serializers.JSONField()
openapi definition should include additionalProperties: true
#8776
Unanswered
johnnymetz
asked this question in
Potential Issue
Replies: 1 comment
-
you can send an improvement request or you can also try drf-spectacular as default schema generator |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Looks like
my_field = serializers.JSONField()
currently generates the following openapi spec:It should generate the following spec (or at least provide an option to generate it):
The reason being that the latter is considered a "free-form" object, which can have any key-value pairs (see here).
The former is generally considered an empty object, see here: openapi-ts/openapi-typescript#1004 (comment)
Implementation Notes
AutoSchema.map_field()
here:django-rest-framework/rest_framework/schemas/openapi.py
Line 368 in 041b88f
Probably just need to include the following snippet inside that method:
Beta Was this translation helpful? Give feedback.
All reactions