10000 Add additional key for items of type array with the type of each element · SoprisApps/python-openapi-codec@6a365e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a365e8

Browse files
committed
Add additional key for items of type array with the type of each element
we will default to 'string' right now in order to make our swagger spec valid.
1 parent a045b2d commit 6a365e8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

openapi_codec/encode.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,20 @@ def _get_parameters(link, encoding):
115115
'required': field.required,
116116
'in': 'formData',
117117
'description': field.description,
118-
'type': field.type or 'string'
118+
'type': field.type or 'string',
119119
}
120+
if field.type == 'array':
121+
parameter['items'] = {'type': 'string'}
120122
parameters.append(parameter)
121123
else:
122124
# Expand coreapi fields with location='form' into a single swagger
123125
# parameter, with a schema containing multiple properties.
124126
schema_property = {
125127
'description': field.description,
126-
'type': field.type or 'string'
128+
'type': field.type or 'string',
127129
}
130+
if field.type == 'array':
131+
schema_property['items'] = {'type': 'string'}
128132
properties[field.name] = schema_property
129133
if field.required:
130 7D0C 134
required.append(field.name)
@@ -148,8 +152,10 @@ def _get_parameters(link, encoding):
148152
'required': field.required,
149153
'in': location,
150154
'description': field.description,
151-
'type': field.type or 'string'
155+
'type': field.type or 'string',
152156
}
157+
if field.type == 'array':
158+
parameter['items'] = {'type': 'string'}
153159
parameters.append(parameter)
154160

155161
if properties:

0 commit comments

Comments
 (0)
0