-
Notifications
You must be signed in to change notification settings - Fork 7
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
Java generator: Union type handling #37
Comments
sonallux
added a commit
that referenced
this issue
Mar 14, 2021
sonallux
added a commit
that referenced
this issue
Mar 15, 2021
sonallux
added a commit
that referenced
this issue
Mar 15, 2021
sonallux
added a commit
that referenced
this issue
Mar 20, 2021
sonallux
added a commit
that referenced
this issue
Mar 20, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the addition of Episodes and Shows, the Spotify Web API does use union types (for example can Playlists can contain Episodes and/or Tracks). As Java does not natively support unions, any union type is currently mapped to
Map<String, Object>
, which is not a nice UX.Once shared super types are added (see #7) the handling of union types in the Java wrapper can be greatly improved.
For example the
getPlaylistTrack()
method can then be typed with a shared super type:The user can then inspect the
type
property of theSpotifyObject
and cast to eitherTrack
orEpisode
. This would require a custom Jackson deserializer that inspects thetype
property and then creates an instance of the concreteSpotifyObject
class (e.g.Artist
,Album
,Track
,Playlist
,Show
,Episode
).The text was updated successfully, but these errors were encountered: