mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-13 16:03:43 +00:00
Add vendorExtensions.x-class-extra-annotation to oneOf interfaces (#22020)
This commit is contained in:
parent
258d971f42
commit
89edad5b8a
@ -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}}();
|
||||
|
@ -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}}
|
||||
|
||||
|
@ -3982,4 +3982,21 @@ public class JavaClientCodegenTest {
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -5730,4 +5730,12 @@ public class SpringCodegenTest {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -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…
x
Reference in New Issue
Block a user