-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Fails to marshal lists of list arrays.
{"description":"connected solar system pairs",
"in":"query",
"items": {
"collectionFormat":"pipes",
"items": {
"format":"int32",
"type":"integer"
},
"maxItems":2,
"minItems":2,
"type":"array",
"uniqueItems":true},
"maxItems":100,
"name":"connections",
"type":"array",
"uniqueItems":true
}
connections = [[30000142,30002801], [30002801,30002661]]
API response
error="failed to coerce value '[30000142' into type integer (format: int32)
Note presence of "[30000142" in integer.
Expected request
/?connections=30000142%7C30002801,30002801%7C30002661
marshal_collection_format() appears to fail marshalling the list of lists at
bravado-core/bravado_core/param.py
Line 356 in 382db87
def marshal_collection_format(swagger_spec, param_spec, value): |
Monkeypatched with the following
def mymarshal_collection_format(swagger_spec, param_spec, value):
"""For an array, apply the collection format and return the result.
:type swagger_spec: :class:`bravado_core.spec.Spec`
:param param_spec: spec of the parameter with 'type': 'array'
:param value: array value of the parameter
:return: transformed value as a string
"""
result = []
collection_format = swagger_spec.deref(param_spec).get('items').get('collectionFormat', 'csv')
if collection_format == 'multi':
# http client lib should handle this
return value
sep = param.COLLECTION_FORMATS[collection_format]
if any(isinstance(i, list) for i in value):
""" if list of lists, apply marshaling to each item in list"""
for i in value:
result.append( sep.join(str(element) for element in i) )
else:
result = sep.join(str(element) for element in value)
return result
Metadata
Metadata
Assignees
Labels
No labels