Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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