Skip to content

Commit 38f93c9

Browse files
committed
Test boolean property with enum
1 parent 6fca1ef commit 38f93c9

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,24 @@ public void testSupportedSecuritySchemesJersey() {
552552
.contains("@Pattern", "import jakarta.validation.constraints.*");
553553
}
554554

555+
@Test public void testJersey3JacksonWithTypeFormat() {
556+
final Path output = newTempFolder();
557+
final CodegenConfigurator configurator = new CodegenConfigurator()
558+
.setGeneratorName("java")
559+
.setLibrary(JERSEY3)
560+
.addAdditionalProperty(CodegenConstants.MODEL_PACKAGE, "xyz.abcdef.model")
561+
.addAdditionalProperty(JavaClientCodegen.USE_JAKARTA_EE, true)
562+
.addAdditionalProperty(CodegenConstants.SERIALIZATION_LIBRARY, JavaClientCodegen.SERIALIZATION_LIBRARY_JACKSON)
563+
.setInputSpec("src/test/resources/3_1/java/java-type-with-format.yaml")
564+
.setOutputDir(output.toString().replace("\\", "/"));
565+
566+
List<File> files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
567+
568+
validateJavaSourceFiles(files);
569+
assertThat(output.resolve("src/main/java/xyz/abcdef/model/DataResponse.java")).content()
570+
.contains("TRUE(Boolean.valueOf(\"true\"))");
571+
}
572+
555573
@Test public void testJdkHttpClientWithAndWithoutDiscriminator() {
556574
final Path output = newTempFolder();
557575
final CodegenConfigurator configurator = new CodegenConfigurator()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
openapi: 3.1.0
2+
info:
3+
version: 1.0.0
4+
description: Specification to reproduce incorrectly generated Java code when using formats
5+
title: FormatTest Api
6+
paths:
7+
/format-test:
8+
get:
9+
tags:
10+
- test
11+
responses:
12+
'200':
13+
description: OK
14+
content:
15+
application/json:
16+
schema:
17+
$ref: "#/components/schemas/data-response"
18+
components:
19+
schemas:
20+
data-response:
21+
type: object
22+
title: Response
23+
properties:
24+
id:
25+
type: string
26+
flag:
27+
type: boolean
28+
enum:
29+
- true

0 commit comments

Comments
 (0)