Skip to content

Commit

Permalink
Fix OpenAPI schema for vid_ranges in VLANGroup so it shows up
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed Dec 13, 2024
1 parent 8951aa8 commit 215206b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions netbox/netbox/api/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,29 @@ def __init__(self, relation, **kwargs):
super().__init__(**kwargs)


_integer_range_schema = {
'type': 'array',
'items': {
'type': 'integer',
},
'minItems': 2,
'maxItems': 2,
}

@extend_schema_field({
'type': 'array',
'items': _integer_range_schema,
})
class IntegerRangeListSerializer(serializers.ListSerializer):
# this special class is only here to work around
# https://github.com/tfranzel/drf-spectacular/issues/1353
pass

@extend_schema_field(_integer_range_schema)
class IntegerRangeSerializer(serializers.Serializer):
class Meta:
list_serializer_class = IntegerRangeListSerializer

"""
Represents a range of integers.
"""
Expand Down

0 comments on commit 215206b

Please sign in to comment.