Skip to content

Commit 33e6570

Browse files
authored
fix: add support for generating 64bit integers (#262)
1 parent fdadea6 commit 33e6570

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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+
- Fix generation for 64bit integers [#262](https://github.com/sonallux/spotify-web-api-java/pull/262)
89

910
## [4.1.0]
1011
- Introduce `ArtistDiscographyAlbum` as response for get Artist's Albums request

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ public static Optional<String> getPrimitiveTypeOfSchema(Schema<?> schema) {
5454
if ("boolean".equals(schema.getType())) {
5555
return Optional.of("boolean");
5656
} else if ("integer".equals(schema.getType())) {
57+
if ("int64".equals(schema.getFormat())) {
58+
return Optional.of("long");
59+
}
60+
// if no format is present, use 32bit integer, for compatability reasons
5761
return Optional.of("int");
5862
} else if ("number".equals(schema.getType())) {
63+
if ("double".equals(schema.getFormat())) {
64+
return Optional.of("double");
65+
}
66+
// if no format is present, use single precision floating point number, for compatability reasons
5967
return Optional.of("float");
6068
} else {
6169
return getTypeOfSchema(schema);
@@ -73,12 +81,20 @@ public static Optional<String> getTypeOfSchema(Schema<?> schema) {
7381
return Optional.of("String");
7482
}
7583
if ("integer".equals(schema.getType())) {
84+
if ("int64".equals(schema.getFormat())) {
85+
return Optional.of("Long");
86+
}
87+
// if no format is present, use 32bit integer, for compatability reasons
7688
return Optional.of("Integer");
7789
}
7890
if ("boolean".equals(schema.getType())) {
7991
return Optional.of("Boolean");
8092
}
8193
if ("number".equals(schema.getType())) {
94+
if ("double".equals(schema.getFormat())) {
95+
return Optional.of("Double");
96+
}
97+
// if no format is present, use single precision floating point number, for compatability reasons
8298
return Optional.of("Float");
8399
}
84100
if (schema instanceof ArraySchema arraySchema) {

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/models/AudioAnalysisMeta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ public class AudioAnalysisMeta {
3636
/**
3737
* <p>The Unix timestamp (in seconds) at which this track was analyzed.</p>
3838
*/
39-
public int timestamp;
39+
public long timestamp;
4040
}

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/models/CurrentlyPlaying.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ public class CurrentlyPlaying {
3636
/**
3737
* <p>Unix Millisecond Timestamp when data was fetched</p>
3838
*/
39-
public int timestamp;
39+
public long timestamp;
4040
}

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/models/CurrentlyPlayingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ public class CurrentlyPlayingContext {
4848
/**
4949
* <p>Unix Millisecond Timestamp when data was fetched.</p>
5050
*/
51-
public int timestamp;
51+
public long timestamp;
5252
}

0 commit comments

Comments
 (0)