diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 2c1414d21ce..0a3bdeb357d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3993,6 +3993,9 @@ public class DefaultCodegen implements CodegenConfig { if (p.getWriteOnly() != null) { property.isWriteOnly = p.getWriteOnly(); } + if (original.getExtensions() != null) { + property.getVendorExtensions().putAll(original.getExtensions()); + } } // set the default value diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java index d2aaa6592a1..045e8898574 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java @@ -347,6 +347,11 @@ public class TestUtils { .containsWithName("javax.persistence.Transient") .toProperty() .toType(); + + JavaFileAssert.assertThat(java.nio.file.Paths.get(baseOutputPath + "/CompanyDto.java")) + .hasProperty("priceCategory") + .assertPropertyAnnotations() + .containsWithNameAndAttributes("IgnoreForRoles", ImmutableMap.of("value", "\"MEDIA_ADMIN\"")); } public static ModelsMap createCodegenModelWrapper(CodegenModel cm) { diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_11772.yml b/modules/openapi-generator/src/test/resources/3_0/issue_11772.yml index 7c1d941613f..9b326871cbd 100644 --- a/modules/openapi-generator/src/test/resources/3_0/issue_11772.yml +++ b/modules/openapi-generator/src/test/resources/3_0/issue_11772.yml @@ -65,6 +65,8 @@ paths: description: A list resource collection of Employees. operationId: getEmployees summary: List all employees. + /company: + summary: Represents a Company components: schemas: EmployeeEntity: @@ -277,3 +279,20 @@ components: description: Role that the employee is billed for on the project.. type: string example: Consultant + CompanyDto: + type: object + properties: + priceCategory: + description: The price category + nullable: true + x-field-extra-annotation: '@IgnoreForRoles("MEDIA_ADMIN")' + allOf: + - $ref: '#/components/schemas/SamplingPriceCategoryEnum' + + SamplingPriceCategoryEnum: + description: The price category of a sampling action + type: string + enum: + - FREE + - PRICE_TIER_1 + - PRICE_TIER_2 \ No newline at end of file