-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
default value for path field should be empty string instead of None #5224
Conversation
It seems it's not as simple as that since it breaks a few tests. |
if this is something that can be accepted I can invest the time to adjust the tests that broke |
Good point. |
Okay, so I think we need a slightly different tack to this, even if might seem obvious on first sight. Our current internal representation for a path field is "has no default, is required" which is exactly what we want. What's awkward is how swagger UI chooses to display that. My opinion is that we should instead change how we map this case onto a Swagger representation, rather than break our underlying Core API representation. |
Well, None is rendered as null in JSON, so I believe the renderer is correct, the UI renders null as 'null'. this could be an issue with swagger UI, but right now I have my hands on the python side of things. We could change the generator to not include the default attribute if the value is None, this would cause the UI to not display a default value, the same as it shows an empty string, but what would happen if someone actually wants null to be the default value? |
Looks like a django-rest-swagger issue. It should take this into account during CoreAPI -> OpenAPI conversion |
I'm going to close this. There may be issue(s) with (a) particular renderer(s) but that's not here with the autogeneration of path fields. Happy to review better targeted issues. |
Description
the schema_cls doesn't pass the default value for the field, so it will be None, meaning swagger ui will show 'null' when it should be empty