-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] nullable enum property #1997
Comments
@rienafairefr thanks for reporting the issue and suggesting the fix. What about doing that in the template with |
Hmm, I might have actually misunderstood the problem with the API spec. For complete reference, the spec, and we see some enum properties that have a list of allowed values containing null, like:
This is parsed as ["red", "orange", "yellow", "green", "blue", "purple", "null"] by OpenAPI, and this generates an incorrect client that doesn't allow for an actual
which won't allow a value of None (which can be received in the json) Apparently an actual This is deeper than I thought and is a bug in swagger-parser itself in my opinion. |
I'm having the same issue described by @rienafairefr.
is getting turned into
Imo null should be converted to |
I am also having issues even when following the examples as outlined in #7754 |
Bug Report Checklist
Description
If encountered this using the python but I feel like this is the case in a lot of cases
I encountered an API that was publishing a 2.0 spec, but I'm getting resultst from the API that are out-of-spec and not possible to be parsed by a generate openapi-generator client, mostly sending null on non-nullable properties. But the issue is for enum values, I'm not sure how a client should validate:
a small spec that is apparently valid according to 3.0.2
if the enum is nullable, then getting a
null
as a result data from an API call should be valid and we should get a property typed likeEnum? in C#, or a
None` value in Python, and that should be valid. But the code in the case of an enum lists the allowable values excluding null, even if the enum property is specified nullableSuggest a fix
allowed_values
list in Python seems to at least make the client accept what the API sends, not sure if that's the full extent that a fix would takeThe text was updated successfully, but these errors were encountered: