Skip to content

Commit 01f36fd

Browse files
committed
fix: allow openApiNullable with useJackson3
1 parent 88f05a9 commit 01f36fd

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

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)