From 6fe1b9b37cf42d87824ad003247331f4a6447920 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Mon, 9 Dec 2019 00:41:43 -0500 Subject: [PATCH] update openapi field type for choice field value fields to string --- netbox/utilities/custom_inspectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/utilities/custom_inspectors.py b/netbox/utilities/custom_inspectors.py index 9662612f9..471232ce3 100644 --- a/netbox/utilities/custom_inspectors.py +++ b/netbox/utilities/custom_inspectors.py @@ -75,7 +75,7 @@ class CustomChoiceFieldInspector(FieldInspector): SwaggerType, _ = self._get_partial_types(field, swagger_object_type, use_references, **kwargs) if isinstance(field, ChoiceField): - value_schema = openapi.Schema(type=openapi.TYPE_INTEGER) + value_schema = openapi.Schema(type=openapi.TYPE_STRING) choices = list(field._choices.keys()) if set([None] + choices) == {None, True, False}: @@ -83,7 +83,7 @@ class CustomChoiceFieldInspector(FieldInspector): # differentiated since they each have subtly different values in their choice keys. # - subdevice_role and connection_status are booleans, although subdevice_role includes None # - face is an integer set {0, 1} which is easily confused with {False, True} - schema_type = openapi.TYPE_INTEGER + schema_type = openapi.TYPE_STRING if all(type(x) == bool for x in [c for c in choices if c is not None]): schema_type = openapi.TYPE_BOOLEAN value_schema = openapi.Schema(type=schema_type)