@@ -128,6 +128,10 @@ def _get_field_type(field):
128
128
}.get (field .schema .__class__ , 'string' )
129
129
130
130
131
+ def _get_field_format (field ):
132
+ return field .schema and field .schema .format
133
+
134
+
131
135
def _get_parameters (link , encoding ):
132
136
"""
133
137
Generates Swagger Parameter Item object.
@@ -140,6 +144,7 @@ def _get_parameters(link, encoding):
140
144
location = get_location (link , field )
141
145
field_description = _get_field_description (field )
142
146
field_type = _get_field_type (field )
147
+ field_format = _get_field_format (field )
143
148
if location == 'form' :
144
149
if encoding in ('multipart/form-data' , 'application/x-www-form-urlencoded' ):
145
150
# 'formData' in swagger MUST be one of these media types.
@@ -152,6 +157,8 @@ def _get_parameters(link, encoding):
152
157
}
153
158
if field_type == 'array' :
154
159
parameter ['items' ] = {'type' : 'string' }
160
+ if field_format :
161
+ parameter ['format' ] = field_format
155
162
parameters .append (parameter )
156
163
else :
157
164
# Expand coreapi fields with location='form' into a single swagger
@@ -179,6 +186,8 @@ def _get_parameters(link, encoding):
179
186
'description' : field_description ,
180
187
'schema' : schema
181
188
}
189
+ if field_format :
190
+ parameter ['format' ] = field_format
182
191
parameters .append (parameter )
183
192
else :
184
193
parameter = {
@@ -190,6 +199,8 @@ def _get_parameters(link, encoding):
190
199
}
191
200
if field_type == 'array' :
192
201
parameter ['items' ] = {'type' : 'string' }
202
+ if field_format :
203
+ parameter ['format' ] = field_format
193
204
parameters .append (parameter )
194
205
195
206
if properties :
0 commit comments