Skip to content

Commit

Permalink
differentiate test cases for 3.1 null cases #1139
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Jan 6, 2024
1 parent 1e28d3e commit 691ac46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3266,7 +3266,8 @@ def view_func(request, format=None):
@mock.patch('drf_spectacular.settings.spectacular_settings.OAS_VERSION', '3.1.0')
def test_basic_oas_3_1_nullable_cases(no_warnings, django_transforms):
class M14(models.Model):
field_json = models.JSONField(null=True, help_text="field_json desc") # case 1
field_json = models.JSONField(null=True) # case 1
field_json2 = models.JSONField(null=True, help_text="field_json desc") # case 3

class XSerializer(serializers.ModelSerializer):

Expand All @@ -3286,7 +3287,8 @@ class XViewset(viewsets.ReadOnlyModelViewSet):
schema = generate_schema('m2', XViewset)
assert schema['components']['schemas']['X']['properties'] == {
'id': {'readOnly': True, 'type': 'integer'},
'field_json': {'oneOf': [{}, {'type': 'null'}], 'description': 'field_json desc'},
'field_json': {'oneOf': [{}, {'type': 'null'}]},
'field_json2': {'oneOf': [{}, {'type': 'null'}], 'description': 'field_json desc'},
'field_method_hint': {
'oneOf': [
{'type': 'integer'},
Expand Down

0 comments on commit 691ac46

Please sign in to comment.