Skip to content

Commit 02fdec2

Browse files
committed
fix: allow openApiNullable with useJackson3
1 parent c1e0361 commit 02fdec2

File tree

4 files changed

+3
-31
lines changed

4 files changed

+3
-31
lines changed

docs/generators/java-camel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
110110
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
111111
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
112112
|useHttpServiceProxyFactoryInterfacesConfigurator|Generate HttpInterfacesAbstractConfigurator based on an HttpServiceProxyFactory instance (as opposed to a WebClient instance, when disabled) for generating Spring HTTP interfaces.| |false|
113-
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false|
113+
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set).| |false|
114114
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
115115
|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|
116116
|useOptional|Use Optional container for optional parameters| |false|

docs/generators/spring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
103103
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
104104
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
105105
|useHttpServiceProxyFactoryInterfacesConfigurator|Generate HttpInterfacesAbstractConfigurator based on an HttpServiceProxyFactory instance (as opposed to a WebClient instance, when disabled) for generating Spring HTTP interfaces.| |false|
106-
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false|
106+
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set).| |false|
107107
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
108108
|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|
109109
|useOptional|Use Optional container for optional parameters| |false|

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public SpringCodegen() {
306306
cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT4,
307307
"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`.",
308308
useSpringBoot4));
309-
cliOptions.add(CliOption.newBoolean(USE_JACKSON_3, "Set it in order to use jackson 3 dependencies (only allowed when `" + USE_SPRING_BOOT4 + "` is set and incompatible with `"+OPENAPI_NULLABLE+"`).", useJackson3));
309+
cliOptions.add(CliOption.newBoolean(USE_JACKSON_3, "Set it in order to use jackson 3 dependencies (only allowed when `" + USE_SPRING_BOOT4 + "` is set).", useJackson3));
310310
cliOptions.add(new CliOption(INCLUDE_HTTP_REQUEST_CONTEXT,
311311
"Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods. Defaults to 'true' for reactive and 'false' for blocking.",
312312
SchemaTypeUtil.BOOLEAN_TYPE).defaultValue("true (reactive) / false (blocking)"));
@@ -535,9 +535,6 @@ public void processOpts() {
535535
if(isUseJackson3() && !isUseSpringBoot4()){
536536
throw new IllegalArgumentException("useJackson3 is only available with Spring Boot >= 4");
537537
}
538-
if(isUseJackson3() && isOpenApiNullable()){
539-
throw new IllegalArgumentException("openApiNullable cannot be set with useJackson3");
540-
}
541538
if(this.useJackson3){
542539
this.applyJackson3Package();
543540
} else {

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6512,31 +6512,6 @@ public void shouldRefuseJackson3WithoutSpringboot4() throws IOException {
65126512
.isThrownBy(generator::generate);
65136513
}
65146514

6515-
@Test
6516-
public void shouldRefuseOpenApiNullableWithJackson3() throws IOException {
6517-
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
6518-
output.deleteOnExit();
6519-
6520-
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/petstore-echo.yaml");
6521-
final SpringCodegen codegen = new SpringCodegen();
6522-
codegen.setOpenAPI(openAPI);
6523-
codegen.setOutputDir(output.getAbsolutePath());
6524-
6525-
codegen.additionalProperties().put(SpringCodegen.USE_SPRING_BOOT4, "true");
6526-
codegen.additionalProperties().put(SpringCodegen.USE_JACKSON_3, "true");
6527-
codegen.additionalProperties().put(SpringCodegen.OPENAPI_NULLABLE, "true");
6528-
6529-
ClientOptInput input = new ClientOptInput();
6530-
input.openAPI(openAPI);
6531-
input.config(codegen);
6532-
6533-
Generator generator = new DefaultGenerator()
6534-
.opts(input);
6535-
6536-
Assertions.assertThatExceptionOfType(IllegalArgumentException.class)
6537-
.isThrownBy(generator::generate);
6538-
}
6539-
65406515
@Test
65416516
public void shouldImportJackson2JsonDeserializeForUniqueItemsWhenJackson3NotSet() throws IOException {
65426517
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();

0 commit comments

Comments
 (0)