Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polymorphism - documentation not generated for subtypes when using Js…
…onTypeInfo.As.WRAPPER_OBJECT and JsonTypeInfo.Id.NAME. fixes #1799
- Loading branch information
1 parent
2272cb3
commit 2478516
Showing
9 changed files
with
214 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app193/Animal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package test.org.springdoc.api.v30.app193; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
/** | ||
* Interface of the Animal. | ||
*/ | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = Dog.class, name = "dog"), | ||
@JsonSubTypes.Type(value = Cat.class, name = "cat"), | ||
}) | ||
@Schema(description = "Represents an Animal class.") | ||
public interface Animal {} |
21 changes: 21 additions & 0 deletions
21
...-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app193/BasicController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package test.org.springdoc.api.v30.app193; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping(path = "/") | ||
public class BasicController { | ||
|
||
@GetMapping("/test") | ||
@Operation(summary = "get", description = "Provides an animal.") | ||
public Animal get() { | ||
|
||
return new Dog("Foo", 12); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app193/Cat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package test.org.springdoc.api.v30.app193; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(description = "Represents a Cat class.") | ||
public class Cat implements Animal { | ||
|
||
private Integer speed; | ||
|
||
public Cat(Integer speed) { | ||
this.speed = speed; | ||
} | ||
|
||
public Integer getSpeed() { | ||
return speed; | ||
} | ||
|
||
public void setSpeed(Integer speed) { | ||
this.speed = speed; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app193/Dog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package test.org.springdoc.api.v30.app193; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(description = "Represents a Dog class.") | ||
public class Dog implements Animal { | ||
|
||
private String name; | ||
private Integer age; | ||
|
||
public Dog(String name, Integer age) { | ||
this.name = name; | ||
this.age = age; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Integer getAge() { | ||
return age; | ||
} | ||
|
||
public void setAge(Integer age) { | ||
this.age = age; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app193.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/test": { | ||
"get": { | ||
"tags": [ | ||
"basic-controller" | ||
], | ||
"summary": "get", | ||
"description": "Provides an animal.", | ||
"operationId": "get", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/components/schemas/Cat" | ||
}, | ||
{ | ||
"$ref": "#/components/schemas/Dog" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Animal": { | ||
"type": "object", | ||
"description": "Represents an Animal class." | ||
}, | ||
"Cat": { | ||
"type": "object", | ||
"description": "Represents a Cat class.", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/components/schemas/Animal" | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"speed": { | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"Dog": { | ||
"type": "object", | ||
"description": "Represents a Dog class.", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/components/schemas/Animal" | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"age": { | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |