Skip to content

Commit

Permalink
some minors
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Oct 3, 2024
1 parent 6f3a656 commit d05e5be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 70 deletions.
4 changes: 2 additions & 2 deletions drf_spectacular/plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ def safe_ref(schema: _SchemaType) -> _SchemaType:

def append_meta(schema: _SchemaType, meta: _SchemaType) -> _SchemaType:
if spectacular_settings.OAS_VERSION.startswith('3.1'):
schema = copy.deepcopy(schema)
meta = copy.deepcopy(meta)
schema = schema.copy()
meta = meta.copy()

schema_nullable = meta.pop('nullable', None)
meta_nullable = schema.pop('nullable', None)
Expand Down
11 changes: 7 additions & 4 deletions tests/test_extend_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,13 @@ class XSerializer(serializers.Serializer):
def view_func(request, format=None):
pass # pragma: no cover

assert_schema(
generate_schema('x', view_function=view_func),
'tests/test_extend_schema_field_with_dict_oas_3_1.yml'
)
schema = generate_schema('x', view_function=view_func)

assert schema['components']['schemas']['X']['properties'] == {
'field1': {'readOnly': True, 'type': ['string', 'null']},
'field2': {'readOnly': True, 'type': ['string', 'null']},
'field3': {'readOnly': True, 'type': ['string', 'null']}
}


def test_layered_extend_schema_on_view_and_method_with_meta(no_warnings):
Expand Down
64 changes: 0 additions & 64 deletions tests/test_extend_schema_field_with_dict_oas_3_1.yml

This file was deleted.

0 comments on commit d05e5be

Please sign in to comment.