Skip to content

Commit

Permalink
Add integration test for discussion in #103
Browse files Browse the repository at this point in the history
  • Loading branch information
neiser committed Dec 29, 2021
1 parent c03ec1e commit 34bf69c
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.qaware.openapigeneratorforspring.test.app54;

import de.qaware.openapigeneratorforspring.test.AbstractOpenApiGeneratorWebMvcIntTest;

class App54Test extends AbstractOpenApiGeneratorWebMvcIntTest {

}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
}
}

0 comments on commit 34bf69c

Please sign in to comment.