Skip to content
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
@@ -1,4 +1,7 @@
{{>additionalOneOfTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}}
{{#vendorExtensions.x-class-extra-annotation}}
{{{vendorExtensions.x-class-extra-annotation}}}
{{/vendorExtensions.x-class-extra-annotation}}
public {{>sealed}}interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}}{{>permits}}{
{{#discriminator}}
public {{propertyType}} {{propertyGetter}}();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
@JsonSubTypes.Type(value = {{classname}}.class){{^-last}}, {{/-last}}
{{/interfaceModels}}
})
{{/useDeductionForOneOfInterfaces}}
{{/useDeductionForOneOfInterfaces}}{{#vendorExtensions.x-class-extra-annotation}}{{{vendorExtensions.x-class-extra-annotation}}}
{{/vendorExtensions.x-class-extra-annotation}}
{{/discriminator}}
{{>generatedAnnotation}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3982,4 +3982,21 @@ public void oneOfWithInnerModelTest() {
}
assertTrue(speciesSeen);
}

@Test
public void testOneOfClassWithAnnotation() throws IOException {
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", RESTCLIENT);
JavaFileAssert.assertThat(files.get("Fruit.java"))
.isNormalClass()
.assertTypeAnnotations().containsWithName("SuppressWarnings");
}

@Test
public void testOneOfInterfaceWithAnnotation() throws IOException {
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", RESTCLIENT,
Map.of(USE_ONE_OF_INTERFACES, "true"));
JavaFileAssert.assertThat(files.get("Fruit.java"))
.isInterface()
.assertTypeAnnotations().containsWithName("SuppressWarnings");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5730,4 +5730,12 @@ public void testHasRestControllerDoesNotHaveController_issue21156() throws IOExc
javaFileAssert
.hasImports("java.util.concurrent.atomic.AtomicInteger");
}

@Test
public void testOneOfInterfaceWithAnnotation() throws IOException {
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", SPRING_BOOT);
JavaFileAssert.assertThat(files.get("Fruit.java"))
.isInterface()
.assertTypeAnnotations().containsWithName("SuppressWarnings");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
openapi: 3.0.1
info:
title: fruity
version: 0.0.1
paths:
/:
get:
responses:
'200':
description: desc
content:
application/json:
schema:
$ref: '#/components/schemas/fruit'
components:
schemas:
fruit:
title: fruit
x-class-extra-annotation: '@SuppressWarnings("unchecked")'
properties:
color:
type: string
oneOf:
- $ref: '#/components/schemas/apple'
- $ref: '#/components/schemas/banana'
- $ref: '#/components/schemas/orange'
apple:
title: apple
type: object
properties:
kind:
type: string
banana:
title: banana
type: object
properties:
count:
type: number
orange:
title: orange
type: object
properties:
sweet:
type: boolean
Loading