-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestParser json list shown as type string in swagger json #173
Comments
After creating this issue I saw #59 (did not read it all) which makes me think that any issues related to RequestParser will not be fixed. I have noted that I can get the behavior that I want by creating a model from a json schema and expecting the model. Is this a good approach to achieve this which hopefully will not be affected by future changes related to issue #59? What worked for me is the following: from flask import Flask, request
from flask_restx import Api, Resource
app = Flask(__name__)
api = Api(app)
request_schema = {
'type': 'object',
'properties': {
'list': {
'type': 'array',
'items': {'type': 'string'},
'minItems': 1,
},
},
'additionalProperties': False,
'required': ['list'],
}
request_model = api.schema_model('test_list_request', request_schema)
@api.route('/test_list')
class TestList(Resource):
@api.expect(request_model, validate=True)
def get(self):
print(request.json)
return request.json
app.run() |
I have a similar issue with file uploads: Swagger.json shows a string type for the parser argument image. Hence, no File Upload Button
|
I also faced this problem. After reading the documentation, I have to add this lines of code to render type list parameter. But i still use the request parser to validate the request. It's just a temporary solution, because we have to write the parameters twice, both for documentation and for receiving the parameters.
|
Add location='files' |
Still not fix yet? |
If I create a request parser with an argument whose location is json and type list, in the api swagger json I see this argument as type string. I would have expected this to be shown as an array with items of type string. Am I right to expect this? Or is there some reason why it is shown as type string?
Steps to reproduce
issue.py
with the following:curl http://127.0.0.1:5000/swagger.json | python3 -mjson.tool
In the printed json you would observe the type of list as string
The text was updated successfully, but these errors were encountered: