1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix #4274: Set correct value schema for int typed ChoiceField

This commit is contained in:
kobayashi
2020-03-02 11:26:56 -05:00
parent 13fcdc0c1e
commit 0be5488104
2 changed files with 5 additions and 0 deletions

View File

@@ -89,6 +89,10 @@ class CustomChoiceFieldInspector(FieldInspector):
value_schema = openapi.Schema(type=schema_type)
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={
"label": openapi.Schema(type=openapi.TYPE_STRING),
"value": value_schema