Path parameters support in swagger #369
-
Is there a way to add path parameters in Gateway route or request method for Swagger. Right now if you create a manual json or yaml file for swagger, It shows up but it does not detect path parameters if it is defined in path. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 45 replies
-
Hi, I'm not sure of I understood you question properly but basically if I did, then what you need to do is simply, for example: @get("/pet/{petid}") And then in the Gateway, you simply do: Gateway(handler=get_pet) All of this is in the docs thoroughly explained as well 🙂. Esmerald automatically detects the path params. When you create a path param in the URL, you must pass it in the handler with the corresponding type. |
Beta Was this translation helpful? Give feedback.
-
@saurabhgharatpara this was a small regression introduced by a big feature 3 versions ago but its being addressed here #371 Soon (today or tomorrow) this should be released and no issues like this should happen again 👍🏼 |
Beta Was this translation helpful? Give feedback.
-
@saurabhgharatpara version 3.3.4 of Esmerald was released and this query parameters should not be an issue anymore. There is also the documentation for it if you want https://www.esmerald.dev/extras/query-params/ |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This issue is solved by making changes in signature.py file for parse_values_for_connection function def parse_values_for_connection(cls, connection: Union[Request, WebSocket], **kwargs: Dict[str, Any]) -> Any:
|
Beta Was this translation helpful? Give feedback.
-
@saurabhgharatpara apologies for the time it took but we needed to investigate the source cause for this and it wasn't a simple thing. Not a bug from Esmerald but from one of the dependencies. This is now working 100% ok with the new version released just now. 3.4.1 Have a look at the release notes but it should now work like a charm for optional query params. |
Beta Was this translation helpful? Give feedback.
-
@saurabhgharatpara i received an email with a reply from you but I can't find it in the conversation. Did you delete it? |
Beta Was this translation helpful? Give feedback.
@saurabhgharatpara Yes, I mentioned that before
Every path parameter and the type must be declared in the function handler in order to make sure it will be recognised.