Skip to content

Expose decorators (e.g. input, output, etc.) as methods of the application instance #187

@greyli

Description

@greyli

In the current implementation, the input, output, doc, and auth_required are standalone decorators, which makes it hard to config the internal behavior since it can't access the config object. I'm thinking of changing them to methods of APIFlask class:

from apiflask import APIFlask


app = APIFlask(__name__)

@app.get('/')
@app.input(PetInSchema)
@app.output(PetOutSchema)
def hello(data):
    return 'Hello'

With this change, we can easily implement:

  • More support for pagination
  • Skip all validation for input with a global configuration variable
  • Support external authentication libraries

The initial plan:

  • Add these mirror methods to APIFlask and APIBlueprint in 0.12.0
  • Add warning for old standalone decorators in 1.0
  • Remove the standalone decorators in 2.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions