-
-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The support that was added for customizable responses in the doc decorator in #327 did not modify the typing or documentation on the decorator, so those are both now slightly inaccurate.
A toy example:
from apiflask import APIBlueprint, Schema, fields
class FooSchema(Schema):
foo = fields.String(required=True)
app_endpoints = APIBlueprint("foo", __name__, tag={"name": "Foo", "description": "Foo endpoints"})
_foo_storage: list[str] = []
@app_endpoints.post("/foo")
@app_endpoints.input(FooSchema)
@app_endpoints.output(FooSchema, description="Existing foo")
@app_endpoints.doc(
responses={201: {"description": "Created foo", "content": {"application/json": {"schema": FooSchema}}}}
)
def post_foo(json_data: dict):
foo_value = query_foo(json_data["foo"])
if foo_value:
return {"foo": foo_value}, 200
else:
foo_value = create_foo(json_data["foo"])
return {"foo": foo_value}, 201
def query_foo(foo: str) -> str | None:
if foo in _foo_storage:
return foo
return None
def create_foo(foo: str) -> str:
_foo_storage.append(foo)
return foo
My IDE gives the following warning on the doc decorator usage:
Expected type 'list[int] | dict[int, str] | None', got 'dict[int, dict[str, str | dict[str, dict[str, Type[FooSchema]]]]]' instead
Environment:
- Python version: 3.11
- Flask version: 2.2.5
- APIFlask version: 2.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working