-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
feature(jackson3) add jackson3 support for spring generator #22854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| generatorName: spring | ||
| outputDir: samples/openapi3/server/petstore/springboot-4 | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/JavaSpring | ||
| additionalProperties: | ||
| groupId: org.openapitools.openapi3 | ||
| documentationProvider: springdoc | ||
| artifactId: springboot | ||
| snapshotVersion: "true" | ||
| useSpringBoot4: true | ||
| useJackson3: true | ||
| useBeanValidation: true | ||
| withXml: true | ||
| hideGenerationTimestamp: "true" | ||
| generateConstructorWithAllArgs: true | ||
| generateBuilders: true | ||
| openApiNullable: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| generatorName: spring | ||
| library: spring-cloud | ||
| outputDir: samples/openapi3/client/petstore/spring-cloud-4-with-optional | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/JavaSpring | ||
| additionalProperties: | ||
| groupId: org.openapitools.openapi3 | ||
| documentationProvider: springdoc | ||
| artifactId: spring-cloud-oas4 | ||
| useSpringBoot4: "true" | ||
| useJackson3: true | ||
| openApiNullable: false | ||
| dateLibrary: "java8" | ||
| useOptional: "true" | ||
| useSwaggerUI: "false" | ||
| hideGenerationTimestamp: "true" | ||
| documentationProvider: none | ||
| #optionalAcceptNullable: "false" # default to true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| generatorName: spring | ||
| library: spring-http-interface | ||
| outputDir: samples/client/petstore/spring-http-interface-springboot-4 | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/JavaSpring | ||
| additionalProperties: | ||
| artifactId: spring-http-interface | ||
| snapshotVersion: "true" | ||
| hideGenerationTimestamp: "true" | ||
| modelNameSuffix: 'Dto' | ||
| generatedConstructorWithRequiredArgs: "false" | ||
| # documentation provider should be ignored | ||
| documentationProvider: "springdoc" | ||
| # annotation provider should be ignored | ||
| annotationLibrary: "swagger2" | ||
| # validation should be ignored | ||
| useBeanValidation: "true" | ||
| performBeanValidation: "true" | ||
| useSpringBoot4: "true" | ||
| useJackson3: true | ||
| openApiNullable: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,12 +107,14 @@ These options may be applied as additional-properties (cli) or configOptions (pl | |
| |useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false| | ||
| |useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true| | ||
| |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| | ||
| |useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false| | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wing328 you raise a good point. I did not correlate them (despite the compatibility); yet I think that using spring boot 4 should enable jackson 3 by default as it is the default behaviour in spring boot. What do you think? For developer experience this would lower the number of parameter given to the generator by default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is misleading. The Jackson 3 settings should not be tied to a Spring Boot 4 setting. The Java generator with the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ML-Marco in order not to impact too much files, I wanted to only address the spring generator.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ML-Marco so as you suggest I do not add a correlated behavior between two parameters
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok I see what you mean; I was puzzled on this question. As you read, springboot strongly advise to move to jackson 3 and tells jackson 2 won't be supported in the future. Yet it is supported. For now.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could the jackson2 vs 3 be handled in a similar way as are the That could lead to a minimal code change across the project and maybe more maintainable template files going forward?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Picazsoo that's a great idea; I will take a look at it in spring generator and give you a feedback
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As @Picazsoo smartly spotted, introducing a template variable Some use of
For almost every other needs, setting the variable to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just updated PR description |
||
| |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false| | ||
| |useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |true| | ||
| |useOptional|Use Optional container for optional parameters| |false| | ||
| |useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true| | ||
| |useSealed|Whether to generate sealed model interfaces and classes| |false| | ||
| |useSpringBoot3|Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| | ||
| |useSpringBoot4|Generate code and provide dependencies for use with Spring Boot 4.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| | ||
| |useSpringBuiltInValidation|Disable `@Validated` at the class level when using built-in validation.| |false| | ||
| |useSpringController|Annotate the generated API as a Spring Controller| |false| | ||
| |useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true| | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the new folders to https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-spring-jdk17.yaml so that CI will test it moving forward
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 I added them yet it is not launched... Shouldn't add it to
samples-jdk17.yamlinstead? As I see them launched with different synthax (/**for instance)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe does it takes main branch specification instead? 🤔
I see that I also added
samples/client/petstore/spring-http-interfacebut it was present insamples-jdk17.yaml, I shall remove it and keep only the v4 version