-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
fix: [BUG][JAVA] vendorExtension.x-class-extra-annotation doesn't generate lists of annotations correctly #23750
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4236,6 +4236,24 @@ public void oneOfWithInnerModelTest() { | |
| assertTrue(speciesSeen); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAllOfClassWithSingleAnnotation() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the |
||
| final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/allOf-with-annotations.yaml", RESTCLIENT); | ||
| JavaFileAssert.assertThat(files.get("Cat.java")) | ||
| .isNormalClass() | ||
| .assertTypeAnnotations().containsWithName("SuppressWarnings"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAllOfClassWithMultipleAnnotations() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. merge the 2 tests |
||
| final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/allOf-with-annotations.yaml", RESTCLIENT); | ||
| JavaFileAssert.assertThat(files.get("Dog.java")) | ||
| .isNormalClass() | ||
| .assertTypeAnnotations() | ||
| .containsWithName("SuppressWarnings") | ||
| .containsWithName("Deprecated"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOneOfClassWithAnnotation() { | ||
| final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", RESTCLIENT); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6103,6 +6103,24 @@ public void testOneOfInterfaceWithAnnotation() throws IOException { | |
| .assertTypeAnnotations().containsWithName("SuppressWarnings"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAllOfClassWithSingleAnnotation() throws IOException { | ||
| final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/allOf-with-annotations.yaml", SPRING_BOOT); | ||
| JavaFileAssert.assertThat(files.get("Cat.java")) | ||
| .isNormalClass() | ||
| .assertTypeAnnotations().containsWithName("SuppressWarnings"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAllOfClassWithMultipleAnnotations() throws IOException { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merge the 2 tests |
||
| final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/allOf-with-annotations.yaml", SPRING_BOOT); | ||
| JavaFileAssert.assertThat(files.get("Dog.java")) | ||
| .isNormalClass() | ||
| .assertTypeAnnotations() | ||
| .containsWithName("SuppressWarnings") | ||
| .containsWithName("Deprecated"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testApiVersion() throws IOException { | ||
| final Map<String, File> files = generateFromContract("src/test/resources/3_0/spring/apiVersion.yaml", SPRING_BOOT, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| openapi: 3.0.1 | ||
| info: | ||
| title: allOf Annotations Test | ||
| version: 0.0.1 | ||
| paths: | ||
| /: | ||
| get: | ||
| responses: | ||
| '200': | ||
| description: desc | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Dog' | ||
| components: | ||
| schemas: | ||
| Animal: | ||
| type: object | ||
| properties: | ||
| name: | ||
| type: string | ||
| Dog: | ||
| x-class-extra-annotation: | ||
| - '@SuppressWarnings("unchecked")' | ||
| - '@Deprecated' | ||
| allOf: | ||
| - $ref: '#/components/schemas/Animal' | ||
| properties: | ||
| breed: | ||
| type: string | ||
| Cat: | ||
| x-class-extra-annotation: '@SuppressWarnings("unchecked")' | ||
| allOf: | ||
| - $ref: '#/components/schemas/Animal' | ||
| properties: | ||
| indoor: | ||
| type: boolean |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a reusable method, also available for other annotations and other generators (kotlin)
Maybe some static method:
fixExtraAnnotation(Map<String, Object> vendorExtensions , String annotationName)