-
Notifications
You must be signed in to change notification settings - Fork 959
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
Convert all Spotify response objects to Pydantic models #975
Comments
This idea is nice, but I can see how creating (and maintaining) such schemas could be a little bit tedious. However, the only thing I found were these. The repository seems archived though, does anyone know if there are any fresher ones? |
Problem here is the dynamic structure response that changes over time according to the Spotify API changelog. You need to adapt manually every schema and mantains the latest versions with updated schema. This identifies a notable effort spent to contributors. Unfortunately, Spotify didn't update response schema very well and it's a bit tedious mantains a good schema without occurs in some issues. |
Even though pydantic and similar approaches probably won't be implemented in spotipy, I just want to leave this OpenAPI specification here: https://developer.spotify.com/reference/web-api/open-api-schema.yaml Found in this community post: https://community.spotify.com/t5/Spotify-for-Developers/OpenApi-Swagger-description-for-the-Web-API/m-p/5329753#messageview_1 |
yep, @dieser-niko is right. If that can be of help for @MrinalJain17 or anyone in the future one option is converting that openapi schema to pydantic classes (pydantic docs, datamodel-code-generator). So ideally, you could have a thin layer to convert spotipy's responses to Pydantic objects. IMO this remains overkill to implement and remain in sync, but just in case someone needs it :) |
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
All the responses can be represented as Pydantic models. https://docs.pydantic.dev/latest/
Describe alternatives you've considered
I've used Pydantic before, so biased towards the tool. There might be other options, but the core feature request stays the same -- well-structured and validated python objects in favour of raw JSON responses.
Additional context
This can be thought of as a more rigorous version of #695.
The text was updated successfully, but these errors were encountered: