Skip to content

Commit

Permalink
Fix extensions handling for allOf with single schema (#15632)
Browse files Browse the repository at this point in the history
  • Loading branch information
borsch committed May 25, 2023
1 parent 2b9677a commit 765628f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3993,6 +3993,9 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
if (p.getWriteOnly() != null) {
property.isWriteOnly = p.getWriteOnly();
}
if (original.getExtensions() != null) {
property.getVendorExtensions().putAll(original.getExtensions());
}
}

// set the default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ public static void assertExtraAnnotationFiles(String baseOutputPath) {
.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) {
Expand Down
19 changes: 19 additions & 0 deletions modules/openapi-generator/src/test/resources/3_0/issue_11772.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

0 comments on commit 765628f

Please sign in to comment.