You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two problems with how Enum declared in OAS.
When I create 3 different models with same enum, i find, that in always paste in schema As Is. There is not schema declared in components->schemas section of OAS.
It cause a problem with frontend, when they create bindings with code-gen tools. They need to handle this strings directly.
I think it is better to register Enum as objects in schemas and refer to them.
When you try to make an Enum field optional, instead of getting oneOf{null, schema{enum{...}} you get enum{..., null}, which is incorrect, i think. Because i'm not realy declared null as value of this enum.
This problem caused by the same logic as above.
I have code to fix it (we use it as monkey-patch in our project), so if we confirm that this is a problem, i'll provide PR.
wallseat
changed the title
Bug: Enum get null possible value when optional and not referable
Bug: Enum get null as possible value when optional and it is not referable
May 23, 2024
wallseat
changed the title
Bug: Enum get null as possible value when optional and it is not referable
Bug: Enum get null as possible value when field typed as optional
May 23, 2024
wallseat
changed the title
Bug: Enum get null as possible value when field typed as optional
Bug: Enum OAS issues
May 23, 2024
Description
I have two problems with how Enum declared in OAS.
When I create 3 different models with same enum, i find, that in always paste in schema As Is. There is not schema declared in components->schemas section of OAS.
It cause a problem with frontend, when they create bindings with code-gen tools. They need to handle this strings directly.
I think it is better to register Enum as objects in schemas and refer to them.
When you try to make an Enum field optional, instead of getting oneOf{null, schema{enum{...}} you get enum{..., null}, which is incorrect, i think. Because i'm not realy declared null as value of this enum.
This problem caused by the same logic as above.
I have code to fix it (we use it as monkey-patch in our project), so if we confirm that this is a problem, i'll provide PR.
URL to code causing the issue
No response
MCVE
Result schema
Litestar Version
2.8.2
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: