parent
9f60dc191a
commit
708e70a526
|
|
@ -597,16 +597,22 @@ class ChoiceFieldInspector(FieldInspector):
|
|||
if model_type:
|
||||
enum_type = model_type.get('type', enum_type)
|
||||
|
||||
enum_values = list(field.choices.keys())
|
||||
if isinstance(field, serializers.MultipleChoiceField):
|
||||
return SwaggerType(
|
||||
result = SwaggerType(
|
||||
type=openapi.TYPE_ARRAY,
|
||||
items=ChildSwaggerType(
|
||||
type=enum_type,
|
||||
enum=list(field.choices.keys())
|
||||
enum=enum_values
|
||||
)
|
||||
)
|
||||
if swagger_object_type == openapi.Parameter:
|
||||
if result['in'] in (openapi.IN_FORM, openapi.IN_QUERY):
|
||||
result.collection_format = 'multi'
|
||||
else:
|
||||
result = SwaggerType(type=enum_type, enum=enum_values)
|
||||
|
||||
return SwaggerType(type=enum_type, enum=list(field.choices.keys()))
|
||||
return result
|
||||
|
||||
return NotHandled
|
||||
|
||||
|
|
|
|||
|
|
@ -81,3 +81,4 @@ class UserSerializerrr(serializers.ModelSerializer):
|
|||
class UserListQuerySerializer(serializers.Serializer):
|
||||
username = serializers.CharField(help_text="this field is generated from a query_serializer", required=False)
|
||||
is_staff = serializers.BooleanField(help_text="this one too!", required=False)
|
||||
styles = serializers.MultipleChoiceField(help_text="and this one is fancy!", choices=('a', 'b', 'c', 'd'))
|
||||
|
|
|
|||
|
|
@ -740,6 +740,19 @@ paths:
|
|||
description: this one too!
|
||||
required: false
|
||||
type: boolean
|
||||
- name: styles
|
||||
in: query
|
||||
description: and this one is fancy!
|
||||
required: true
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
- d
|
||||
collectionFormat: multi
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
|
|
@ -1159,6 +1172,7 @@ definitions:
|
|||
- fan
|
||||
- fancy
|
||||
- felix
|
||||
- fennel
|
||||
- fish
|
||||
- flatline
|
||||
- forth
|
||||
|
|
@ -1184,6 +1198,7 @@ definitions:
|
|||
- haskell
|
||||
- haxeml
|
||||
- hexdump
|
||||
- hlsl
|
||||
- hsail
|
||||
- html
|
||||
- html+cheetah
|
||||
|
|
@ -1450,6 +1465,7 @@ definitions:
|
|||
- xml+php
|
||||
- xml+smarty
|
||||
- xml+velocity
|
||||
- xorg.conf
|
||||
- xquery
|
||||
- xslt
|
||||
- xtend
|
||||
|
|
|
|||
Loading…
Reference in New Issue