External yml with flask_restful method
See original GitHub issueIs this an expected behaviour?
This works:
class todo(Resource):
def get(self, todo_id):
"""
file: todo_get.yml
"""
abort_if_todo_doesnt_exist(todo_id)
return TODOS[todo_id]
This:
from flasgger import swag_from
class todo(Resource):
@swag_from('todo_get.yml', validation=True)
def get(self, todo_id):
abort_if_todo_doesnt_exist(todo_id)
return TODOS[todo_id]
Gives: Code: 200 Data: { “message”: null }
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Extending Flask-RESTful — Flask-RESTful 0.3.8 documentation
It is possible to configure how the default Flask-RESTful JSON representation will format JSON by providing a RESTFUL_JSON attribute on the application ...
Read more >flasgger/flasgger: Easy OpenAPI specs and Swagger UI for ...
Using docstrings as specification · Using external YAML files · Using dictionaries as raw specs · Using Marshmallow Schemas · Using Flask RESTful...
Read more >Python REST APIs With Flask, Connexion, and SQLAlchemy
This tutorial series is a hand-on guide on how to create a REST API with Flask and interact with it using CRUD operations....
Read more >Working with APIs using Flask, Flask-RESTPlus and Swagger UI
I defined the application as a flask application using the method Flask() which sets the name using __name__ . Next, I'll used Api...
Read more >README.md · Flasgger/flasgger - Gitee.com
Getting started · Using docstrings as specification · Using external YAML files · Using dictionaries as raw specs · Using Marshmallow Schemas ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I have the same issue here, using manual validation
Response is:
{"message": null}
When using this code:
Everything is fine when removing the validation step
I’ve experienced a similar or same issue.
By changing the abort call in parse_request: https://github.com/flasgger/flasgger/blob/31c86c4db66b3e4d6446bb024cca50cf51652561/flasgger/base.py#L638
to:
It successfully returns the ValidationError message with the status code 400. I tried to figure out why it fails to abort with the Response object, but couldn’t find the cause.
However, for a better end user experience perhaps the try/except clause should be replaced by something like this?:
The formatting of the messages should perhaps be configured by the user, but this is just an example.