Registry / web-framework / quart-schema

quart-schema

JSON →
library0.23.0pypypi✓ verified 88d ago

A Quart extension providing request/response schema validation using Pydantic models and OpenAPI documentation generation. Current version 0.23.0, compatible with Python >=3.10. Actively maintained, with regular releases.

pip install quart-schema
INSTALL
IMPORT
SIG · QUART-SCHEMA
Q
quart-schema
web-frameworkpythonv0.23.0
Install
3.2s avg
Import
1651ms
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.23.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.314s · 26.6MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.2s · import 1.328s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QuartSchema
✓ from quart_schema import QuartSchema
✗ from quart_schema import QuartSchema as QS
Aliasing not needed, but acceptable. Common mistake: importing from wrong package (e.g., 'quart_schema' vs 'quart_schema.core')
validate_request
✓ from quart_schema import validate_request
✗ from quart_schema.decorators import validate_request
Exposed from top-level package; internal module path may break in future versions.
openapi_spec
✓ from quart_schema import openapi_spec
✗ from quart_schema.openapi import spec
The public symbol is `openapi_spec` at package root.

Minimal Quart app with request body validation using Pydantic model.

from quart import Quart, request, jsonify from quart_schema import QuartSchema, validate_request from pydantic import BaseModel app = Quart(__name__) QuartSchema(app) class Item(BaseModel): name: str price: float @app.route('/item', methods=['POST']) @validate_request(Item) async def create_item(): data = await request.get_json() # data is validated as Item return jsonify({"created": data.name}), 201 if __name__ == '__main__': app.run()
Debug
Known issues
breakingVersion 0.20.0 dropped support for Python 3.7 and 3.8. Requires Python >=3.10.
fix
Upgrade to Python 3.10+.
affects: >=0.20.0
deprecatedThe `QuartSchema` constructor parameter `convert_errors` is deprecated; use `error_handler` instead.
fix
Remove `convert_errors=True` and define a custom error handler via `app.error_handler` or pass `error_handler` to `QuartSchema`.
affects: >=0.18.0, <1.0
gotcha`@validate_request` expects a Pydantic model class, not an instance. Passing an instance will raise a `TypeError`.
fix
Decorate with `@validate_request(SomeModel)` not `@validate_request(SomeModel())`.
affects: all
gotchaThe `openapi_spec` blueprint must be registered manually if you want OpenAPI docs at a specific path. By default, it is mounted at `/openapi.json`.
fix
Use `app.register_blueprint(openapi_spec)` without arguments to get default path, or pass `url_prefix` to customize.
affects: >=0.14.0
Errors
Common errors & fixes
pydantic.errors.PydanticUserError: A custom validator cannot be used with `@validate_request` because the model is not instantiated.
Using Pydantic validators that rely on instance state (e.g., `@validator('field', pre=True)`) that expect the model to be instantiated. `@validate_request` only validates JSON payload without model instantiation.
fix
Use `@validate_request(SomeModel)` and rely on Pydantic field types; avoid `@validator` that expects instance. If needed, manually instantiate inside the handler.
AttributeError: module 'quart_schema' has no attribute 'QuartSchema'
Older version of quart-schema (<0.14.0) used a different class name or not installed at all.
fix
Upgrade to latest: `pip install --upgrade quart-schema`.
TypeError: 'DummyRequest' object is not subscriptable
Trying to access `request.json` or `request.args` directly inside a function decorated with `@validate_request` before calling `await request.get_json()`. The request body is already validated and available as the argument of the function, but raw access may cause issues.
fix
Remove manual `request.get_json()`; the validated model is passed as a function argument automatically.
quart.exceptions.BadRequest: 400 Bad Request: JSON decode error
Submitting empty body or invalid JSON. `@validate_request` requires a JSON body.
fix
Ensure the client sends a valid JSON payload.
Upgrade
Version history
0.23.0latest on PyPI · released Dec 2, 2025
Audit
Dependencies
quartrequiredRequired web framework
pydanticrequiredSchema definition and validation
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
2
Resources
quart-schema — pip install quart-schema · libregistry