Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Schema validation support for Pydantic and Marshmellow #489

Closed
wants to merge 2 commits into from

Conversation

tabotkevin
Copy link
Collaborator

@tabotkevin tabotkevin commented Nov 15, 2023

check examples/schema_input_validation.py

"""Decorator for parsing and validating input schema.
Supports both Pydantic and Marshmallow.

Usage::
import time

from pydantic import BaseModel
import responder

class Item(BaseModel)
    name: str

api = responder.API()

@api.route("/create")
@api.trust(Item)
def create_item(req, resp, *, data):
    @api.background.task
    def process_item(item):
        time.sleep(2)
        print(item)   # e.g {"name": "Monster Hunter"}

    process_item(data)
    resp.media = {"msg": "created"}

"""

@tabotkevin tabotkevin closed this Nov 15, 2023
@tabotkevin tabotkevin deleted the schema_input_validation branch November 19, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant