uplink icon indicating copy to clipboard operation
uplink copied to clipboard

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

Open torchss opened this issue 4 months ago • 0 comments

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

torchss avatar Aug 03 '25 22:08 torchss