Skip to content
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

JSONField uses dict schema but can be any json primitive #1095

Closed
Kangaroux opened this issue Oct 31, 2023 · 1 comment
Closed

JSONField uses dict schema but can be any json primitive #1095

Kangaroux opened this issue Oct 31, 2023 · 1 comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@Kangaroux
Copy link

Kangaroux commented Oct 31, 2023

Describe the bug
When using a JSONField in the serializer, the generated schema is for an object. However, DRF describes it as being any json primitive: strings, numbers, booleans, etc. The current implementation seems more appropriate for DictField, not JSONField

To Reproduce

from rest_framework import serializers

class MySerializer(serializers.Serializer):
  json_field = serializers.JSONField()

Expected behavior
The generated type should be OpenApiTypes.ANY.

@tfranzel
Copy link
Owner

tfranzel commented Nov 1, 2023

excellent point, a string or number would be possible too.

@tfranzel tfranzel added the bug Something isn't working label Nov 1, 2023
@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Nov 2, 2023
@tfranzel tfranzel closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants