Skip to content

Commit d6a2cff

Browse files
joseegman-idoneeajoseegarciaclaude
authored
Release 6.5.3: Gradle JDK 21 fix + OpenAPI 3.1 refinements (enum metadata, deprecated) (#384)
* CI: build Gradle release job with JDK 21 The gradle-portal-push workflow set up JDK 17 and then ran `mvn install` on multiapi-engine, which compiles with `release 21` — failing with "release version 21 not supported". Bump the job to JDK 21, matching the Maven workflows (which already build against 21). The engine and the Gradle plugin both require Java 21. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Propagate description/example to enum fields; bump 6.5.2 Enum fields bypassed processObjectProperty's applyMetadata, so their schema `description`/`example` were dropped from the generated @Schema annotation. Set them in processEnumField so enum properties match the rest. Bumps version 6.5.1 -> 6.5.2. Full multiapi-engine suite: 110/110 (mvn clean test). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Support schema `deprecated` on generated models; bump 6.5.3 OpenAPI 3.x / JSON Schema `deprecated: true` on a property (or enum) is now carried into the generated model as @Schema(deprecated = true); previously it was ignored. Applied at the same property/enum metadata points as description/example. Bumps version 6.5.2 -> 6.5.3. Full multiapi-engine suite: 110/110 (mvn clean test). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: joseegarcia <jose.garcia@disashop.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4261296 commit d6a2cff

10 files changed

Lines changed: 93 additions & 12 deletions

File tree

.github/workflows/gradle-portal-push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
with:
5151
ref: ${{ github.head_ref }}
5252

53-
- name: Set up JDK 17
53+
- name: Set up JDK 21
5454
uses: actions/setup-java@v2
5555
with:
56-
java-version: "17"
56+
java-version: "21"
5757
distribution: "adopt"
5858
server-id: ossrh
5959
server-username: MAVEN_USERNAME

multiapi-engine/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.sngular</groupId>
66
<artifactId>multiapi-engine</artifactId>
7-
<version>6.5.1</version>
7+
<version>6.5.3</version>
88
<packaging>jar</packaging>
99

1010
<properties>

multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/model/SchemaFieldObject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ public class SchemaFieldObject {
3232
private String description;
3333

3434
private String example;
35+
36+
private boolean deprecated;
3537
}

multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ApiTool.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ public static String getDescription(final JsonNode schema) {
484484
return getNodeAsString(schema, "description");
485485
}
486486

487+
public static boolean isDeprecated(final JsonNode schema) {
488+
return getNodeAsBoolean(schema, "deprecated");
489+
}
490+
487491
public static String getExample(final JsonNode schema) {
488492
// OpenAPI 3.0 uses a single `example`; OpenAPI 3.1 / JSON Schema 2020-12 use an
489493
// `examples` array. Prefer `example`, otherwise take the first `examples` entry.

multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ModelBuilder.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ private static List<SchemaFieldObject> processObjectProperty(
346346
private static void applyMetadata(final List<SchemaFieldObject> fields, final String fieldName, final JsonNode fieldBody) {
347347
final String description = ApiTool.getDescription(fieldBody);
348348
final String example = ApiTool.getExample(fieldBody);
349-
if (Objects.isNull(description) && Objects.isNull(example)) {
349+
final boolean deprecated = ApiTool.isDeprecated(fieldBody);
350+
if (Objects.isNull(description) && Objects.isNull(example) && !deprecated) {
350351
return;
351352
}
352353
for (final var field : fields) {
@@ -357,6 +358,9 @@ private static void applyMetadata(final List<SchemaFieldObject> fields, final St
357358
if (Objects.nonNull(example)) {
358359
field.setExample(example);
359360
}
361+
if (deprecated) {
362+
field.setDeprecated(true);
363+
}
360364
}
361365
}
362366
}
@@ -872,6 +876,11 @@ private static SchemaFieldObject processEnumField(
872876
throw new BadDefinedEnumException(name);
873877
}
874878
field.setEnumValues(enumValuesMap);
879+
// Enum fields bypass processObjectProperty's applyMetadata, so carry the schema's
880+
// description/example/deprecated here too for consistent @Schema annotations.
881+
field.setDescription(ApiTool.getDescription(value));
882+
field.setExample(ApiTool.getExample(value));
883+
field.setDeprecated(ApiTool.isDeprecated(value));
875884
return field;
876885
}
877886

multiapi-engine/src/main/resources/templates/model/templateSchema.ftlh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public class ${schema.className} {
340340
}
341341

342342
<#list schema.fieldObjectList as field>
343-
@Schema(name = "${field.baseName?uncap_first}", required = <#if field.required?has_content && field.required == true>true<#else>false</#if><#if field.description?has_content>, description = "${field.description?j_string}"</#if><#if field.example?has_content>, example = "${field.example?j_string}"</#if>)
343+
@Schema(name = "${field.baseName?uncap_first}", required = <#if field.required?has_content && field.required == true>true<#else>false</#if><#if field.description?has_content>, description = "${field.description?j_string}"</#if><#if field.example?has_content>, example = "${field.example?j_string}"</#if><#if field.deprecated>, deprecated = true</#if>)
344344
<#if field.dataType.baseType == "array">
345345
public ${field.dataType} get${field.baseName?cap_first}() {
346346
return ${calculateSafeName (field.baseName, ";")}

multiapi-engine/src/test/resources/openapigenerator/testOpenApi31Completeness/api-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ components:
4242
description: The unique gadget identifier
4343
examples:
4444
- "gadget-001"
45+
legacyId:
46+
type: string
47+
deprecated: true
4548
serial:
4649
type: ["string", "null"]
4750
example: "SN-12345"
@@ -58,6 +61,12 @@ components:
5861
patternProperties:
5962
"^x-":
6063
type: string
64+
status:
65+
type: string
66+
description: Lifecycle status of the gadget
67+
enum:
68+
- ACTIVE
69+
- RETIRED
6170
nothing:
6271
type: "null"
6372
owner:

multiapi-engine/src/test/resources/openapigenerator/testOpenApi31Completeness/assets/GadgetDTO.java

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
66
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
77
import com.fasterxml.jackson.annotation.JsonProperty;
8+
import com.fasterxml.jackson.annotation.JsonValue;
89
import io.swagger.v3.oas.annotations.media.Schema;
910
import org.springframework.web.multipart.MultipartFile;
1011
import java.util.List;
@@ -16,6 +17,30 @@
1617
@JsonDeserialize(builder = GadgetDTO.GadgetDTOBuilder.class)
1718
public class GadgetDTO {
1819

20+
@JsonProperty(value ="status")
21+
private Status status;
22+
public enum Status {
23+
ACTIVE("ACTIVE"),
24+
RETIRED("RETIRED");
25+
26+
private String value;
27+
28+
Status(String value) {
29+
this.value = value;
30+
}
31+
32+
@JsonValue
33+
public String getValue() {
34+
return value;
35+
}
36+
37+
@Override
38+
public String toString() {
39+
return String.valueOf(value);
40+
}
41+
}
42+
@JsonProperty(value ="legacyId")
43+
private String legacyId;
1944
@JsonProperty(value ="payload")
2045
private MultipartFile payload;
2146
@JsonProperty(value ="nothing")
@@ -32,6 +57,8 @@ public class GadgetDTO {
3257
private String serial;
3358

3459
private GadgetDTO(GadgetDTOBuilder builder) {
60+
this.status = builder.status;
61+
this.legacyId = builder.legacyId;
3562
this.payload = builder.payload;
3663
this.nothing = builder.nothing;
3764
this.id = builder.id;
@@ -49,6 +76,8 @@ public static GadgetDTO.GadgetDTOBuilder builder() {
4976
@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "")
5077
public static class GadgetDTOBuilder {
5178

79+
private Status status;
80+
private String legacyId;
5281
private MultipartFile payload;
5382
private Object nothing;
5483
private String id;
@@ -57,6 +86,16 @@ public static class GadgetDTOBuilder {
5786
private PersonDTO owner;
5887
private String serial;
5988

89+
public GadgetDTO.GadgetDTOBuilder status(Status status) {
90+
this.status = status;
91+
return this;
92+
}
93+
94+
public GadgetDTO.GadgetDTOBuilder legacyId(String legacyId) {
95+
this.legacyId = legacyId;
96+
return this;
97+
}
98+
6099
public GadgetDTO.GadgetDTOBuilder payload(MultipartFile payload) {
61100
this.payload = payload;
62101
return this;
@@ -112,6 +151,22 @@ public GadgetDTO build() {
112151
}
113152
}
114153

154+
@Schema(name = "status", required = false, description = "Lifecycle status of the gadget")
155+
public Status getStatus() {
156+
return status;
157+
}
158+
public void setStatus(Status status) {
159+
this.status = status;
160+
}
161+
162+
@Schema(name = "legacyId", required = false, deprecated = true)
163+
public String getLegacyId() {
164+
return legacyId;
165+
}
166+
public void setLegacyId(String legacyId) {
167+
this.legacyId = legacyId;
168+
}
169+
115170
@Schema(name = "payload", required = false)
116171
public MultipartFile getPayload() {
117172
return payload;
@@ -177,18 +232,20 @@ public boolean equals(Object o) {
177232
return false;
178233
}
179234
GadgetDTO gadgetDTO = (GadgetDTO) o;
180-
return Objects.equals(this.payload, gadgetDTO.payload) && Objects.equals(this.nothing, gadgetDTO.nothing) && Objects.equals(this.id, gadgetDTO.id) && Objects.equals(this.metadata, gadgetDTO.metadata) && Objects.equals(this.coords, gadgetDTO.coords) && Objects.equals(this.owner, gadgetDTO.owner) && Objects.equals(this.serial, gadgetDTO.serial);
235+
return Objects.equals(this.status, gadgetDTO.status) && Objects.equals(this.legacyId, gadgetDTO.legacyId) && Objects.equals(this.payload, gadgetDTO.payload) && Objects.equals(this.nothing, gadgetDTO.nothing) && Objects.equals(this.id, gadgetDTO.id) && Objects.equals(this.metadata, gadgetDTO.metadata) && Objects.equals(this.coords, gadgetDTO.coords) && Objects.equals(this.owner, gadgetDTO.owner) && Objects.equals(this.serial, gadgetDTO.serial);
181236
}
182237

183238
@Override
184239
public int hashCode() {
185-
return Objects.hash(payload, nothing, id, metadata, coords, owner, serial);
240+
return Objects.hash(status, legacyId, payload, nothing, id, metadata, coords, owner, serial);
186241
}
187242

188243
@Override
189244
public String toString() {
190245
StringBuilder sb = new StringBuilder();
191246
sb.append("GadgetDTO{");
247+
sb.append(" status:").append(status).append(",");
248+
sb.append(" legacyId:").append(legacyId).append(",");
192249
sb.append(" payload:").append(payload).append(",");
193250
sb.append(" nothing:").append(nothing).append(",");
194251
sb.append(" id:").append(id).append(",");

scs-multiapi-gradle-plugin/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repositories {
2121
}
2222

2323
group = 'com.sngular'
24-
version = '6.5.1'
24+
version = '6.5.3'
2525

2626
def SCSMultiApiPluginGroupId = group
2727
def SCSMultiApiPluginVersion = version
@@ -31,7 +31,7 @@ dependencies {
3131
shadow localGroovy()
3232
shadow gradleApi()
3333

34-
implementation 'com.sngular:multiapi-engine:6.5.1'
34+
implementation 'com.sngular:multiapi-engine:6.5.3'
3535
testImplementation 'org.assertj:assertj-core:3.24.2'
3636
testImplementation 'com.puppycrawl.tools:checkstyle:10.12.3'
3737
testImplementation 'org.junit.platform:junit-platform-launcher:1.9.2'
@@ -100,7 +100,7 @@ testing {
100100

101101
integrationTest(JvmTestSuite) {
102102
dependencies {
103-
implementation 'com.sngular:scs-multiapi-gradle-plugin:6.5.1'
103+
implementation 'com.sngular:scs-multiapi-gradle-plugin:6.5.3'
104104
implementation 'org.assertj:assertj-core:3.24.2'
105105
}
106106

scs-multiapi-maven-plugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.sngular</groupId>
66
<artifactId>scs-multiapi-maven-plugin</artifactId>
7-
<version>6.5.1</version>
7+
<version>6.5.3</version>
88
<packaging>maven-plugin</packaging>
99

1010
<name>AsyncApi - OpenApi Code Generator Maven Plugin</name>
@@ -271,7 +271,7 @@
271271
<dependency>
272272
<groupId>com.sngular</groupId>
273273
<artifactId>multiapi-engine</artifactId>
274-
<version>6.5.1</version>
274+
<version>6.5.3</version>
275275
</dependency>
276276
<dependency>
277277
<groupId>org.apache.maven</groupId>

0 commit comments

Comments
 (0)