8000 Merge pull request #21 from angvp/issue-20 · Pix4D/python-openapi-codec@f914daa · GitHub
[go: up one dir, main page]

Skip to content

Commit f914daa

Browse files
authored
Merge pull request core-api#21 from angvp/issue-20
Add additional key for items of type array in order to make swagger spec valid
2 parents a045b2d + 6a365e8 commit f914daa

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:
130134
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