Skip to content

Commit 4a845b5

Browse files
authored
[webclient] Annotate getValue with @JsonValue in enum Classes (#389)
Annotates the `getValue` method in generated `enum` classes with `@JsonValue`, when the `serializationLibrary` is set to `jackson` (_default_ for the `webclient`-library). This allows Jackson to serialize `enum` values using the `getValue` method. _MAY_ be a **BREAKING** change for `enum` classes where constant `value`s differ from their `name`.
1 parent 3ceb629 commit 4a845b5

File tree

337 files changed

+531
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+531
-337
lines changed

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ authors:
55
given-names: "Christopher"
66
orcid: "https://orcid.org/0009-0002-1005-3942"
77
title: "OpenAPI to Java Records Mustache Templates"
8-
version: 2.8.1
8+
version: 2.8.2
99
date-released: 2025-01-06
1010
url: "https://github.com/Chrimle/openapi-to-java-records-mustache-templates"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The mustache templates are best acquired by importing the project as a dependenc
3737
<dependency>
3838
<groupId>io.github.chrimle</groupId>
3939
<artifactId>openapi-to-java-records-mustache-templates</artifactId>
40-
<version>2.8.1</version>
40+
<version>2.8.2</version>
4141
</dependency>
4242
```
4343
It is **strongly recommended** to import the project as a dependency. It has officially been published to:

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The mustache templates are best acquired by importing the project as a dependenc
3232
<dependency>
3333
<groupId>io.github.chrimle</groupId>
3434
<artifactId>openapi-to-java-records-mustache-templates</artifactId>
35-
<version>2.8.1</version>
35+
<version>2.8.2</version>
3636
</dependency>
3737
```
3838
It is **strongly recommended** to import the project as a dependency. It has officially been published to:

mustache-templates/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.github.chrimle</groupId>
88
<artifactId>openapi-to-java-records-mustache-templates-parent</artifactId>
9-
<version>2.8.1</version>
9+
<version>2.8.2</version>
1010
</parent>
1111

1212
<artifactId>openapi-to-java-records-mustache-templates</artifactId>

mustache-templates/src/main/resources/templates/modelEnum.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
}}{{!
3030
}}{{#jackson}}import com.fasterxml.jackson.annotation.JsonCreator;
31+
import com.fasterxml.jackson.annotation.JsonValue;
3132

3233
{{/jackson}}{{!
3334
}}{{#gson}}import java.io.IOException;
@@ -62,6 +63,8 @@ import com.google.gson.JsonElement;
6263
*
6364
* @return the value of this enum.
6465
*/
66+
{{#jackson}} @JsonValue
67+
{{/jackson}}
6568
public {{{dataType}}} getValue() {
6669
return value;
6770
}

mustache-templates/src/main/resources/templates/pojo.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030

3131
}}{{!
3232
Imports needed for 'okhttp-gson'
33-
}}{{#jackson}}import com.fasterxml.jackson.annotation.JsonCreator;
33+
}}{{#jackson}}import com.fasterxml.jackson.annotation.JsonCreator;{{!
34+
}}{{#vars}}{{#isEnum}}{{#-first}}
35+
import com.fasterxml.jackson.annotation.JsonValue;{{/-first}}{{/isEnum}}{{/vars}}
3436

3537
{{/jackson}}{{!
3638
}}{{#gson}}{{!
@@ -106,6 +108,8 @@ import java.util.Set;
106108
*
107109
* @return the value of this enum.
108110
*/
111+
{{#jackson}} @JsonValue
112+
{{/jackson}}
109113
public {{{dataType}}} getValue() {
110114
return value;
111115
}

mustache-templates/target/classes/templates/generateBuilders.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
}}{{!
1717
Source: openapi-to-java-records-mustache-templates
18-
Version: 2.8.1
18+
Version: 2.8.2
1919
Type: Custom
2020
Dependencies:
2121
- none

mustache-templates/target/classes/templates/javadoc.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
}}{{!
1717
Source: openapi-to-java-records-mustache-templates
18-
Version: 2.8.1
18+
Version: 2.8.2
1919
Type: Custom
2020
Dependencies:
2121
- none

mustache-templates/target/classes/templates/licenseInfo.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
}}{{!
1717
Source: openapi-to-java-records-mustache-templates
18-
Version: 2.8.1
18+
Version: 2.8.2
1919
Type: Override
2020
Dependencies:
2121
- none
@@ -39,6 +39,6 @@
3939
* openapi-to-java-records-mustache-templates. For further information,
4040
* questions, requesting features or reporting issues, please visit:
4141
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
42-
* Generated with Version: 2.8.1
42+
* Generated with Version: 2.8.2
4343
*
4444
*/

mustache-templates/target/classes/templates/modelEnum.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
}}{{!
1717
Source: openapi-to-java-records-mustache-templates
18-
Version: 2.8.1
18+
Version: 2.8.2
1919
Type: Override
2020
Dependencies:
2121
- `additionalEnumTypeAnnotations.mustache` (Official)
@@ -28,6 +28,7 @@
2828
2929
}}{{!
3030
}}{{#jackson}}import com.fasterxml.jackson.annotation.JsonCreator;
31+
import com.fasterxml.jackson.annotation.JsonValue;
3132

3233
{{/jackson}}{{!
3334
}}{{#gson}}import java.io.IOException;
@@ -62,6 +63,8 @@ import com.google.gson.JsonElement;
6263
*
6364
* @return the value of this enum.
6465
*/
66+
{{#jackson}} @JsonValue
67+
{{/jackson}}
6568
public {{{dataType}}} getValue() {
6669
return value;
6770
}

0 commit comments

Comments
 (0)