Fix extensions handling for allOf with single schema (#15632)

This commit is contained in:
Oleh Kurpiak 2023-05-25 05:59:00 +03:00 committed by GitHub
parent 2b9677a29e
commit 765628fb77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -3993,6 +3993,9 @@ public class DefaultCodegen implements CodegenConfig {
if (p.getWriteOnly() != null) { if (p.getWriteOnly() != null) {
property.isWriteOnly = p.getWriteOnly(); property.isWriteOnly = p.getWriteOnly();
} }
if (original.getExtensions() != null) {
property.getVendorExtensions().putAll(original.getExtensions());
}
} }
// set the default value // set the default value

View File

@ -347,6 +347,11 @@ public class TestUtils {
.containsWithName("javax.persistence.Transient") .containsWithName("javax.persistence.Transient")
.toProperty() .toProperty()
.toType(); .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) { public static ModelsMap createCodegenModelWrapper(CodegenModel cm) {

View File

@ -65,6 +65,8 @@ paths:
description: A list resource collection of Employees. description: A list resource collection of Employees.
operationId: getEmployees operationId: getEmployees
summary: List all employees. summary: List all employees.
/company:
summary: Represents a Company
components: components:
schemas: schemas:
EmployeeEntity: EmployeeEntity:
@ -277,3 +279,20 @@ components:
description: Role that the employee is billed for on the project.. description: Role that the employee is billed for on the project..
type: string type: string
example: Consultant 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