diff --git a/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54.java b/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54.java new file mode 100644 index 00000000..4633a706 --- /dev/null +++ b/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54.java @@ -0,0 +1,11 @@ +package de.qaware.openapigeneratorforspring.test.app54; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +class App54 { + public static void main(String[] args) { + SpringApplication.run(App54.class, args); + } +} diff --git a/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54Controller.java b/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54Controller.java new file mode 100644 index 00000000..415ab3b6 --- /dev/null +++ b/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54Controller.java @@ -0,0 +1,36 @@ +package de.qaware.openapigeneratorforspring.test.app54; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import lombok.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping +class App54Controller { + @GetMapping("mapping1") + public Animal mapping1() { + return null; + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") + @JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "DOG"), + @JsonSubTypes.Type(value = Cat.class, name = "CAT"), + }) + private interface Animal { + + } + + @Value + private static class Dog { + String wuff; + } + + @Value + private static class Cat { + String meow; + } +} diff --git a/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54Test.java b/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54Test.java new file mode 100644 index 00000000..f3160244 --- /dev/null +++ b/openapi-generator-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app54/App54Test.java @@ -0,0 +1,7 @@ +package de.qaware.openapigeneratorforspring.test.app54; + +import de.qaware.openapigeneratorforspring.test.AbstractOpenApiGeneratorWebMvcIntTest; + +class App54Test extends AbstractOpenApiGeneratorWebMvcIntTest { + +} diff --git a/openapi-generator-for-spring-test/src/test/resources/openApiJson/app54.json b/openapi-generator-for-spring-test/src/test/resources/openApiJson/app54.json new file mode 100644 index 00000000..161f847d --- /dev/null +++ b/openapi-generator-for-spring-test/src/test/resources/openApiJson/app54.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "API for App54", + "version": "unknown" + }, + "paths": { + "/mapping1": { + "get": { + "operationId": "mapping1", + "responses": { + "200": { + "description": "Default response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/App54Controller.Animal" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "App54Controller.AnimalType": { + "type": "string", + "enum": [ + "DOG", + "CAT" + ] + }, + "App54Controller.Dog": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/App54Controller.AnimalType" + }, + "wuff": { + "type": "string" + } + } + }, + "App54Controller.Cat": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/App54Controller.AnimalType" + }, + "meow": { + "type": "string" + } + } + }, + "App54Controller.Animal": { + "discriminator": { + "propertyName": "type", + "mapping": { + "DOG": "#/components/schemas/App54Controller.Dog", + "CAT": "#/components/schemas/App54Controller.Cat" + } + }, + "oneOf": [ + { + "$ref": "#/components/schemas/App54Controller.Dog" + }, + { + "$ref": "#/components/schemas/App54Controller.Cat" + } + ] + } + } + } +}