I'm developing a python API with flask and swagger, and I want to change one of the inputs from string to list:
This is the current working code for the schema :
/question:
post:
operationId: processor.convertInputString
tags:
- People
summary: Create a person and add it to the people list
description: Create a new person in the people list
parameters:
- name: input_string_2
in: body
description: Person to create
required: True
schema:
type: object
properties:
question:
type: list
description: question to match
responses:
201:
description: Successfully created person in list
and the request i'm using:
data = {"question": "processor","num_results":3}
headers = {'content-type': 'application/json'}
url = "http://localhost:5000/api/question"
data = requests.post(url,data=json.dumps(data), headers=headers)
This works fine, but I need To change {"question": "processor"} for:
{"question": ["processor"]}
but when I make that request I get this error:
'{\n "detail": "[\'processor\'] is not of type \'string\'",\n "status": 400,\n "title": "Bad Request",\n "type": "about:blank"\n}\n'
Hence I tried to change change the data type from string to list in the schema:
schema:
type: object
properties:
question:
type: list
description: question to match
But I get another error with that.
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['post']['properties']['parameters']['items']:
{'oneOf': [{'$ref': '#/definitions/parameter'},
{'$ref': '#/definitions/jsonReference'}]}
On instance['paths']['/question']['post']['parameters'][0]:
{'description': 'Person to create',
'in': 'body',
'name': 'input_string_2',
'required': True,
'schema': {'properties': {'question': {'description': 'question to '
'match',
'type': 'list'}},
'type': 'object'}}