{"id":21846,"library":"quart-schema","title":"Quart-Schema","description":"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.","status":"active","version":"0.23.0","language":"python","source_language":"en","source_url":"https://github.com/pgjones/quart-schema","tags":["quart","schema","validation","pydantic","openapi"],"install":[{"cmd":"pip install quart-schema","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required web framework","package":"quart","optional":false},{"reason":"Schema definition and validation","package":"pydantic","optional":false}],"imports":[{"note":"Aliasing not needed, but acceptable. Common mistake: importing from wrong package (e.g., 'quart_schema' vs 'quart_schema.core')","wrong":"from quart_schema import QuartSchema as QS","symbol":"QuartSchema","correct":"from quart_schema import QuartSchema"},{"note":"Exposed from top-level package; internal module path may break in future versions.","wrong":"from quart_schema.decorators import validate_request","symbol":"validate_request","correct":"from quart_schema import validate_request"},{"note":"The public symbol is `openapi_spec` at package root.","wrong":"from quart_schema.openapi import spec","symbol":"openapi_spec","correct":"from quart_schema import openapi_spec"}],"quickstart":{"code":"from quart import Quart, request, jsonify\nfrom quart_schema import QuartSchema, validate_request\nfrom pydantic import BaseModel\n\napp = Quart(__name__)\nQuartSchema(app)\n\nclass Item(BaseModel):\n    name: str\n    price: float\n\n@app.route('/item', methods=['POST'])\n@validate_request(Item)\nasync def create_item():\n    data = await request.get_json()\n    # data is validated as Item\n    return jsonify({\"created\": data.name}), 201\n\nif __name__ == '__main__':\n    app.run()","lang":"python","description":"Minimal Quart app with request body validation using Pydantic model."},"warnings":[{"fix":"Upgrade to Python 3.10+.","message":"Version 0.20.0 dropped support for Python 3.7 and 3.8. Requires Python >=3.10.","severity":"breaking","affected_versions":">=0.20.0"},{"fix":"Remove `convert_errors=True` and define a custom error handler via `app.error_handler` or pass `error_handler` to `QuartSchema`.","message":"The `QuartSchema` constructor parameter `convert_errors` is deprecated; use `error_handler` instead.","severity":"deprecated","affected_versions":">=0.18.0, <1.0"},{"fix":"Decorate with `@validate_request(SomeModel)` not `@validate_request(SomeModel())`.","message":"`@validate_request` expects a Pydantic model class, not an instance. Passing an instance will raise a `TypeError`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `app.register_blueprint(openapi_spec)` without arguments to get default path, or pass `url_prefix` to customize.","message":"The `openapi_spec` blueprint must be registered manually if you want OpenAPI docs at a specific path. By default, it is mounted at `/openapi.json`.","severity":"gotcha","affected_versions":">=0.14.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `@validate_request(SomeModel)` and rely on Pydantic field types; avoid `@validator` that expects instance. If needed, manually instantiate inside the handler.","cause":"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.","error":"pydantic.errors.PydanticUserError: A custom validator cannot be used with `@validate_request` because the model is not instantiated."},{"fix":"Upgrade to latest: `pip install --upgrade quart-schema`.","cause":"Older version of quart-schema (<0.14.0) used a different class name or not installed at all.","error":"AttributeError: module 'quart_schema' has no attribute 'QuartSchema'"},{"fix":"Remove manual `request.get_json()`; the validated model is passed as a function argument automatically.","cause":"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.","error":"TypeError: 'DummyRequest' object is not subscriptable"},{"fix":"Ensure the client sends a valid JSON payload.","cause":"Submitting empty body or invalid JSON. `@validate_request` requires a JSON body.","error":"quart.exceptions.BadRequest: 400 Bad Request: JSON decode error"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}