Skip to content

Is it possible to add a response header to the openapi spec that is generated? #686

@jceresini

Description

@jceresini

Description

How can I [...]?
Add a response header to the openapi spec that is generated.

Additional context
I was hoping to use the response headers for pagination, something similar to the following:

@api.get('/things')
def list_things(response: Response, params: dict = Depends(pagination_params)):

    things_resp = get_things(**params)
    if things_resp.next_page_token:
        response.headers['next_page_token'] = things_resp.next_page_token

    return things_resp.things

But I'd like to inform users of my API that they may see a next_page_token header in the response by way of the OpenAPI spec. I read through a bunch of the documentation but didn't see a solution for this use case

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions