Skip to content

Commit 45dc531

Browse files
Merge branch 'master' into feature/jackson3-native
2 parents 8091162 + cbdee19 commit 45dc531

417 files changed

Lines changed: 1079 additions & 810 deletions

File tree

Some content is hidden

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

.github/workflows/samples-spring-jdk17.yaml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ name: Samples Java Spring (JDK17)
33
on:
44
push:
55
paths:
6-
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
7-
- samples/openapi3/client/petstore/spring-cloud-4-with-optional
8-
- samples/client/petstore/spring-http-interface-springboot-4
9-
- samples/openapi3/server/petstore/springboot-3
10-
- samples/openapi3/server/petstore/springboot-4
11-
- samples/server/petstore/springboot-api-response-examples
12-
- samples/server/petstore/springboot-lombok-data
13-
- samples/server/petstore/springboot-lombok-tostring
14-
- samples/server/petstore/springboot-file-delegate-optional
15-
- samples/server/petstore/springboot-petstore-with-api-response-examples
16-
- samples/server/petstore/spring-boot-oneof-sealed
17-
- samples/openapi3/server/petstore/spring-boot-oneof-interface
6+
- samples/openapi3/client/petstore/spring-cloud-3-with-optional/**
7+
- samples/openapi3/client/petstore/spring-cloud-4-with-optional/**
8+
- samples/client/petstore/spring-http-interface-springboot-4/**
9+
- samples/openapi3/server/petstore/springboot-3/**
10+
- samples/openapi3/server/petstore/springboot-4/**
11+
- samples/server/petstore/springboot-api-response-examples/**
12+
- samples/server/petstore/springboot-lombok-data/**
13+
- samples/server/petstore/springboot-lombok-tostring/**
14+
- samples/server/petstore/springboot-file-delegate-optional/**
15+
- samples/server/petstore/springboot-petstore-with-api-response-examples/**
16+
- samples/openapi3/server/petstore/spring-boot-oneof-sealed/**
17+
- samples/openapi3/server/petstore/spring-boot-oneof-interface/**
1818
pull_request:
1919
paths:
20-
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
21-
- samples/openapi3/client/petstore/spring-cloud-4-with-optional
22-
- samples/client/petstore/spring-http-interface-springboot-4
23-
- samples/openapi3/server/petstore/springboot-3
24-
- samples/openapi3/server/petstore/springboot-4
25-
- samples/server/petstore/springboot-api-response-examples
26-
- samples/server/petstore/springboot-lombok-data
27-
- samples/server/petstore/springboot-lombok-tostring
28-
- samples/server/petstore/springboot-file-delegate-optional
29-
- samples/server/petstore/springboot-petstore-with-api-response-examples
30-
- samples/server/petstore/spring-boot-oneof-sealed
31-
- samples/openapi3/server/petstore/spring-boot-oneof-interface
20+
- samples/openapi3/client/petstore/spring-cloud-3-with-optional/**
21+
- samples/openapi3/client/petstore/spring-cloud-4-with-optional/**
22+
- samples/client/petstore/spring-http-interface-springboot-4/**
23+
- samples/openapi3/server/petstore/springboot-3/**
24+
- samples/openapi3/server/petstore/springboot-4/**
25+
- samples/server/petstore/springboot-api-response-examples/**
26+
- samples/server/petstore/springboot-lombok-data/**
27+
- samples/server/petstore/springboot-lombok-tostring/**
28+
- samples/server/petstore/springboot-file-delegate-optional/**
29+
- samples/server/petstore/springboot-petstore-with-api-response-examples/**
30+
- samples/openapi3/server/petstore/spring-boot-oneof-sealed/**
31+
- samples/openapi3/server/petstore/spring-boot-oneof-interface/**
3232
jobs:
3333
build:
3434
name: Build Java Spring (JDK17)
@@ -49,7 +49,7 @@ jobs:
4949
- samples/server/petstore/springboot-lombok-tostring
5050
- samples/server/petstore/springboot-file-delegate-optional
5151
- samples/server/petstore/springboot-petstore-with-api-response-examples
52-
- samples/server/petstore/spring-boot-oneof-sealed
52+
- samples/openapi3/server/petstore/spring-boot-oneof-sealed
5353
- samples/openapi3/server/petstore/spring-boot-oneof-interface
5454
steps:
5555
- uses: actions/checkout@v5

bin/configs/spring-boot-x-implements-skip.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ outputDir: samples/server/petstore/springboot-x-implements-skip
33
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-x-implements.yaml
44
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
55
additionalProperties:
6+
additionalNotNullAnnotations: true
67
documentationProvider: springfox
78
artifactId: springboot
89
snapshotVersion: "true"
@@ -12,4 +13,4 @@ additionalProperties:
1213
xImplementsSkip: [ com.custompackage.InterfaceToSkip ]
1314
schemaImplements:
1415
Foo: [ com.custompackage.WithBar, com.custompackage.WithDefaultMethod ]
15-
Animal: com.custompackage.WithColor
16+
Animal: com.custompackage.WithColor

docs/generators/java-camel.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2020
| ------ | ----------- | ------ | ------- |
2121
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
2222
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
23+
|additionalNotNullAnnotations|Add @NotNull to path variables (required by default) and requestBody.| |false|
2324
|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
2425
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
2526
|annotationLibrary|Select the complementary documentation annotation library.|<dl><dt>**none**</dt><dd>Do not annotate Model and Api with complementary annotations.</dd><dt>**swagger1**</dt><dd>Annotate Model and Api using the Swagger Annotations 1.x library.</dd><dt>**swagger2**</dt><dd>Annotate Model and Api using the Swagger Annotations 2.x library.</dd></dl>|swagger2|

docs/generators/spring.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2020
| ------ | ----------- | ------ | ------- |
2121
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
2222
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
23+
|additionalNotNullAnnotations|Add @NotNull to path variables (required by default) and requestBody.| |false|
2324
|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
2425
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
2526
|annotationLibrary|Select the complementary documentation annotation library.|<dl><dt>**none**</dt><dd>Do not annotate Model and Api with complementary annotations.</dd><dt>**swagger1**</dt><dd>Annotate Model and Api using the Swagger Annotations 1.x library.</dd><dt>**swagger2**</dt><dd>Annotate Model and Api using the Swagger Annotations 2.x library.</dd></dl>|swagger2|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public class SpringCodegen extends AbstractJavaCodegen
108108
public static final String JACKSON2_PACKAGE = "com.fasterxml.jackson";
109109
public static final String JACKSON3_PACKAGE = "tools.jackson";
110110
public static final String JACKSON_PACKAGE = "jacksonPackage";
111+
public static final String ADDITIONAL_NOT_NULL_ANNOTATIONS = "additionalNotNullAnnotations";
111112

112113
@Getter
113114
public enum RequestMappingMode {
@@ -180,6 +181,8 @@ public enum RequestMappingMode {
180181
protected boolean useDeductionForOneOfInterfaces = false;
181182
@Getter @Setter
182183
protected boolean useJackson3 = false;
184+
@Getter @Setter
185+
protected boolean additionalNotNullAnnotations = false;
183186

184187
public SpringCodegen() {
185188
super();
@@ -269,7 +272,6 @@ public SpringCodegen() {
269272
cliOptions.add(CliOption.newString(X_IMPLEMENTS_SKIP, "Ability to choose interfaces that should NOT be implemented in the models despite their presence in vendor extension `x-implements`. Takes a list of fully qualified interface names. Example: yaml `xImplementsSkip: [com.some.pack.WithPhotoUrls]` skips implementing the interface `com.some.pack.WithPhotoUrls` in any schema", "empty list"));
270273
cliOptions.add(CliOption.newString(SCHEMA_IMPLEMENTS, "Ability to supply interfaces per schema that should be implemented (serves similar purpose as vendor extension `x-implements`, but is fully decoupled from the api spec). Example: yaml `schemaImplements: {Pet: com.some.pack.WithId, Category: [com.some.pack.CategoryInterface], Dog: [com.some.pack.Canine, com.some.pack.OtherInterface]}` implements interfaces in schemas `Pet` (interface `com.some.pack.WithId`), `Category` (interface `com.some.pack.CategoryInterface`), `Dog`(interfaces `com.some.pack.Canine`, `com.some.pack.OtherInterface`)", "empty map"));
271274

272-
273275
CliOption requestMappingOpt = new CliOption(REQUEST_MAPPING_OPTION,
274276
"Where to generate the class level @RequestMapping annotation.")
275277
.defaultValue(requestMappingMode.name());
@@ -325,6 +327,10 @@ public SpringCodegen() {
325327
library.setEnum(supportedLibraries);
326328
cliOptions.add(library);
327329

330+
cliOptions.add(CliOption.newBoolean(ADDITIONAL_NOT_NULL_ANNOTATIONS,
331+
"Add @NotNull to path variables (required by default) and requestBody.",
332+
additionalNotNullAnnotations));
333+
328334
}
329335

330336
@Override
@@ -532,6 +538,7 @@ public void processOpts() {
532538
}
533539
convertPropertyToStringAndWriteBack(RESOURCE_FOLDER, this::setResourceFolder);
534540

541+
convertPropertyToBooleanAndWriteBack(ADDITIONAL_NOT_NULL_ANNOTATIONS, this::setAdditionalNotNullAnnotations);
535542

536543
// override parent one
537544
importMapping.put("JsonDeserialize", (useJackson3 ? JACKSON3_PACKAGE : JACKSON2_PACKAGE) + ".databind.annotation.JsonDeserialize");
@@ -1286,7 +1293,7 @@ public List<VendorExtension> getSupportedVendorExtensions() {
12861293
return extensions;
12871294
}
12881295

1289-
private boolean isSpringCodegen() {
1296+
protected boolean isSpringCodegen() {
12901297
return getName().contains("spring");
12911298
}
12921299

modules/openapi-generator/src/main/resources/Java/build.gradle.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ if(hasProperty('target') && target == 'android') {
114114

115115
ext {
116116
swagger_annotations_version = "1.6.3"
117-
jackson_version = "2.19.2"
118-
jackson_databind_version = "2.19.2"
117+
jackson_version = "2.21.1"
118+
jackson_annotations_version = "2.21"
119+
jackson_databind_version = "2.21.1"
119120
{{#openApiNullable}}
120121
jackson_databind_nullable_version = "0.2.9"
121122
{{/openApiNullable}}
@@ -137,7 +138,7 @@ dependencies {
137138
implementation "com.sun.jersey:jersey-client:$jersey_version"
138139
implementation "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
139140
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
140-
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
141+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version"
141142
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
142143
implementation "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
143144
{{#openApiNullable}}

modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/build.gradle.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ if(hasProperty('target') && target == 'android') {
114114

115115
ext {
116116
swagger_annotations_version = "1.6.6"
117-
jackson_version = "2.19.2"
118-
jackson_databind_version = "2.19.2"
117+
jackson_version = "2.21.1"
118+
jackson_annotations_version = "2.21"
119+
jackson_databind_version = "2.21.1"
119120
{{#openApiNullable}}
120121
jackson_databind_nullable_version = "0.2.9"
121122
{{/openApiNullable}}
@@ -130,7 +131,7 @@ dependencies {
130131
implementation "com.google.code.findbugs:jsr305:3.0.2"
131132
implementation "org.apache.httpcomponents.client5:httpclient5:$httpclient_version"
132133
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
133-
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
134+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version"
134135
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
135136
implementation "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
136137
{{#openApiNullable}}

modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/pom.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
<dependency>
253253
<groupId>com.fasterxml.jackson.core</groupId>
254254
<artifactId>jackson-annotations</artifactId>
255-
<version>${jackson-version}</version>
255+
<version>${jackson-annotations-version}</version>
256256
</dependency>
257257
<dependency>
258258
<groupId>com.fasterxml.jackson.core</groupId>
@@ -351,8 +351,9 @@
351351
<swagger-annotations-version>2.2.15</swagger-annotations-version>
352352
{{/swagger2AnnotationLibrary}}
353353
<httpclient-version>5.2.1</httpclient-version>
354-
<jackson-version>2.19.2</jackson-version>
355-
<jackson-databind-version>2.19.2</jackson-databind-version>
354+
<jackson-version>2.21.1</jackson-version>
355+
<jackson-annotations-version>2.21</jackson-annotations-version>
356+
<jackson-databind-version>2.21.1</jackson-databind-version>
356357
{{#openApiNullable}}
357358
<jackson-databind-nullable-version>0.2.9</jackson-databind-nullable-version>
358359
{{/openApiNullable}}

modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ test {
103103
ext {
104104
swagger_annotations_version = "1.6.11"
105105
{{#jackson}}
106-
jackson_version = "2.19.2"
107-
jackson_databind_version = "2.19.2"
106+
jackson_version = "2.21.1"
107+
jackson_annotations_version = "2.21"
108+
jackson_databind_version = "2.21.1"
108109
{{/jackson}}
109110
{{#openApiNullable}}
110111
jackson_databind_nullable_version = "0.2.9"
@@ -139,7 +140,7 @@ dependencies {
139140
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
140141
{{/joda}}
141142
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
142-
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
143+
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version"
143144
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
144145
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
145146
{{/jackson}}

modules/openapi-generator/src/main/resources/Java/libraries/feign/build.sbt.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ lazy val root = (project in file(".")).
2424
"io.github.openfeign" % "feign-hc5" % "13.5" % "compile",
2525
{{/feign-hc5}}
2626
{{#jackson}}
27-
"com.fasterxml.jackson.core" % "jackson-core" % "2.17.1" % "compile",
28-
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.17.1" % "compile",
29-
"com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1" % "compile",
30-
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.17.1" % "compile",
27+
"com.fasterxml.jackson.core" % "jackson-core" % "2.21.1" % "compile",
28+
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.21" % "compile",
29+
"com.fasterxml.jackson.core" % "jackson-databind" % "2.21.1" % "compile",
30+
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.21.1" % "compile",
3131
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.15.2" % "compile",
3232
{{/jackson}}
3333
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",

0 commit comments

Comments
 (0)