I am using flasgger to write my API documentation, one of my function has both GET and POST method.The problem is that flasgger is not able to differentiate between the GET and the POST method. I have written the code only for the post method but it is also associating that code with the GET method
I have attached the image showing the code i have written, as u can see that here I have written code which was meant only for the POST method but it is associating it with the GET method too as shown in the 2nd pic.
This image shows the swagger UI for the GET and POST method. AS you can see that for the GET method it is showing the same results as that for the POST method even though I haven't written anything for GET method.
I want to use the docstring way to integrate swagger into my code what should I do?
Flasgger actually is able to differentiate between docs for single function that operates on different http methods. However, it's not able to create two separate docs from single docstring. The solution provided by flasgger documentation is described here:
@app.route('/api/<string:username>', endpoint='with_user_name', methods=['PUT', 'GET'])
@app.route('/api/', endpoint='without_user_name')
@swag_from('path/to/external_file.yml', endpoint='with_user_name')
@swag_from('path/to/external_file_no_user_get.yml', endpoint='without_user_name', methods=['GET'])
@swag_from('path/to/external_file_no_user_put.yml', endpoint='without_user_name', methods=['PUT'])
...but it requires to keep docs in separate files.