Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror the API responses in the returned values #277

Open
jooola opened this issue Aug 7, 2023 · 1 comment
Open

Mirror the API responses in the returned values #277

jooola opened this issue Aug 7, 2023 · 1 comment
Labels
enhancement New feature or request pinned

Comments

@jooola
Copy link
Member

jooola commented Aug 7, 2023

Feature Request

Is your feature request related to a problem? Please describe.

When returning data from an API call, we usually unwrap the single field that might be returned by the API. Sometimes we return a Response wrapper including the different fields returned by the API.

This makes our API a bit inconsistent, and not future-proof: if a new field is added to the response, we usually have to implement a new method to return the new desired fields inside a wrapper class.

#181 is an example where we have to implement some dirty work around to provide the missing field.

Describe the solution you'd like

Make the return object consistent with the API response, and ensure we wrap all the returned fields in an object where it makes sense.

If the API returns:

{
  "action": {}
}

we return a class with an action field:

class MyResponse:
    action: Action

Adding a new field should be easy

{
  "action": {}
  "root_password": "1234567890"
}
class MyResponse:
    action: Action
    root_password: str | None

Teachability, Documentation, Adoption, Migration Strategy

I wonder how this can be solved without asking too much effort to users, as this would be a decent amount of work.

Maybe using the trick with the return_response argument in #276 can solve this ?

@jooola jooola changed the title Mirror the API responses in the returned objects Mirror the API responses in the returned values Aug 7, 2023
@jooola jooola added this to the v2.0.0 milestone Aug 7, 2023
@jooola jooola added the enhancement New feature or request label Aug 7, 2023
Copy link

github-actions bot commented Nov 6, 2023

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the Stale label Nov 6, 2023
@jooola jooola added pinned and removed Stale labels Nov 6, 2023
@jooola jooola removed this from the v2.0.0 milestone Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

1 participant