Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generated client is not working when there are more than one API's with the colon in the API path #1726

Open
soodpr opened this issue Aug 14, 2024 · 3 comments · May be fixed by #1879
Open

Comments

@soodpr
Copy link

soodpr commented Aug 14, 2024

There seems to be a bug if the API spec contains more than one API's with colon in the API Path, it always return the response of 1st API.
I have put an example in this repo here: https://github.com/soodpr/oapi-codegen-bug

If we run both server and client code in the above example, the expected output from the client main program is that it first calls the /pets:validate and then /pets:generate API but in reality, its always end up calling /pets:validate API twice.

Let me know if you require any further details on this.

@cosban
Copy link
Contributor

cosban commented Oct 28, 2024

soodpr's example is based on echo, but this issue is also present with gin. It seems that the code generator needs to update its SwaggerUriToGinUri and SwaggerUriToEchoUri methods to include escaping the literal colon characters.

I believe such an update would not take very long to implement and I would be willing to submit an PR for it if doing so helps speed up getting the fix in.

labstack/echo#2046
gin-gonic/gin#1432

@cosban
Copy link
Contributor

cosban commented Oct 28, 2024

In the meantime, you may be able to work around the issue by manually escaping these paths yourself in the spec.

i.e. /pets\\:generate

The only problem is that the escape characters will show up in the spec, which means it will not be accurate.

@holyfuchs
Copy link

the issue is also present in fiber.
Escaping the paths in the same way fixes it as well.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
3 participants