Skip to content

Support passing APISpec object to spec processor#412

Merged
greyli merged 1 commit intomainfrom
spec-obj
Mar 18, 2023
Merged

Support passing APISpec object to spec processor#412
greyli merged 1 commit intomainfrom
spec-obj

Conversation

@greyli
Copy link
Copy Markdown
Member

@greyli greyli commented Mar 12, 2023

Add a SPEC_PROCESSOR_PASS_OBJECT to control the argument type of the spec processor. Example usage:

from apiflask import APIFlask

app = APIFlask(__name__)
app.config['SPEC_PROCESSOR_PASS_OBJECT'] = True

class FooSchema(Schema):
    id = Integer()

@app.spec_processor
def update_spec(spec):
    spec.title = 'Updated Title'
    spec.components.schema('Foo', schema=FooSchema)  # add a schema manually
    return spec

fixes #213

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code docstring.
  • Add an entry in CHANGES.md summarizing the change and linking to the issue.
  • Add *Version changed* or *Version added* note in any relevant docs and docstring.
  • Run pytest and tox, no tests failed.

@greyli greyli added this to the 1.3.0 milestone Mar 12, 2023
Add a `SPEC_PROCESSOR_PASS_OBJECT` to control the argument type of the spec processor.
@greyli
Copy link
Copy Markdown
Member Author

greyli commented Mar 12, 2023

Maybe we can find a better name than SPEC_PROCESSOR_PASS_OBJECT.

@stutao Any ideas?

@greyli greyli merged commit 97779d0 into main Mar 18, 2023
@greyli greyli deleted the spec-obj branch March 18, 2023 07:53
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.

Support to add schemas to the OpenAPI spec explicitly

1 participant