Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extensions handling for allOf with single schema #15632

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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