Просмотр исходного кода

Merge pull request #4303 from kobayashi/4274-prefix-schema

Fix #4274: Set correct value schema for int typed ChoiceField
Jeremy Stretch 6 лет назад
Родитель
Сommit
1b38f3ad3a
2 измененных файлов с 5 добавлено и 0 удалено
  1. 1 0
      docs/release-notes/version-2.7.md
  2. 4 0
      netbox/utilities/custom_inspectors.py

+ 1 - 0
docs/release-notes/version-2.7.md

@@ -10,6 +10,7 @@
 ## Bug Fixes
 ## Bug Fixes
 
 
 * [#4277](https://github.com/netbox-community/netbox/issues/4277) - Fix filtering of clusters by tenant
 * [#4277](https://github.com/netbox-community/netbox/issues/4277) - Fix filtering of clusters by tenant
+* [#4274](https://github.com/netbox-community/netbox/issues/4274) - Fix incorrect schema definition of `int` type choicefields
 * [#4282](https://github.com/netbox-community/netbox/issues/4282) - Fix label on export button for device types
 * [#4282](https://github.com/netbox-community/netbox/issues/4282) - Fix label on export button for device types
 * [#4285](https://github.com/netbox-community/netbox/issues/4285) - Include A/Z termination sites in provider circuits table
 * [#4285](https://github.com/netbox-community/netbox/issues/4285) - Include A/Z termination sites in provider circuits table
 * [#4295](https://github.com/netbox-community/netbox/issues/4295) - Fix assignment of parent LAG during interface bulk edit
 * [#4295](https://github.com/netbox-community/netbox/issues/4295) - Fix assignment of parent LAG during interface bulk edit

+ 4 - 0
netbox/utilities/custom_inspectors.py

@@ -89,6 +89,10 @@ class CustomChoiceFieldInspector(FieldInspector):
                 value_schema = openapi.Schema(type=schema_type)
                 value_schema = openapi.Schema(type=schema_type)
                 value_schema['x-nullable'] = True
                 value_schema['x-nullable'] = True
 
 
+            if isinstance(choices[0], int):
+                # Change value_schema for IPAddressFamilyChoices, RackWidthChoices
+                value_schema = openapi.Schema(type=openapi.TYPE_INTEGER)
+
             schema = SwaggerType(type=openapi.TYPE_OBJECT, required=["label", "value"], properties={
             schema = SwaggerType(type=openapi.TYPE_OBJECT, required=["label", "value"], properties={
                 "label": openapi.Schema(type=openapi.TYPE_STRING),
                 "label": openapi.Schema(type=openapi.TYPE_STRING),
                 "value": value_schema
                 "value": value_schema