Skip to content

Commit a070a6a

Browse files
authored
[JAVA-SPRING] - 22859 - spring http interface library should support 'useBeanValidation' (OpenAPITools#23803)
* feat: add support for Bean Validation in Java Spring HTTP Interface code generation (no samples regen, no documentation regen - to force cubic to review the most relevant files) * update samples * add samples for new functionality. Regenerate * fix up-to-date samples * Update modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java whitespace only change to retrigger pipelines
1 parent 179acc9 commit a070a6a

722 files changed

Lines changed: 21006 additions & 1490 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-jdk17.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- samples/client/petstore/java-helidon-client/v3/mp/**
88
- samples/client/petstore/java-helidon-client/v3/se/**
99
- samples/client/petstore/spring-http-interface-reactive/**
10+
- samples/client/petstore/spring-http-interface-reactive-bean-validation/**
11+
- samples/client/petstore/spring-http-interface-bean-validation/**
1012
- samples/client/petstore/spring-http-interface/**
1113
- samples/client/petstore/spring-http-interface-reactive-noResponseEntity/**
1214
- samples/client/petstore/spring-http-interface-noResponseEntity/**
@@ -27,6 +29,8 @@ on:
2729
- samples/client/petstore/java-helidon-client/v3/mp/**
2830
- samples/client/petstore/java-helidon-client/v3/se/**
2931
- samples/client/petstore/spring-http-interface-reactive/**
32+
- samples/client/petstore/spring-http-interface-reactive-bean-validation/**
33+
- samples/client/petstore/spring-http-interface-bean-validation/**
3034
- samples/client/petstore/spring-http-interface/**
3135
- samples/client/petstore/spring-http-interface-reactive-noResponseEntity/**
3236
- samples/client/petstore/spring-http-interface-noResponseEntity/**
@@ -53,6 +57,8 @@ jobs:
5357
- samples/client/petstore/java-helidon-client/v3/mp/
5458
- samples/client/petstore/java-helidon-client/v3/se
5559
- samples/client/petstore/spring-http-interface-reactive
60+
- samples/client/petstore/spring-http-interface-reactive-bean-validation
61+
- samples/client/petstore/spring-http-interface-bean-validation
5662
- samples/client/petstore/spring-http-interface
5763
- samples/client/petstore/spring-http-interface-reactive-noResponseEntity
5864
- samples/client/petstore/spring-http-interface-noResponseEntity

.github/workflows/samples-kotlin-server-jdk17.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
- samples/server/petstore/kotlin-server-modelMutable
6868
- samples/server/petstore/kotlin-misk
6969
- samples/server/petstore/kotlin-spring-declarative-interface
70+
- samples/server/petstore/kotlin-spring-declarative-interface-bean-validation
7071
- samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines
7172
- samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped
7273
- samples/server/petstore/kotlin-spring-declarative-interface-wrapped
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
generatorName: kotlin-spring
2+
outputDir: samples/server/petstore/kotlin-spring-declarative-interface-bean-validation
3+
library: spring-declarative-http-interface
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
6+
additionalProperties:
7+
documentationProvider: springDoc
8+
annotationLibrary: swagger2
9+
useSwaggerUI: "false"
10+
serializableModel: "true"
11+
interfaceOnly: true
12+
reactive: false
13+
useResponseEntity: true
14+
useFlowForArrayReturnType: false
15+
useBeanValidation: "true"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
generatorName: spring
2+
library: spring-http-interface
3+
outputDir: samples/client/petstore/spring-http-interface-bean-validation
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
6+
additionalProperties:
7+
artifactId: spring-http-interface
8+
snapshotVersion: "true"
9+
hideGenerationTimestamp: "true"
10+
modelNameSuffix: 'Dto'
11+
generatedConstructorWithRequiredArgs: "false"
12+
# validation should be respected
13+
useBeanValidation: "true"
14+
# documentation provider should be ignored
15+
documentationProvider: "springdoc"
16+
# annotation provider should be ignored
17+
annotationLibrary: "swagger2"
18+
useSpringBoot3: "true"

bin/configs/spring-http-interface-noResponseEntity.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ additionalProperties:
1313
documentationProvider: "springdoc"
1414
# annotation provider should be ignored
1515
annotationLibrary: "swagger2"
16-
# validation should be ignored
17-
useBeanValidation: "true"
18-
performBeanValidation: "true"
16+
# useBeanValidation should default to "false" when not specified
17+
# performBeanValidation should default to "false" when not specified
1918
useResponseEntity: "false"
2019
useSpringBoot3: "true"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
generatorName: spring
2+
library: spring-http-interface
3+
outputDir: samples/client/petstore/spring-http-interface-reactive-bean-validation
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
6+
additionalProperties:
7+
artifactId: spring-http-interface-reactive
8+
snapshotVersion: "true"
9+
hideGenerationTimestamp: "true"
10+
reactive: "true"
11+
# validation should be respected
12+
useBeanValidation: "true"
13+
# documentation provider should be ignored
14+
documentationProvider: "springfox"
15+
# annotation provider should be ignored
16+
annotationLibrary: "swagger1"
17+
useSpringBoot3: "true"

bin/configs/spring-http-interface-reactive-noResponseEntity.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ additionalProperties:
1212
documentationProvider: "springdoc"
1313
# annotation provider should be ignored
1414
annotationLibrary: "swagger1"
15-
# validation should be ignored
16-
useBeanValidation: "true"
17-
performBeanValidation: "true"
15+
# useBeanValidation should default to "false" when not specified
16+
# performBeanValidation should default to "false" when not specified
1817
useResponseEntity: "false"
1918
useSpringBoot3: "true"
2019

bin/configs/spring-http-interface-reactive.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ additionalProperties:
1212
documentationProvider: "springdoc"
1313
# annotation provider should be ignored
1414
annotationLibrary: "swagger1"
15-
# validation should be ignored
16-
useBeanValidation: "true"
17-
performBeanValidation: "true"
15+
# useBeanValidation should default to "false" when not specified
16+
# performBeanValidation should default to "false" when not specified
1817
useSpringBoot3: "true"
1918

bin/configs/spring-http-interface-springboot-4.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ additionalProperties:
1313
documentationProvider: "springdoc"
1414
# annotation provider should be ignored
1515
annotationLibrary: "swagger2"
16-
# validation should be ignored
1716
useBeanValidation: "true"
1817
performBeanValidation: "true"
1918
useSpringBoot4: "true"

bin/configs/spring-http-interface.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ additionalProperties:
1313
documentationProvider: "springdoc"
1414
# annotation provider should be ignored
1515
annotationLibrary: "swagger2"
16-
# validation should be ignored
17-
useBeanValidation: "true"
18-
performBeanValidation: "true"
16+
# useBeanValidation should default to "false" when not specified
17+
# performBeanValidation should default to "false" when not specified
1918
useSpringBoot3: "true"

0 commit comments

Comments
 (0)