Skip to content

Commit 655e2c1

Browse files
committed
generator-java: make position parameter optional in endpoint add tracks to playlist
1 parent 8b79e0b commit 655e2c1

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

spotify-web-api-generator-java/src/main/java/de/sonallux/spotify/generator/java/EndpointHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public static void fixDuplicateEndpointParameters(SpotifyWebApiEndpoint endpoint
3131
endpoint.getParameters().removeIf(p -> p.getLocation() == QUERY && paramName.equals(p.getName()));
3232
for (var param : endpoint.getParameters()) {
3333
if (param.getLocation() == BODY && paramName.equals(param.getName())) {
34-
param.setRequired(true);
34+
if (!("endpoint-add-tracks-to-playlist".equals(endpoint.getId()) && "position".equals(param.getName()))) {
35+
param.setRequired(true);
36+
}
3537
} else if (param.getLocation() == HEADER && "Content-Type".equals(param.getName())) {
3638
param.setRequired(true);
3739
}

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/PlaylistsApi.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ public class PlaylistsApi {
1616
* <p>Add one or more items to a user's playlist.</p>
1717
* @param playlistId <p>The <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify ID</a> for the playlist.</p>
1818
* @param uris <p>A JSON array of the <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify URIs</a> to add. For example: <code>{&quot;uris&quot;: [&quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot;,&quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot;, &quot;spotify:episode:512ojhOuo1ktJprKbVcKyQ&quot;]}</code><br>A maximum of 100 items can be added in one request. <em>Note: if the <code>uris</code> parameter is present in the query string, any URIs listed here in the body will be ignored.</em></p>
19-
* @param position <p>The position to insert the items, a zero-based index. For example, to insert the items in the first position: <code>position=0</code> ; to insert the items in the third position: <code>position=2</code>. If omitted, the items will be appended to the playlist. Items are added in the order they appear in the uris array. For example: <code>{&quot;uris&quot;: [&quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot;,&quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot;], &quot;position&quot;: 3}</code></p>
2019
* @return a {@link AddTracksToPlaylistRequest} object to build and execute the request
2120
*/
22-
public AddTracksToPlaylistRequest addTracksToPlaylist(String playlistId, java.util.List<String> uris, int position) {
23-
return new AddTracksToPlaylistRequest(apiClient, playlistId, uris, position);
21+
public AddTracksToPlaylistRequest addTracksToPlaylist(String playlistId, java.util.List<String> uris) {
22+
return new AddTracksToPlaylistRequest(apiClient, playlistId, uris);
2423
}
2524

2625
/**

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/playlists/AddTracksToPlaylistRequest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,23 @@ public class AddTracksToPlaylistRequest {
2525
* @param apiClient <p>The API client</p>
2626
* @param playlistId <p>The <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify ID</a> for the playlist.</p>
2727
* @param uris <p>A JSON array of the <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify URIs</a> to add. For example: <code>{&quot;uris&quot;: [&quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot;,&quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot;, &quot;spotify:episode:512ojhOuo1ktJprKbVcKyQ&quot;]}</code><br>A maximum of 100 items can be added in one request. <em>Note: if the <code>uris</code> parameter is present in the query string, any URIs listed here in the body will be ignored.</em></p>
28-
* @param position <p>The position to insert the items, a zero-based index. For example, to insert the items in the first position: <code>position=0</code> ; to insert the items in the third position: <code>position=2</code>. If omitted, the items will be appended to the playlist. Items are added in the order they appear in the uris array. For example: <code>{&quot;uris&quot;: [&quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot;,&quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot;], &quot;position&quot;: 3}</code></p>
2928
*/
30-
public AddTracksToPlaylistRequest(ApiClient apiClient, String playlistId, java.util.List<String> uris, int position) {
29+
public AddTracksToPlaylistRequest(ApiClient apiClient, String playlistId, java.util.List<String> uris) {
3130
this.apiClient = apiClient;
3231
this.request = new Request("POST", "/playlists/{playlist_id}/tracks")
3332
.addPathParameter("playlist_id", String.valueOf(playlistId))
3433
.addBodyParameter("uris", uris)
35-
.addBodyParameter("position", position)
3634
;
3735
}
3836

37+
/**
38+
* <p>The position to insert the items, a zero-based index. For example, to insert the items in the first position: <code>position=0</code> ; to insert the items in the third position: <code>position=2</code>. If omitted, the items will be appended to the playlist. Items are added in the order they appear in the uris array. For example: <code>{&quot;uris&quot;: [&quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot;,&quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot;], &quot;position&quot;: 3}</code></p>
39+
*/
40+
public AddTracksToPlaylistRequest position(int position) {
41+
this.request.addBodyParameter("position", position);
42+
return this;
43+
}
44+
3945
/**
4046
* Build the request into an executable call
4147
*/

0 commit comments

Comments
 (0)