Skip to content

Add flag to allow disabling of validation on input #573

@edufresne

Description

@edufresne

Suggestion

There has been use cases where validation is not always wanted for input but having the input schema in the docs is. It would be nice if there was a way to optionally disable validation for a given input schema and just have APIFlask pass the unaltered JSON to the endpoint while still keeping the input documented in the schema.

Something like:

@some_blueprint.post("/foos/bulk")
@some_blueprint.input(SomeSchema, validate=False)
def create_foos(json_data: dict):
   ...

or

@some_blueprint.post("/foos/bulk")
@some_blueprint.doc(input=SomeSchema)
def create_foos(json_data: dict):
   ...

This solves the problem as a lot of the times, bulk endpoints for things like bulk create, bulk edit can do a "best effort" processing. ie. Create/edit all valid entries and ignore invalid entries. Endpoints like POST /foos/bulk or PUT /foos/bulk.

I can't seem to find a way of doing it with subclassing or some other method of overriding.

I'm more than happy to help and contribute with an MR if this feature is deemed useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions