Skip to content

πŸ’‘ Β» improve openapi error responsesΒ #37

@lucas-labs

Description

@lucas-labs

Instead of having to define something like:

@get(
    '/foo/{id}',
    responses={
        404: {  # or exc_response(404)
            'description': 'Execution not found',
            'model': ExceptionResponse,
            'content': {
                'application/json': {
                    'example': ExceptionResponse.example(404),
                },
            },
        },
        500: {...},
        ..
    },
)
def get_foo(self, id: str) -> list[OperationResponse]:
    ...

Accept a new argument throws or raises:

@get('/foo/{id}', raises=[404, 500, ...])
def get_foo(self, id: str) -> list[OperationResponse]:
    ...

We can then use the already existing exc_response function to generate the examples.

Note

The responses argument should be kept and then combined with raises|throws if provided

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions