You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm interested in using Uplink for building a REST API client, and would like to use pydantic to define the request/response payloads.
I looked at the doc and found the following example for handling request payloads:
from uplink import Consumer, Body
class CreateRepo(BaseModel):
name: str
delete_branch_on_merge: bool
class GitHub(Consumer):
@post("user/repos")
def create_repo(self, repo: Body(type=CreateRepo)):
"""Creates a new repository for the authenticated user."""
which would then require using:
github.create_repo(repo)
I would really like to be able to (also) offer this way however:
whilst still having IDE auto-completion, type hinting, etc.
Is that something that could be done "automatically" somehow? (without having to create 2 versions of each method, and duplicating information on type hints, etc.; and whilst ensuring that pydantic validation can still take place)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm interested in using Uplink for building a REST API client, and would like to use pydantic to define the request/response payloads.
I looked at the doc and found the following example for handling request payloads:
which would then require using:
I would really like to be able to (also) offer this way however:
whilst still having IDE auto-completion, type hinting, etc.
Is that something that could be done "automatically" somehow? (without having to create 2 versions of each method, and duplicating information on type hints, etc.; and whilst ensuring that pydantic validation can still take place)
Beta Was this translation helpful? Give feedback.
All reactions