diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/v3/service/GeneratorServiceTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/v3/service/GeneratorServiceTest.java index 5b79dee2780..12dd7659632 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/v3/service/GeneratorServiceTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/v3/service/GeneratorServiceTest.java @@ -18,6 +18,35 @@ public class GeneratorServiceTest { + @Test(description = "test generator oneOf ComposedSchema Properties") + public void testGenerator_OneOf_ComposedSchemaProperties() throws IOException { + + String path = getTmpFolder().getAbsolutePath(); + GenerationRequest request = new GenerationRequest(); + request + .codegenVersion(GenerationRequest.CodegenVersion.V3) + .type(GenerationRequest.Type.CLIENT) + .lang("html") + .spec(loadSpecAsNode("3_0_0/OneOfPropertiesIssue.yaml", true, false)) + .options( + new Options() + .outputDir(path) + ); + + List files = new GeneratorService().generationRequest(request).generate(); + Assert.assertFalse(files.isEmpty()); + for (File f: files) { + String relPath = f.getAbsolutePath().substring(path.length()); + if ("/index.html".equals(relPath)) { + //val_Member unique property + Assert.assertTrue(FileUtils.readFileToString(f).contains("val_unique_reference")); + //val_Member_Product unique property + Assert.assertTrue(FileUtils.readFileToString(f).contains("val_property_1")); + } + } + + } + @Test(description = "test generator service with jaxrs-cxf-client") public void testGeneratorService_Jaxrs_cxf_client() throws IOException { diff --git a/modules/swagger-codegen/src/test/resources/3_0_0/OneOfPropertiesIssue.yaml b/modules/swagger-codegen/src/test/resources/3_0_0/OneOfPropertiesIssue.yaml new file mode 100644 index 00000000000..3b9237aba2b --- /dev/null +++ b/modules/swagger-codegen/src/test/resources/3_0_0/OneOfPropertiesIssue.yaml @@ -0,0 +1,78 @@ +--- +openapi: 3.0.2 +info: + description: "Description" + title: Title + version: v2 +paths: + "/validation": + post: + tags: + - Validation Data + summary: Validation Data + requestBody: + required: true + content: + application/json: + schema: + "$ref": "#/components/schemas/mtg_Message" + responses: + '200': + description: responses description + content: + application/xml: + schema: + "$ref": "#/components/schemas/mtg_Message" +components: + schemas: + val_Member: + additionalProperties: false + description: valMember + properties: + val_unique_reference: + description: val unique reference + "$ref": "#/components/schemas/val_TypeCode" + val_country: + description: val country + "$ref": "#/components/schemas/val_Country" + val_products: + description: Products + "$ref": "#/components/schemas/val_Products" + oneOf: + - required: + - val_products + - required: + - val_country + xml: + prefix: val + name: member + type: object + val_MemberProduct: + additionalProperties: false + description: Member Product Description + properties: + val_property_1: + description: property 1 + "$ref": "#/components/schemas/val_Property_1" + val_property_2: + description: property 2 + "$ref": "#/components/schemas/val_Property_2" + val_property_3: + description: property 3 + "$ref": "#/components/schemas/val_Property_3" + val_property_4: + description: property 4 + "$ref": "#/components/schemas/val_Property_4" + oneOf: + - required: + - val_property_1 + - required: + - val_property_2 + - required: + - val_property_3 + - required: + - val_property_4 + xml: + prefix: val + name: product + type: object \ No newline at end of file