pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
76 stars 24 forks source link

Bug in open api rules processing - AnyConverter #81

Open doug-granular opened 3 months ago

doug-granular commented 3 months ago

Hello, Thank you for this repo.

Discovered a bug when trying to add some documentation to route parameters.

In our use case we want to document an enumerated list of possible values for a url path parameter like so:

/<any(\"enum1\", \"enum2\", \"enum3\"):parameter_name>

This works, but the problem is the generated openapi.json also pulls in some other schema info from the request body, which ends up looking very strange in swagger.

The cause of this bug is the schema dictionary variable is reused from the above code. See https://github.com/pgjones/quart-schema/blob/main/src/quart_schema/extension.py#L590

I am attaching a patch file. Tried to submit a PR but couldn't

Note: should also consider setting the type at line 590 like so: params_schema.update({"type": "string", "enum": list(converter.items)})

Patch file: fixbug-_do_not_reuse_schema_dictionary_from_above_logic_Improve_the_decorator_typing.patch

pgjones commented 3 months ago

Thanks fixed in 125e218d7a35a2eb9fc8216de2905f5479939dd3