Skip to content

Commit 59057b0

Browse files
committed
Remove description field from ResponseType as it is always null
1 parent a3696ee commit 59057b0

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

spotify-web-api-core/src/main/java/de/sonallux/spotify/core/EndpointSplitter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void splitUsersTopArtistsAndTracksEndpoint(SpotifyWebApi apiDocume
4949
responseDescriptionArtists,
5050
topArtistsAndTracks.getScopes(),
5151
topArtistsAndTracks.getNotes(),
52-
List.of(new SpotifyWebApiEndpoint.ResponseType("PagingObject[ArtistObject]", 200, null))
52+
List.of(new SpotifyWebApiEndpoint.ResponseType("PagingObject[ArtistObject]", 200))
5353
);
5454
var topTracks = new SpotifyWebApiEndpoint(
5555
"endpoint-get-users-top-tracks",
@@ -62,7 +62,7 @@ public static void splitUsersTopArtistsAndTracksEndpoint(SpotifyWebApi apiDocume
6262
responseDescriptionTracks,
6363
topArtistsAndTracks.getScopes(),
6464
topArtistsAndTracks.getNotes(),
65-
List.of(new SpotifyWebApiEndpoint.ResponseType("PagingObject[TrackObject]", 200, null))
65+
List.of(new SpotifyWebApiEndpoint.ResponseType("PagingObject[TrackObject]", 200))
6666
);
6767

6868
category.getEndpoints().remove(topArtistsAndTracks.getId());
@@ -113,7 +113,7 @@ public static void splitReorderOrReplacePlaylistsTracksEndpoint(SpotifyWebApi ap
113113
reorderResponseDescription + "\n\n" + errorResponseDescription,
114114
endpoint.getScopes(),
115115
endpoint.getNotes(),
116-
List.of(new SpotifyWebApiEndpoint.ResponseType("SnapshotIdObject", 200, null))
116+
List.of(new SpotifyWebApiEndpoint.ResponseType("SnapshotIdObject", 200))
117117
);
118118

119119
reorderEndpoint.getParameters().stream().filter(p -> "range_start".equals(p.getName())).findFirst().get().setRequired(true);
@@ -130,7 +130,7 @@ public static void splitReorderOrReplacePlaylistsTracksEndpoint(SpotifyWebApi ap
130130
replaceResponseDescription + "\n\n" + errorResponseDescription,
131131
endpoint.getScopes(),
132132
endpoint.getNotes(),
133-
List.of(new SpotifyWebApiEndpoint.ResponseType("SnapshotIdObject", 201, null))
133+
List.of(new SpotifyWebApiEndpoint.ResponseType("SnapshotIdObject", 201))
134134
);
135135

136136
category.getEndpoints().remove(endpoint.getId());

spotify-web-api-core/src/main/java/de/sonallux/spotify/core/model/SpotifyWebApiEndpoint.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,5 @@ public static class ResponseType {
6666
@NonNull
6767
private String type;
6868
private int status;
69-
private String description;
7069
}
7170
}

spotify-web-api-generator-open-api/src/main/java/de/sonallux/spotify/generator/openapi/OpenApiGenerator.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ private Operation generateOperation(SpotifyWebApiEndpoint endpoint) {
116116
for (var responseType : endpoint.getResponseTypes()) {
117117
var response = getApiResponse(responseType);
118118
if (response != null) {
119-
if (response.getDescription() == null || response.getDescription().isEmpty()) {
120-
response.description(endpoint.getResponseDescription());
121-
}
119+
response.description(endpoint.getResponseDescription());
122120
apiResponses.put(String.valueOf(responseType.getStatus()), response);
123121
}
124122
}
@@ -136,16 +134,16 @@ private Operation generateOperation(SpotifyWebApiEndpoint endpoint) {
136134
}
137135

138136
private ApiResponse getApiResponse(SpotifyWebApiEndpoint.ResponseType responseType) {
139-
var response = new ApiResponse().description(responseType.getDescription());
140137
if ("Void".equals(responseType.getType())) {
141-
return response;
138+
return new ApiResponse();
142139
}
143140

144141
var responseSchema = getSchema(responseType.getType(), openAPI.getComponents().getSchemas());
145142
if (responseSchema == null) {
146143
return null;
147144
}
148-
return response.content(new Content().addMediaType(MEDIA_TYPE_JSON, new MediaType().schema(responseSchema)));
145+
var content = new Content().addMediaType(MEDIA_TYPE_JSON, new MediaType().schema(responseSchema));
146+
return new ApiResponse().content(content);
149147
}
150148

151149
private io.swagger.v3.oas.models.parameters.Parameter generateParameter(SpotifyWebApiEndpoint.Parameter param) {

spotify-web-api-parser/src/main/java/de/sonallux/spotify/parser/ResponseTypeMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void update(List<SpotifyWebApiCategory> categories) {
9494
}
9595
System.out.print("Response status (default: 200): ");
9696
int newStatus = readInt(scanner, 200);
97-
endpointResponse.getResponseTypes().add(new SpotifyWebApiEndpoint.ResponseType(newType, newStatus, null));
97+
endpointResponse.getResponseTypes().add(new SpotifyWebApiEndpoint.ResponseType(newType, newStatus));
9898
}
9999
i++;
100100
} while (true);

0 commit comments

Comments
 (0)