|
@@ -15,10 +15,16 @@ class CustomChoiceFieldInspector(FieldInspector):
|
|
if isinstance(field, ChoiceFieldSerializer):
|
|
if isinstance(field, ChoiceFieldSerializer):
|
|
value_schema = openapi.Schema(type=openapi.TYPE_INTEGER)
|
|
value_schema = openapi.Schema(type=openapi.TYPE_INTEGER)
|
|
|
|
|
|
- if set([None] + list(field._choices.keys())) == {None, True, False}:
|
|
+ choices = list(field._choices.keys())
|
|
-
|
|
+ if set([None] + choices) == {None, True, False}:
|
|
-
|
|
+
|
|
- value_schema = openapi.Schema(type=openapi.TYPE_BOOLEAN)
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ schema_type = openapi.TYPE_INTEGER
|
|
|
|
+ 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)
|
|
value_schema['x-nullable'] = True
|
|
value_schema['x-nullable'] = True
|
|
|
|
|
|
schema = SwaggerType(type=openapi.TYPE_OBJECT, required=["label", "value"], properties={
|
|
schema = SwaggerType(type=openapi.TYPE_OBJECT, required=["label", "value"], properties={
|