-
Notifications
You must be signed in to change notification settings - Fork 271
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
Invalid nullable case using OpenAPI 3.1.0 support #1133
Comments
hi, yes OAS 3.1 is a new feature, and there are probably 1 or 2 more flaws we have to hammer out. I fixed a missing case in d78a21c. However, I cannot be certain this addresses your specific assertion warning. Can you test the master branch an see if your issue is gone? |
I see this too. In my case It happens because some JSONField in library has not label attrubute. |
OAS 3.1.0 + JSONField(null=True) on a model attribute will trigger |
I tested, unfortunately I get the same error. |
As written above, serializers.JSONField(allow_null=True) causes this error. The d78a21c solution in master branch does not solve this. The reason I wanted to use OpenAPI 3.1.0 was that I needed the request body for delete. I fixed the JSONFields for testing purposes. Afterwards, I defined a request body for delete with different attempts, but I was not successful in any of them.
or
or
|
This commit should fix you Regarding OAS 3.1 and |
Thanks for the fix. If |
@koksalkapucuoglu , please check again against current master. @Viicos fixed another case. |
same issue with |
@anyidea can't reproduce your issue on current |
just released 0.27.1 let me know if there is still cases missing. |
@tfranzel first of all, I'm sorry for replying a little late.
But I noticed something: |
I have no idea what that is supposed to represent. Please provide a OpenAPI schema snippet for discussion.
That is likely a Swagger UI thing independent of us or this issue in particular. |
serializers.py schema.yml
x seems like string at example_value at swagger ui, and it seems like "write-only(any | null)" at schema section at swagger ui. |
that is the correct schema. |
ok, then we can close this issue. |
Describe the bug
I change to drf-spectacular version from 0.26.5 to 0.27.0 for OpenAPI 3.1.0 support. I also changed OAS_VERSION in the settings. Afterwards, when I want to open swagger, I get the AssertionError: Invalid nullable case error.
web_1 | File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
web_1 | response = get_response(request)
web_1 | File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
web_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1 | File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
web_1 | return view_func(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
web_1 | return self.dispatch(request, *args, **kwargs)
web_1 | File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
web_1 | response = self.handle_exception(exc)
web_1 | File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
web_1 | self.raise_uncaught_exception(exc)
web_1 | File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
web_1 | raise exc
web_1 | File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
web_1 | response = handler(request, *args, **kwargs)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/views.py", line 84, in get
web_1 | return self._get_schema_response(request)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/views.py", line 92, in _get_schema_response
web_1 | data=generator.get_schema(request=request, public=self.serve_public),
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/generators.py", line 281, in get_schema
web_1 | paths=self.parse(request, public),
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/generators.py", line 252, in parse
web_1 | operation = view.schema.get_operation(
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 111, in get_operation
web_1 | operation['responses'] = self._get_response_bodies()
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 1367, in _get_response_bodies
web_1 | return {'200': self._get_response_for_code(response_serializers, '200', direction=direction)}
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 1423, in _get_response_for_code
web_1 | component = self.resolve_serializer(serializer, direction)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 1605, in resolve_serializer
web_1 | component.schema = self._map_serializer(serializer, direction, bypass_extensions)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 927, in _map_serializer
web_1 | schema = self._map_basic_serializer(serializer, direction)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 1026, in _map_basic_serializer
web_1 | schema = self._map_serializer_field(field, direction)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/openapi.py", line 863, in _map_serializer_field
web_1 | return append_meta(build_basic_type(OpenApiTypes.ANY), meta)
web_1 | File "/usr/local/lib/python3.9/site-packages/drf_spectacular/plumbing.py", line 537, in append_meta
web_1 | assert False, 'Invalid nullable case' # pragma: no cover
web_1 | AssertionError: Invalid nullable case
The text was updated successfully, but these errors were encountered: