Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

issue with Path Parameter Definition in Swagger using @hono/zod-openapi #144

Closed
omar-tekab opened this issue Aug 25, 2023 · 3 comments
Closed

Comments

@omar-tekab
Copy link

Issue Description:

unnamed

When following the example provided by @hono/zod-openapi and using the path parameter syntax '{id}' in Swagger to define an endpoint path like '/users/{id}', an issue arises where the defined endpoint cannot be found. This results in a 404 error when testing the endpoint with Postman or any. However, when the path is manually changed to '/users/:id', the endpoint functions correctly.

Steps to Reproduce:

Utilize the example provided by @hono/zod-openapi for defining an endpoint path with a path parameter using '{id}' syntax.
Try to access the defined endpoint using Postman or any other API testing tool.

Expected Behavior:

The endpoint defined with the '{id}' syntax should be successfully recognized and accessible both in Swagger documentation and when tested.

Actual Behavior:

When using the defined '{id}' path parameter syntax in Swagger, the endpoint cannot be found, and a 404 error is returned when testing the endpoint api call. However, changing the path parameter syntax to '/users/:id' makes the endpoint work as expected.

Additional Information:

This issue seems to be specific to the use of the '{id}' path parameter syntax in Swagger, as manually changing it to '/users/:id' in both the Swagger documentation and the testing tool resolves the issue.
When modifying the OpenAPI documentation directly to use '/users/{id}' and accessing the endpoint, it functions correctly.
It appears that the inconsistency lies in how the '{id}' syntax is interpreted when used within the Swagger documentation.

Environment Details:

Library: @hono/zod-openapi
OpenAPI Definition: (Provide the relevant OpenAPI definition excerpt where the endpoint is defined)
Testing Tool: Postman (or specify the testing tool used)
API Endpoint Path: '/users/{id}'
HTTP Method: GET (or specify the method)

Screenshots when i use :id in postman and swagger

Screenshot from 2023-08-25 14-30-29

Screenshot from 2023-08-25 14-32-52

Screenshots when i use {id} in postman and swagger

Screenshot from 2023-08-25 14-32-11

Screenshot from 2023-08-25 14-34-48

Labels:

Bug
Swagger
OpenAPI
Path Parameter
Your prompt attention to this issue would be greatly appreciated. If additional information is required, please let me know. Thank you for your assistance in resolving this matter.

@yusukebe
Copy link
Member

yusukebe commented Aug 25, 2023

Hi @omar-tekab

This bug is should be fix in latest version. Could you try with it?

@omar-tekab
Copy link
Author

Thank you! The bug has been fixed.

@yusukebe
Copy link
Member

Yeah! Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants