Skip to content

Is it possible to also obtain the HTTP status code when using @uplink.returns.json? #343

@torchss

Description

@torchss

For a bad or invalid ep_id, the server can return various errors which are a combination of the HTTP status code and a message: str if that status code allows it.

Is there a way I could add a HTTP status code to my Error class? How would that look like?

class APIError(BaseModel):
    message: str

class FooClient(uplink.Consumer):

    @uplink.returns.json
    @uplink.get("ep/{ep_id}")
    def get_ep_by_id(self, ep_id: uplink.Path) -> EP | APIError:
        pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions