{"id":5627,"library":"flask-openapi3","title":"flask-openapi3","description":"Flask-OpenAPI3 is a web API framework based on Flask, currently at version 4.3.1. It simplifies the generation of REST APIs and OpenAPI documentation (including Swagger UI, ReDoc, and RapiDoc) for Flask projects. It leverages Pydantic for data validation and schema definition, and is actively maintained with frequent updates.","status":"active","version":"4.3.1","language":"en","source_language":"en","source_url":"https://github.com/luolingchun/flask-openapi3","tags":["flask","openapi","swagger","api documentation","pydantic","rest-api"],"install":[{"cmd":"pip install flask-openapi3","lang":"bash","label":"Standard Installation"},{"cmd":"pip install flask-openapi3[swagger,redoc,rapidoc]","lang":"bash","label":"With Common UI Plugins"}],"dependencies":[{"reason":"Core web framework integration.","package":"Flask","optional":false},{"reason":"Data validation and schema definition.","package":"Pydantic","optional":false}],"imports":[{"symbol":"OpenAPI","correct":"from flask_openapi3 import OpenAPI"},{"symbol":"Info","correct":"from flask_openapi3 import Info"},{"symbol":"Tag","correct":"from flask_openapi3 import Tag"},{"note":"Used for defining request/response schemas.","symbol":"BaseModel","correct":"from pydantic import BaseModel"}],"quickstart":{"code":"from flask_openapi3 import Info, Tag, OpenAPI\nfrom pydantic import BaseModel\n\ninfo = Info(title='Book API', version='1.0.0')\napp = OpenAPI(__name__, info=info)\n\nbook_tag = Tag(name='book', description='Book management operations')\n\nclass BookQuery(BaseModel):\n    age: int\n    author: str\n\n@app.get('/book', tags=[book_tag], summary='Get books by query')\ndef get_book(query: BookQuery):\n    \"\"\"Retrieves a list of books based on age and author.\"\"\"\n    return {\n        \"code\": 0,\n        \"message\": \"ok\",\n        \"data\": [\n            {\"bid\": 1, \"age\": query.age, \"author\": query.author},\n            {\"bid\": 2, \"age\": query.age, \"author\": query.author}\n        ]\n    }\n\nif __name__ == '__main__':\n    # Access OpenAPI docs at http://127.0.0.1:5000/openapi\n    app.run(debug=True)","lang":"python","description":"This example initializes a Flask-OpenAPI3 application, defines a Pydantic model for query parameters, and registers a GET endpoint. The OpenAPI documentation will be automatically generated and accessible at `/openapi`."},"warnings":[{"fix":"For v4.x, continue using `flask-openapi3`. For v5+, install `flask-openapi` and update imports from `flask_openapi3` to `flask_openapi`.","message":"The upcoming major version (v5.0.0rc1 and beyond) renames the library from `flask-openapi3` to `flask-openapi`. This will require installing a new package (`pip install flask-openapi`) and updating import statements.","severity":"breaking","affected_versions":"v5.0.0rc1+"},{"fix":"Upgrade to `flask-openapi3>=4.3.0` to ensure correct handling of Pydantic v2 validation errors.","message":"When using Pydantic v2 (required `Pydantic>=2.4`), be aware that the `ValidationError` schema changed. Version 4.3.0 of `flask-openapi3` includes a fix for this, so ensure you are on `v4.3.0` or newer for full compatibility.","severity":"gotcha","affected_versions":"<4.3.0 when using Pydantic v2"},{"fix":"Upgrade to `flask-openapi3>=4.2.1`. If upgrading is not possible, ensure `register_api` is only called once per blueprint or handle potential side effects manually.","message":"When registering blueprints, older versions of `flask-openapi3` (prior to 4.2.1) had an issue where `register_api` was not idempotent. Repeated calls could lead to unexpected behavior or duplicate routes.","severity":"gotcha","affected_versions":"<4.2.1"},{"fix":"Always navigate to the base `/openapi` path provided by the extension, which then links to the specific UI tools.","message":"The generated API documentation (Swagger UI, Redoc, etc.) is typically served under the `/openapi` path (e.g., `http://127.0.0.1:5000/openapi`). Users sometimes expect direct access at `/swagger` or `/redoc`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}