Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

ponytailer/flask-dantic-swagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Coverage Status

flask-dantic-swagger

Please use the schema-validator

Use the pydantic to validate your request or response in flask, and it can help you generate swagger quickly.


    class Book(ValidatorModel):
        title: str
        price: int

    class Author(ValidatorModel):
        name: str
        age: int = 30
        books: List[Book]
        address: Optional[str]

    @app.route("/")
    @validate(query=Book, body=Author, response=Author)
    def test_route():
        book_title = request.query_params.title
        author = request.body_params
        author_books = author.books
        return jsonify(author)
    
    test_api = Blueprint("test-api", __name__)

<<< from flask_dantic_swagger import generate_swagger
<<< generate_swagger(app, "")
<<< generate_swagger(app, "test-api") 

About

validate with pydantic and generate swagger.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages