-
-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/respect_composed_schemas' of https://github.com/slw…
…546/springdoc-openapi into slw546-fix/respect_composed_schemas
- Loading branch information
Showing
7 changed files
with
210 additions
and
2 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
24 changes: 24 additions & 0 deletions
24
springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/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,24 @@ | ||
package test.org.springdoc.api.app31; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema | ||
public class Cat extends Pet { | ||
|
||
private final boolean meows; | ||
|
||
public Cat() { | ||
super(); | ||
this.meows = false; | ||
} | ||
|
||
public Cat(boolean meows, String name) { | ||
super(name); | ||
this.meows = meows; | ||
} | ||
|
||
public boolean getMeows() { | ||
return meows; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/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,24 @@ | ||
package test.org.springdoc.api.app31; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema | ||
public class Dog extends Pet { | ||
|
||
private final boolean barks; | ||
|
||
public Dog() { | ||
super(); | ||
this.barks = false; | ||
} | ||
|
||
public Dog(boolean barks, String name) { | ||
super(name); | ||
this.barks = barks; | ||
} | ||
|
||
public boolean getBarks() { | ||
return barks; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/Pet.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,23 @@ | ||
package test.org.springdoc.api.app31; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(Dog.class), | ||
@JsonSubTypes.Type(Cat.class) | ||
}) | ||
public class Pet { | ||
|
||
public final String name; | ||
|
||
public Pet() { | ||
this.name = null; | ||
} | ||
|
||
public Pet(String name) { | ||
this.name = name; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/PetController.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,18 @@ | ||
package test.org.springdoc.api.app31; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class PetController { | ||
|
||
@GetMapping("/any") | ||
public Pet getAnyPet() { | ||
return new Cat(true, "cat"); | ||
} | ||
|
||
@GetMapping("/dog") | ||
public Dog getDog() { | ||
return new Dog(true, "dog"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...gdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.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,12 @@ | ||
package test.org.springdoc.api.app31; | ||
|
||
import test.org.springdoc.api.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
public class SpringDocApp31Test extends AbstractSpringDocTest { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
springdoc-openapi-data-rest/src/test/resources/results/app31.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,100 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
}], | ||
"paths": { | ||
"/dog": { | ||
"get": { | ||
"tags": ["pet-controller"], | ||
"operationId": "getDog", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"application/hal+json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Dog" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/any": { | ||
"get": { | ||
"tags": ["pet-controller"], | ||
"operationId": "getAnyPet", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"application/hal+json": { | ||
"schema": { | ||
"oneOf": [{ | ||
"$ref": "#/components/schemas/Pet" | ||
}, { | ||
"$ref": "#/components/schemas/Cat" | ||
}, { | ||
"$ref": "#/components/schemas/Dog" | ||
}] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Dog": { | ||
"type": "object", | ||
"allOf": [{ | ||
"$ref": "#/components/schemas/Pet" | ||
}, { | ||
"type": "object", | ||
"properties": { | ||
"barks": { | ||
"type": "boolean" | ||
} | ||
} | ||
}] | ||
}, | ||
"Cat": { | ||
"type": "object", | ||
"allOf": [{ | ||
"$ref": "#/components/schemas/Pet" | ||
}, { | ||
"type": "object", | ||
"properties": { | ||
"meows": { | ||
"type": "boolean" | ||
} | ||
} | ||
}] | ||
}, | ||
"Pet": { | ||
"required": ["type"], | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"type": { | ||
"type": "string" | ||
} | ||
}, | ||
"discriminator": { | ||
"propertyName": "type" | ||
} | ||
} | ||
} | ||
} | ||
} |