From 99e367cbaf7e857d9cee5fb01fdf47b70545f1f5 Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Fri, 3 Oct 2025 17:31:53 +0200 Subject: [PATCH] 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 --- netbox/core/api/schema.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/netbox/core/api/schema.py b/netbox/core/api/schema.py index 0c59da5a1..c61675cf3 100644 --- a/netbox/core/api/schema.py +++ b/netbox/core/api/schema.py @@ -282,18 +282,18 @@ class FixSerializedPKRelatedField(OpenApiSerializerFieldExtension): class FixIntegerRangeSerializerSchema(OpenApiSerializerExtension): target_class = 'netbox.api.fields.IntegerRangeSerializer' + match_subclasses = True def map_serializer(self, auto_schema: 'AutoSchema', direction: Direction) -> _SchemaType: + # One range = two integers; many=True will wrap this in an outer array return { 'type': 'array', 'items': { - 'type': 'array', - 'items': { - 'type': 'integer', - }, - 'minItems': 2, - 'maxItems': 2, + 'type': 'integer', }, + 'minItems': 2, + 'maxItems': 2, + 'example': [10, 20], }