stapi-pydantic Pydantic models for the Satellite Tasking API (STAPI) specification. [!NOTE] This repository intentionally has no input/output (IO) functionality. For making requests to a STAPI API, use pystapi-client.
pypi package. Binary
Latest version: 0.0.3 Released: 2025-04-25
pydantic-spark This library can convert a pydantic class to a spark schema or generate python code from a spark schema. Install bash pip install pydantic-spark Pydantic class to spark schema ```python import json from typing import Optional from pydantic_spark.base import SparkBase class TestModel(SparkBase): key1: str key2: int key2: Optional[str] schema_dict: dict = TestModel.spark_schema() print(json.dumps(schema_dict)) ``` Coerce type Pydantic-spark provides a coerce_type option that allows type coercion. When applied to a field, pydantic-spark converts the column's data type to the specified coercion type. ```python import json from pydantic import Field from pydantic_spark.base import SparkBase, CoerceType class TestModel(SparkBase): key1: str = Field(extra_json_schema={"coerce_type": CoerceType.integer}) schema_dict: dict = TestModel.spark_schema() print(json.dumps(schema_dict)) ``` Install for developers Install package Requirement: Poetry 1.* shell poetry install Run unit tests ```shell pytest coverage run -m pytest # with coverage or (depends on your local env) poetry run pytest poetry run coverage run -m pytest # with coverage ``` Run linting The linting is checked in the github workflow. To fix and review issues run this: shell black . # Auto fix all issues isort . # Auto fix all issues pflake . # Only display issues, fixing is manual
Latest version: 1.0.1 Released: 2023-11-24
Pydantic Typer Typer extension to enable pydantic support [!WARNING] This package is still in early development and some things might not work as expected, or change between versions. Table of Contents Installation Usage License Installation console pip install pydantic-typer [!NOTE] pydantic-typer comes with pydantic and typer as dependencies, so you don't need to install anything else. Usage For general typer usage, please refer to the typer documentation. All the code blocks below can be copied and used directly (they are tested Python files). To run any of the examples, copy the code to a file main.py, and run it: console python main.py Basic Usage :technologist: Simply use pydantic_typer.run instead of typer.run to enable pydantic support ```python from typing import Annotated import pydantic import typer import pydantic_typer class User(pydantic.BaseModel): id: Annotated[int, pydantic.Field(description="The id of the user.")] name: Annotated[str, pydantic.Field(description="The name of the user.")] = "Jane Doe" def main(num: int, user: User): typer.echo(f"{num} {type(num)}") typer.echo(f"{user} {type(user)}") if name == "main": pydantic_typer.run(main) ``` :t-rex: Non-Annotated Version ```python import pydantic import typer import pydantic_typer class User(pydantic.BaseModel): id: int = pydantic.Field(description="The id of the user.") name: str = pydantic.Field("Jane Doe", description="The name of the user.") def main(num: int, user: User): typer.echo(f"{num} {type(num)}") typer.echo(f"{user} {type(user)}") if name == "main": pydantic_typer.run(main) ``` :computer: Usage ```console $ # Run the basic example: $ python main.py Usage: main.py [OPTIONS] NUM Try 'main.py --help' for help. ╭─ Error ────────────────────────────────────────────────────────────╮ │ Missing argument 'NUM'. │ ╰────────────────────────────────────────────────────────────────────╯ $ # We're missing a required argument, try using --help as suggested: $ python main.py --help Usage: main.py [OPTIONS] NUM ╭─ Arguments ────────────────────────────────────────────────────────╮ │ * num INTEGER [default: None] [required] │ ╰────────────────────────────────────────────────────────────────────╯ ╭─ Options ──────────────────────────────────────────────────────────╮ │ * --user.id INTEGER The id of the user. [default: None] │ │ [required] │ │ --user.name TEXT The name of the user. │ │ [default: Jane Doe] │ │ --help Show this message and exit. │ ╰──────────────────────────────────────────────────────────────────── $ # Notice the help text for user.id and user.name are inferred from the pydantic.Field. $ # user.id is reqired, because we don't provide a default value for the field. $ # Now run the example with the required arguments: $ python main.py 1 --user.id 1 1 id=1 name='Jane Doe' $ # It worked! You can also experiment with an invalid user.id: $ python main.py 1 --user.id some-string Usage: example_001_basic.py [OPTIONS] NUM Try 'example_001_basic.py --help' for help. ╭─ Error ─────────────────────────────────────────────────────────────╮ │ Invalid value for '--user.id': 'some-string' is not a valid integer.│ ╰─────────────────────────────────────────────────────────────────────╯ ``` Usage with nested models :technologist: pydantic_typer.run also works with nested pydantic models ```python from future import annotations from typing import Optional import pydantic import typer import pydantic_typer class Pet(pydantic.BaseModel): name: str species: str class Person(pydantic.BaseModel): name: str age: Optional[float] = None # noqa: UP007 For Python versions >=3.10, prefer float | None pet: Pet def main(person: Person): typer.echo(f"{person} {type(person)}") if name == "main": pydantic_typer.run(main) ``` :computer: Usage console $ # Run the nested models example with the required options: $ python main.py --person.name "Patrick" --person.pet.name "Snoopy" --person.pet.species "Dog" name='Patrick' age=None pet=Pet(name='Snoopy', species='Dog') Use pydantic models with typer.Argument :technologist: You can annotate the parameters with typer.Argument to make all model fields CLI arguments ```python from future import annotations import pydantic import typer from typing_extensions import Annotated import pydantic_typer class User(pydantic.BaseModel): id: int name: str def main(num: Annotated[int, typer.Option()], user: Annotated[User, typer.Argument()]): typer.echo(f"{num} {type(num)}") typer.echo(f"{user} {type(user)}") if name == "main": pydantic_typer.run(main) ``` :computer: Usage ```console $ # Run the example $ python main.py Usage: main.py [OPTIONS] _PYDANTIC_USER_ID _PYDANTIC_USER_NAME Try 'main.py --help' for help. ╭─ Error ─────────────────────────────────────────────────────────────╮ │ Missing argument '_PYDANTIC_USER_ID'. │ ╰─────────────────────────────────────────────────────────────────────╯ $ #Notice how _PYDANTIC_USER_ID and _PYDANTIC_USER_NAME are now cli arguments instead of options. $ # Supply the arguments in the right order: python main.py 1 Patrick --num 1 1 id=1 name='Patrick' ``` :bulb: You can also override annotations directly on the pydantic model fields: ```python from future import annotations import pydantic import typer from typing_extensions import Annotated import pydantic_typer class User(pydantic.BaseModel): id: Annotated[int, typer.Argument(metavar="THE_ID")] name: Annotated[str, typer.Option()] def main(num: Annotated[int, typer.Option()], user: Annotated[User, typer.Argument()]): typer.echo(f"{num} {type(num)}") typer.echo(f"{user} {type(user)}") if name == "main": pydantic_typer.run(main) ``` Here, User is a typer.Argument, but we manually override the fields again: We override the metavar of to User.id be THE_ID And User.name to be a typer.Option Use pydantic models in multiple commands :technologist: For larger typer apps, you can use pydantic_typer.Typer instead of annotating each command function individually to enable pydantic models on all commands ```python from future import annotations import pydantic import typer from typing_extensions import Annotated from pydantic_typer import Typer app = Typer() class User(pydantic.BaseModel): id: int name: Annotated[str, typer.Option()] = "John" @app.command() def hi(user: User): typer.echo(f"Hi {user}") @app.command() def bye(user: User): typer.echo(f"Bye {user}") if name == "main": app() ``` Use pydantic types :technologist: You can also annotate arguments with pydantic types and they will be validated ```python import click import typer from pydantic import HttpUrl, conint import pydantic_typer EvenInt = conint(multiple_of=2) def main(num: EvenInt, url: HttpUrl, ctx: click.Context): # type: ignore typer.echo(f"{num} {type(num)}") typer.echo(f"{url} {type(url)}") if name == "main": pydantic_typer.run(main) ``` :technologist: Pydantic types also work in lists and tuples ```python from typing import List import typer from pydantic import AnyHttpUrl import pydantic_typer def main(urls: List[AnyHttpUrl] = typer.Option([], "--url")): typer.echo(f"urls: {urls}") if name == "main": pydantic_typer.run(main) ``` Use Union types :technologist: Thanks to pydantic.TypeAdapter, which we use internally, we also support Union types ```python import typer import pydantic_typer def main(value: bool | int | float | str = 1): typer.echo(f"{value} {type(value)}") if name == "main": pydantic_typer.run(main) ``` :computer: Usage ```console $ # Run the example using a boolean $ python main.py --value True True $ # Run the example using an integer $ python main.py --value 2 2 $ # Run the example using a float $ python main.py --value 2.1 2.1 $ # Run the example using a string $ python main.py --value "Hello World" Hello World $ # Before, we intentionally used 2, when testing the integer $ # Check what happens if you pass 1 $ python main.py --value 1 True $ # We get back a boolean! $ # This is because Unions are generally evaluated left to right. $ # So in this case bool > int > float > str, if parsing is successful. $ # There are some exceptions, where pydantic tries to be smart, see here for details: $ # https://docs.pydantic.dev/latest/concepts/unions/#smart-mode ``` Limitations [!WARNING] pydantic-typer does not yet support sequences of pydantic models: See this issue for details [!WARNING] pydantic-typer does not yet support self-referential pydantic models. [!WARNING] pydantic-typer does not yet support lists with complex sub-types, in particular unions such as list[str|int]. License pydantic-typer is distributed under the terms of the MIT license.
Latest version: 0.0.13 Released: 2024-11-14
pydantic-kedro Advanced serialization for Pydantic models via Kedro and fsspec. This package implements custom Kedro "datasets" for both "pure" and "arbitrary" Pydantic models. You can also use it stand-alone, using Kedro just for serializing other object types. Please see the documentation for a tutorial and more examples. Usage with Kedro You can use the [PydanticAutoDataset][pydantic_kedro.PydanticAutoDataset] or any other dataset from pydantic-kedro within your Kedro catalog to save your Pydantic models: ```yaml conf/base/catalog.yml my_pydantic_model: type: pydantic_kedro.PydanticAutoDataset filepath: folder/my_model ``` Direct Dataset Usage This example works for "pure", JSON-safe Pydantic models via PydanticJsonDataset: ```python from pydantic import BaseModel from pydantic.v1 import BaseModel # Pydantic V2 from pydantic_kedro import PydanticJsonDataset class MyPureModel(BaseModel): """Your custom Pydantic model with JSON-safe fields.""" x: int y: str obj = MyPureModel(x=1, y="why?") Create an in-memory (temporary) file via fsspec and save it ds = PydanticJsonDataset("memory://temporary-file.json") ds.save(obj) We can re-load it from the same file read_obj = ds.load() assert read_obj.x == 1 ``` Standalone Usage You can also use pydantic-kedro as a generic saving and loading engine for Pydantic models: ```python from tempfile import TemporaryDirectory from pydantic.v1 import BaseModel from pydantic_kedro import load_model, save_model class MyModel(BaseModel): """My custom model.""" name: str We can use any fsspec URL, so we'll make a temporary folder with TemporaryDirectory() as tmpdir: save_model(MyModel(name="foo"), f"{tmpdir}/my_model") obj = load_model(f"{tmpdir}/my_model") assert obj.name == "foo" ```
Latest version: 0.8.0 Released: 2024-04-01
Pydantic Mongo A Python library that offers an easy-to-use Repository pattern for MongoDB, supporting both synchronous and asynchronous operations. It simplifies working with databases by providing a clear interface for CRUD (Create, Read, Update, Delete) operations using Pydantic models. With built-in data validation and serialization from Pydantic, it helps manage your MongoDB data safely. Read the documentation Features Asynchronous and Synchronous support Pydantic models integration Type-safe MongoDB operations Cursor-based pagination Installation bash pip install pydantic-mongo Usage Examples Defining Models and Repository ```python from bson import ObjectId from pydantic import BaseModel from pydantic_mongo import AbstractRepository, PydanticObjectId from pymongo import MongoClient from typing import Optional, List Define your models class Foo(BaseModel): count: int size: float = None class Bar(BaseModel): apple: str = 'x' banana: str = 'y' class Spam(BaseModel): # PydanticObjectId is an alias to Annotated[ObjectId, ObjectIdAnnotation] id: Optional[PydanticObjectId] = None foo: Foo bars: List[Bar] Create a repository class SpamRepository(AbstractRepository[Spam]): class Meta: collection_name = 'spams' Connect to database client = MongoClient("mongodb://localhost:27017") database = client["example"] repo = SpamRepository(database) ``` Creating and Saving Documents ```python Create a new document spam = Spam(foo=Foo(count=1, size=1.0), bars=[Bar()]) Create a document with predefined ID spam_with_predefined_id = Spam( id=ObjectId("611827f2878b88b49ebb69fc"), foo=Foo(count=2, size=2.0), bars=[Bar()] ) Save a single document repo.save(spam) # spam.id is now set to an ObjectId Save multiple documents repo.save_many([spam, spam_with_predefined_id]) ``` Querying Documents ```python Find by ID result = repo.find_one_by_id(spam.id) Find by ID using string result = repo.find_one_by_id(ObjectId('611827f2878b88b49ebb69fc')) assert result.foo.count == 2 Find one by custom query result = repo.find_one_by({'foo.count': 1}) Find multiple documents by query results = repo.find_by({'foo.count': {'$gte': 1}}) ``` Pagination ```python Get first page edges = repo.paginate({'foo.count': {'$gte': 1}}, limit=10) Get next page using the last cursor more_edges = repo.paginate( {'foo.count': {'$gte': 1}}, limit=10, after=list(edges)[-1].cursor ) ``` Deleting Documents ```python Delete a document repo.delete(spam) Delete by ID repo.delete_by_id(ObjectId("...")) ``` Async Support For asynchronous applications, you can use AsyncAbstractRepository which provides the same functionality as AbstractRepository but with async/await support: ```python from pymongo import AsyncMongoClient from pydantic import BaseModel from pydantic_mongo import AsyncAbstractRepository class User(BaseModel): id: str name: str email: str class UserRepository(AsyncAbstractRepository[User]): class Meta: collection_name = 'users' Initialize database connection client = AsyncMongoClient('mongodb://localhost:27017') database = client["mydb"] Create repository instance user_repo = UserRepository(database) Example usage user = User(name='John Doe', email='john@example.com') await user_repo.save(user) user = await user_repo.find_one_by_id(user_id) ``` License MIT License
Latest version: 3.1.0 Released: 2025-04-18
Flask-Pydantic Flask extension for integration of the awesome pydantic package with Flask. Pallets Community Ecosystem [!IMPORTANT]\ This project is part of the Pallets Community Ecosystem. Pallets is the open source organization that maintains Flask; Pallets-Eco enables community maintenance of Flask extensions. If you are interested in helping maintain this project, please reach out on the Pallets Discord server. Installation python3 -m pip install Flask-Pydantic Basics URL query and body parameters validate decorator validates query, body and form-data request parameters and makes them accessible two ways: Using validate arguments, via flask's request variable | parameter type | request attribute name | |:------------------:|:----------------------------:| | query | query_params | | body | body_params | | form | form_params | Using the decorated function argument parameters type hints URL path parameter If you use annotated path URL path parameters as follows ```python @app.route("/users/", methods=["GET"]) @validate() def get_user(user_id: str): pass `` flask_pydantic will parse and validateuser_id` variable in the same manner as for body and query parameters. Additional validate arguments Success response status code can be modified via on_success_status parameter of validate decorator. response_many parameter set to True enables serialization of multiple models (route function should therefore return iterable of models). request_body_many parameter set to False analogically enables serialization of multiple models inside of the root level of request body. If the request body doesn't contain an array of objects 400 response is returned, get_json_params - parameters to be passed to flask.Request.get_json function If validation fails, 400 response is returned with failure explanation. For more details see in-code docstring or example app. Usage Example 1: Query parameters only Simply use validate decorator on route function. :exclamation: Be aware that @app.route decorator must precede @validate (i. e. @validate must be closer to the function declaration). ```python from typing import Optional from flask import Flask, request from pydantic import BaseModel from flask_pydantic import validate app = Flask("flask_pydantic_app") class QueryModel(BaseModel): age: int class ResponseModel(BaseModel): id: int age: int name: str nickname: Optional[str] = None Example 1: query parameters only @app.route("/", methods=["GET"]) @validate() def get(query: QueryModel): age = query.age return ResponseModel( age=age, id=0, name="abc", nickname="123" ) ``` See the full example app here age query parameter is a required int curl --location --request GET 'http://127.0.0.1:5000/' if none is provided the response contains: json { "validation_error": { "query_params": [ { "loc": ["age"], "msg": "field required", "type": "value_error.missing" } ] } } for incompatible type (e. g. string /?age=not_a_number) curl --location --request GET 'http://127.0.0.1:5000/?age=abc' json { "validation_error": { "query_params": [ { "loc": ["age"], "msg": "value is not a valid integer", "type": "type_error.integer" } ] } } likewise for body parameters example call with valid parameters: curl --location --request GET 'http://127.0.0.1:5000/?age=20' -> {"id": 0, "age": 20, "name": "abc", "nickname": "123"} Example 2: URL path parameter python @app.route("/character//", methods=["GET"]) @validate() def get_character(character_id: int): characters = [ ResponseModel(id=1, age=95, name="Geralt", nickname="White Wolf"), ResponseModel(id=2, age=45, name="Triss Merigold", nickname="sorceress"), ResponseModel(id=3, age=42, name="Julian Alfred Pankratz", nickname="Jaskier"), ResponseModel(id=4, age=101, name="Yennefer", nickname="Yenn"), ] try: return characters[character_id] except IndexError: return {"error": "Not found"}, 400 Example 3: Request body only ```python class RequestBodyModel(BaseModel): name: str nickname: Optional[str] = None Example2: request body only @app.route("/", methods=["POST"]) @validate() def post(body: RequestBodyModel): name = body.name nickname = body.nickname return ResponseModel( name=name, nickname=nickname,id=0, age=1000 ) ``` See the full example app here Example 4: BOTH query paramaters and request body ```python Example 3: both query paramters and request body @app.route("/both", methods=["POST"]) @validate() def get_and_post(body: RequestBodyModel, query: QueryModel): name = body.name # From request body nickname = body.nickname # From request body age = query.age # from query parameters return ResponseModel( age=age, name=name, nickname=nickname, id=0 ) ``` See the full example app here Example 5: Request form-data only ```python class RequestFormDataModel(BaseModel): name: str nickname: Optional[str] = None Example2: request body only @app.route("/", methods=["POST"]) @validate() def post(form: RequestFormDataModel): name = form.name nickname = form.nickname return ResponseModel( name=name, nickname=nickname,id=0, age=1000 ) ``` See the full example app here Modify response status code The default success status code is 200. It can be modified in two ways in return statement ```python necessary imports, app and models definition ... @app.route("/", methods=["POST"]) @validate(body=BodyModel, query=QueryModel) def post(): return ResponseModel( id=id_, age=request.query_params.age, name=request.body_params.name, nickname=request.body_params.nickname, ), 201 ``` in validate decorator python @app.route("/", methods=["POST"]) @validate(body=BodyModel, query=QueryModel, on_success_status=201) def post(): ... Status code in case of validation error can be modified using FLASK_PYDANTIC_VALIDATION_ERROR_STATUS_CODE flask configuration variable. Using the decorated function kwargs Instead of passing body and query to validate, it is possible to directly defined them by using type hinting in the decorated function. ```python necessary imports, app and models definition ... @app.route("/", methods=["POST"]) @validate() def post(body: BodyModel, query: QueryModel): return ResponseModel( id=id_, age=query.age, name=body.name, nickname=body.nickname, ) ``` This way, the parsed data will be directly available in body and query. Furthermore, your IDE will be able to correctly type them. Model aliases Pydantic's alias feature is natively supported for query and body models. To use aliases in response modify response model ```python def modify_key(text: str) -> str: # do whatever you want with model keys return text class MyModel(BaseModel): ... model_config = ConfigDict( alias_generator=modify_key, populate_by_name=True ) ``` and set response_by_alias=True in validate decorator python @app.route(...) @validate(response_by_alias=True) def my_route(): ... return MyModel(...) Example app For more complete examples see example application. Configuration The behaviour can be configured using flask's application config FLASK_PYDANTIC_VALIDATION_ERROR_STATUS_CODE - response status code after validation error (defaults to 400) Additionally, you can set FLASK_PYDANTIC_VALIDATION_ERROR_RAISE to True to cause flask_pydantic.ValidationError to be raised with either body_params, form_params, path_params, or query_params set as a list of error dictionaries. You can use flask.Flask.register_error_handler to catch that exception and fully customize the output response for a validation error. Contributing Feature requests and pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. clone repository bash git clone https://github.com/pallets-eco/flask_pydantic.git cd flask_pydantic create virtual environment and activate it bash python3 -m venv venv source venv/bin/activate install development requirements bash python3 -m pip install -r requirements/test.txt checkout new branch and make your desired changes (don't forget to update tests) bash git checkout -b make sure your code style is compliant with Ruff. Your can check these errors and automatically correct some of them with ruff check --select I --fix . run tests and check code format bash python3 -m pytest --ruff --ruff-format push your changes and create a pull request to master branch TODOs: header request parameters cookie request parameters
Latest version: 0.13.1 Released: 2025-04-23
OSCAL Pydantic Description A simple module that contains pydantic datamodels representing the OSCAL standard. They are built from the OSCAL models published by NIST at https://github.com/usnistgov/OSCAL Several Python projects include data models, but importing a large project just to get access to the datamodel represents a significant overhead. This module simply provides the models. Installation pip install oscal-pydantic Usage To import a specific model, include it in your python file: e.g.: from oscal_pydantic import catalog Alternatively, you can import the complete OSCAL schema: from oscal_pydantic import complete After importing, you should be able to define OSCAL objects that support pydantic's rich validation rules. License This code is released under the [CC0 1.0 Universal Public Domain Dedication] (https://creativecommons.org/publicdomain/zero/1.0/).
Latest version: 2023.3.21 Released: 2023-03-21
Pydantic forms A Python package that lets you add smart forms to FastAPI and Flask. Forms will respond with a JSON scheme that contains all info needed in a React frontend with uniforms to render the forms and handle all validation tasks. Forms can also consist out of a wizard, so you can create complex form flows consisting out of multiple consecutive forms. The forms and the validation logic are defined by using Pydantic models. Documentation regarding the usage of Forms can be found here Installation (Development standalone) Install the project and its dependencies to develop on the code. Step 1 - install flit: shell python3 -m venv venv source venv/bin/activate pip install flit Step 2 - install the development code: shell flit install --deps develop --symlink --python venv/bin/python !!! danger Make sure to use the flit binary that is installed in your environment. You can check the correct path by running shell which flit To be sure that the packages will be installed against the correct venv you can also prepend the python interpreter that you want to use: shell flit install --deps develop --symlink --python venv/bin/python Running tests Run the unit-test suite to verify a correct setup. Step 2 - Run tests shell pytest tests/unit_tests or with xdist: shell pytest -n auto tests/unit_tests If you do not encounter any failures in the test, you should be able to develop features in the pydantic-forms. Installation (Development symlinked into project that use pydantic-forms) If you are working on a project that already uses the pydantic-forms and you want to test your new form features against it, you can use some flit magic to symlink the dev version of the forms to your project. It will automatically replace the pypi dep with a symlink to the development version of the core and update/downgrade all required packages in your own project. Step 1 - install flit: shell python - m venv venv source venv/bin/activate pip install flit Step 2 - symlink pydantic-forms to your own project shell flit install --deps develop --symlink --python /path/to/a/project/venv/bin/python Increasing the version number for a (pre) release. When your PR is accepted you will get a version number. You can do the necessary change with a clean, e.g. every change committed, branch: shell bumpversion patch --new-version 0.0.1 Note: specifying it like this, instead of relying on bumpversion itself to increase the version, allows you to set a "RC1" version if needed. Debugging Form behaviour If you want/need the traceback of pydantic in a Form response you can add an env variable: LOG_LEVEL_PYDANTIC_FORMS=DEBUG This will add the traceback to the JSONResponse. If the loglevel is set to DEBUG the library will also add the traceback to the logger.
Latest version: 2.0.0 Released: 2025-04-09
Sanic Pyndatic Description A library for parsing and validating http requests for sanic web-framework using pydantic library Full documentation here Requirements python >= 3.7 How to install bash pip install sanic-pydantic Dependencies pydantic Example ```python from sanic_pydantic import webargs from sanic import Sanic from sanic.response import json from pydantic import BaseModel app = Sanic("new app") class PathModel(BaseModel): id: int class QueryModel(BaseModel): name: str class BodyModel(BaseModel): age: int class HeadersModel(BaseModel): api_key: str = Field(alias="x-api-key") @app.route("/get/", methods=["GET"]) @webargs(path=PathModel, headers=HeadersModel) def example_get_endpoint_params(request, id, **kwargs): response = json({"id":id}) return response @app.route("/get-request", methods=["GET"]) @webargs(query=QueryModel) def example_get_endpoint(request, **kwargs): print(kwargs) response = json(kwargs) return response @app.route("/post-request", methods=["POST"]) @webargs(query=QueryModel, body=BodyModel) def example_post_endpoint(request, **kwargs): print(kwargs) response = json(kwargs) return response @app.route("/async-get-request", methods=["GET"]) @webargs(query=QueryModel) async def async_example_get_endpoint(request, **kwargs): print(kwargs) response = json(kwargs) return response @app.route("/async-post-request", methods=["POST"]) @webargs(query=QueryModel, body=BodyModel) async def async_example_post_endpoint(request, **kwargs): print(kwargs) response = json(kwargs) return response if name == "main": app.run(host="0.0.0.0", port=8000) ```
Latest version: 1.3.1 Released: 2022-05-12