Skip to content

Commit fa12fb0

Browse files
committed
Minor fixes
1 parent 66ebda3 commit fa12fb0

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
The Java wrapper generator has been completely rewritten and uses now OpenAPI definition of the Spotify Web API as source.
9+
The OpenAPI definition contains fixes and improvements from my [spotify-web-api](https://github.com/sonallux/spotify-web-api) repository.
10+
Therefore, some model class names have changed and many fixes are included.
11+
12+
- The library now also requires Java 17
13+
- Update to jackson `2.13.2`
14+
- Update to okhttp `4.9.3`
815

916
## [2.4.0]
1017
- Update to spotify-web-api-core `2021.10.17`

spotify-web-api-java/src/main/java/de/sonallux/spotify/api/authorization/AuthorizationRedirectResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static <T> AuthorizationRedirectResponse<T> error(String error) {
3737

3838
/**
3939
* Parses the authorization response from the callback url
40+
*
4041
* @param url the callback url
4142
* @return the authorization response
4243
* @throws IllegalArgumentException If {@code uri} is not a well-formed URI.
@@ -47,6 +48,7 @@ public static <T> AuthorizationRedirectResponse<T> parse(String url, Function<Ht
4748

4849
/**
4950
* Parses the authorization response from the callback url
51+
*
5052
* @param httpUrl the callback url
5153
* @return the authorization response
5254
* @throws IllegalArgumentException If {@code uri} is not a well-formed URI.
@@ -58,11 +60,9 @@ public static <T> AuthorizationRedirectResponse<T> parse(HttpUrl httpUrl, Functi
5860
var content = contentExtractor.apply(httpUrl);
5961
if (content != null) {
6062
return new AuthorizationRedirectResponse<>(state, content, null);
61-
}
62-
else if (TextUtil.hasText(error)) {
63+
} else if (TextUtil.hasText(error)) {
6364
return new AuthorizationRedirectResponse<>(state, null, error);
64-
}
65-
else {
65+
} else {
6666
return new AuthorizationRedirectResponse<>(state, null, "Invalid authorization redirect response uri");
6767
}
6868
}

spotify-web-api-java/src/main/java/de/sonallux/spotify/api/authorization/AuthorizationUrlBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import okhttp3.HttpUrl;
44

55
import java.util.Arrays;
6+
import java.util.stream.Collectors;
67

78
public class AuthorizationUrlBuilder {
89
protected final HttpUrl.Builder builder;
@@ -28,8 +29,7 @@ public AuthorizationUrlBuilder scopes(Scope... scopes) {
2829
}
2930
var scopeString = Arrays.stream(scopes)
3031
.map(Scope::getName)
31-
.reduce((scope1, scope2) -> scope1 + " " + scope2)
32-
.orElse("");
32+
.collect(Collectors.joining(" "));
3333

3434
builder.addQueryParameter("scope", scopeString);
3535
return this;

spotify-web-api-java/src/main/java/de/sonallux/spotify/api/authorization/authorization_code/AuthorizationCodeFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.sonallux.spotify.api.authorization.authorization_code;
22

3-
import de.sonallux.spotify.api.authorization.AuthorizationUrlBuilder;
43
import de.sonallux.spotify.api.authorization.AuthorizationRedirectResponse;
4+
import de.sonallux.spotify.api.authorization.AuthorizationUrlBuilder;
55
import de.sonallux.spotify.api.authorization.SpotifyAuthorizationException;
66
import de.sonallux.spotify.api.authorization.TokenStore;
77
import de.sonallux.spotify.api.util.TextUtil;

spotify-web-api-java/src/main/java/de/sonallux/spotify/api/authorization/authorization_code/AuthorizationCodePKCEFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.sonallux.spotify.api.authorization.authorization_code;
22

3-
import de.sonallux.spotify.api.authorization.AuthorizationUrlBuilder;
43
import de.sonallux.spotify.api.authorization.AuthorizationRedirectResponse;
4+
import de.sonallux.spotify.api.authorization.AuthorizationUrlBuilder;
55
import de.sonallux.spotify.api.authorization.SpotifyAuthorizationException;
66
import de.sonallux.spotify.api.authorization.TokenStore;
77
import de.sonallux.spotify.api.util.TextUtil;

spotify-web-api-java/src/test/java/de/sonallux/spotify/api/authorization/implicit_grant/ImplicitGrantFlowTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ void createAuthorizationUriTest() {
3737

3838
var urlWithStateAndScope = implicitGrantFlow.createAuthorizationUrl()
3939
.state("34fFs29kd10")
40-
.scopes(Scope.USER_LIBRARY_READ, Scope.USER_LIBRARY_MODIFY)
40+
.scopes(Scope.USER_LIBRARY_READ)
4141
.build();
4242
assertEquals("https://accounts.spotify.com/authorize?" +
4343
"client_id=1a2b3c4d5e6f7&" +
4444
"response_type=token&" +
4545
"redirect_uri=http%3A%2F%2Fexample.com%2Fcallback&" +
4646
"state=34fFs29kd10&" +
47-
"scope=user-library-read%20user-library-modify", urlWithStateAndScope.toString());
47+
"scope=user-library-read", urlWithStateAndScope.toString());
4848

4949
var urlWithDialog = implicitGrantFlow.createAuthorizationUrl()
5050
.showDialog(true)

0 commit comments

Comments
 (0)