Open Addovej opened 1 year ago
Hi,
About the first point,
We should consider this case:
class QueryParams(Group):
some_param: int | None = None
You can make a PR, I will merge it this month.
First part is fixed by https://github.com/Maillol/aiohttp-pydantic/issues/56.
Your contribution to fix the 2nd issue is welcome.
Hello!
There are two issues with generating open api specification for get requests:
1) While parsing group signature, in the _get_group_signature function you decide that param is optional by default value. But it's a lit incorrect because if I write in this way:
it will be still required in the swagger: in
_add_http_method_to_oas
:So if name is not in defaults, then parameter will be required.
in
_get_group_signature
:If default value is None then it value will be removed from defaults even if param type marked as Optional.
I suggest following solution: in
_get_group_signature
:Here I make a new variable
_is_optional
and decide that field is not required if it's marked as Optional.2) The second issue: when you specify query param as any enum type, then enum model schema doesn't being added to open api schema as for body or response schema.
To fix it, you need to modify
_add_http_method_to_oas
function:Above I extracted sub_schema from param schema and set it to common components schema.
Could you please fix it? If not, can I fix it myself and make a PR?