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

Endpoint path parameters type specification compatibility with OAS #746

Closed
inverseTrig opened this issue Dec 7, 2019 · 1 comment · Fixed by #1648
Closed

Endpoint path parameters type specification compatibility with OAS #746

inverseTrig opened this issue Dec 7, 2019 · 1 comment · Fixed by #1648

Comments

@inverseTrig
Copy link

inverseTrig commented Dec 7, 2019

When specifying a convertor type for a path parameter like so:

...
Route('/users/{user_id:int}', user, methods=["GET", "POST"])
...

The OAS schema generated using SchemaGenerator interprets the whole portion within {} eg. 'user_id:int' as the required path parameter variable name, which then requires the parameter name in OAS to be user_id:int instead of just user_id.

user_idint

I think the convertor is great in that a GET request to /users/foo will result in 404: NOT FOUND. Of course, another option is to have a try-except clause to handle non-integer values within the method... but I was wondering what the community thinks about this and if this even should be supported by the SchemaGenerator.

@tomchristie
Copy link
Member

Thanks for raising this.

As a first pass at resolving this we should just do the simple thing and strip any :<specifier> portion from the string. Would gratefully accept a pull request for that.

A second pass could be to also make sure that we're generating the correct type description in OpenAPI.

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

Successfully merging a pull request may close this issue.

2 participants