Skip to content

Commit 447764e

Browse files
joseegarciaclaude
andcommitted
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>
1 parent 6b31a7d commit 447764e

6 files changed

Lines changed: 57 additions & 8 deletions

File tree

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.2</version>
88
<packaging>jar</packaging>
99

1010
<properties>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,10 @@ private static SchemaFieldObject processEnumField(
872872
throw new BadDefinedEnumException(name);
873873
}
874874
field.setEnumValues(enumValuesMap);
875+
// Enum fields bypass processObjectProperty's applyMetadata, so carry the schema's
876+
// description/example here too for consistent @Schema annotations.
877+
field.setDescription(ApiTool.getDescription(value));
878+
field.setExample(ApiTool.getExample(value));
875879
return field;
876880
}
877881

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ components:
5858
patternProperties:
5959
"^x-":
6060
type: string
61+
status:
62+
type: string
63+
description: Lifecycle status of the gadget
64+
enum:
65+
- ACTIVE
66+
- RETIRED
6167
nothing:
6268
type: "null"
6369
owner:

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

Lines changed: 41 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,28 @@
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+
}
1942
@JsonProperty(value ="payload")
2043
private MultipartFile payload;
2144
@JsonProperty(value ="nothing")
@@ -32,6 +55,7 @@ public class GadgetDTO {
3255
private String serial;
3356

3457
private GadgetDTO(GadgetDTOBuilder builder) {
58+
this.status = builder.status;
3559
this.payload = builder.payload;
3660
this.nothing = builder.nothing;
3761
this.id = builder.id;
@@ -49,6 +73,7 @@ public static GadgetDTO.GadgetDTOBuilder builder() {
4973
@JsonPOJOBuilder(buildMethodName = "build", withPrefix = "")
5074
public static class GadgetDTOBuilder {
5175

76+
private Status status;
5277
private MultipartFile payload;
5378
private Object nothing;
5479
private String id;
@@ -57,6 +82,11 @@ public static class GadgetDTOBuilder {
5782
private PersonDTO owner;
5883
private String serial;
5984

85+
public GadgetDTO.GadgetDTOBuilder status(Status status) {
86+
this.status = status;
87+
return this;
88+
}
89+
6090
public GadgetDTO.GadgetDTOBuilder payload(MultipartFile payload) {
6191
this.payload = payload;
6292
return this;
@@ -112,6 +142,14 @@ public GadgetDTO build() {
112142
}
113143
}
114144

145+
@Schema(name = "status", required = false, description = "Lifecycle status of the gadget")
146+
public Status getStatus() {
147+
return status;
148+
}
149+
public void setStatus(Status status) {
150+
this.status = status;
151+
}
152+
115153
@Schema(name = "payload", required = false)
116154
public MultipartFile getPayload() {
117155
return payload;
@@ -177,18 +215,19 @@ public boolean equals(Object o) {
177215
return false;
178216
}
179217
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);
218+
return Objects.equals(this.status, gadgetDTO.status) && 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);
181219
}
182220

183221
@Override
184222
public int hashCode() {
185-
return Objects.hash(payload, nothing, id, metadata, coords, owner, serial);
223+
return Objects.hash(status, payload, nothing, id, metadata, coords, owner, serial);
186224
}
187225

188226
@Override
189227
public String toString() {
190228
StringBuilder sb = new StringBuilder();
191229
sb.append("GadgetDTO{");
230+
sb.append(" status:").append(status).append(",");
192231
sb.append(" payload:").append(payload).append(",");
193232
sb.append(" nothing:").append(nothing).append(",");
194233
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.2'
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.2'
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.2'
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.2</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.2</version>
275275
</dependency>
276276
<dependency>
277277
<groupId>org.apache.maven</groupId>

0 commit comments

Comments
 (0)