Skip to content

Commit 2adafba

Browse files
committed
docs(api): Correct IntegerRangeSerializer schema definition
Adjusts the schema mapping for `IntegerRangeSerializer` by setting `match_subclasses` to `True` and refining the array definition. Adds an example field for clarity in generated OpenAPI documentation. Fixes #20494
1 parent 5f77d68 commit 2adafba

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

netbox/core/api/schema.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,18 @@ def map_serializer_field(self, auto_schema, direction):
282282

283283
class FixIntegerRangeSerializerSchema(OpenApiSerializerExtension):
284284
target_class = 'netbox.api.fields.IntegerRangeSerializer'
285+
match_subclasses = True
285286

286287
def map_serializer(self, auto_schema: 'AutoSchema', direction: Direction) -> _SchemaType:
288+
# One range = two integers; many=True will wrap this in an outer array
287289
return {
288290
'type': 'array',
289291
'items': {
290-
'type': 'array',
291-
'items': {
292-
'type': 'integer',
293-
},
294-
'minItems': 2,
295-
'maxItems': 2,
292+
'type': 'integer',
296293
},
294+
'minItems': 2,
295+
'maxItems': 2,
296+
'example': [10, 20],
297297
}
298298

299299

0 commit comments

Comments
 (0)