Skip to content

Commit 091a5c9

Browse files
committed
project review
1 parent c7c31fc commit 091a5c9

File tree

7 files changed

+60
-45
lines changed

7 files changed

+60
-45
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,9 @@ public static Schema extractSchema(Components components, Type returnType, JsonV
130130
}
131131
else
132132
for (Map.Entry<String, Schema> entry : schemaMap.entrySet()) {
133-
if (!componentSchemas.containsKey(entry.getKey())) {
134-
componentSchemas.put(entry.getKey(), entry.getValue());
135-
// If we've seen this schema before but find later it should be polymorphic,
136-
// replace the existing schema with this richer version.
137-
} else if (entry.getValue() instanceof ComposedSchema &&
138-
!(componentSchemas.get(entry.getKey()) instanceof ComposedSchema)) {
133+
// If we've seen this schema before but find later it should be polymorphic,
134+
// replace the existing schema with this richer version.
135+
if (!componentSchemas.containsKey(entry.getKey()) || !entry.getValue().getClass().equals(componentSchemas.get(entry.getKey()).getClass())) {
139136
componentSchemas.put(entry.getKey(), entry.getValue());
140137
}
141138
}

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/Cat.java renamed to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Cat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package test.org.springdoc.api.app31;
1+
package test.org.springdoc.api.app185;
22

33
import io.swagger.v3.oas.annotations.media.Schema;
44

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/Dog.java renamed to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Dog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package test.org.springdoc.api.app31;
1+
package test.org.springdoc.api.app185;
22

33
import io.swagger.v3.oas.annotations.media.Schema;
44

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/Pet.java renamed to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Pet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package test.org.springdoc.api.app31;
1+
package test.org.springdoc.api.app185;
22

33
import com.fasterxml.jackson.annotation.JsonSubTypes;
44
import com.fasterxml.jackson.annotation.JsonTypeInfo;

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/PetController.java renamed to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/PetController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package test.org.springdoc.api.app31;
1+
package test.org.springdoc.api.app185;
22

33
import org.springframework.web.bind.annotation.GetMapping;
44
import org.springframework.web.bind.annotation.RestController;

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java renamed to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/SpringDocApp185Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package test.org.springdoc.api.app31;
1+
package test.org.springdoc.api.app185;
22

33
import test.org.springdoc.api.AbstractSpringDocTest;
44

55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66

7-
public class SpringDocApp31Test extends AbstractSpringDocTest {
7+
public class SpringDocApp185Test extends AbstractSpringDocTest {
88

99
@SpringBootApplication
1010
static class SpringDocTestApp {}

springdoc-openapi-data-rest/src/test/resources/results/app31.json renamed to springdoc-openapi-webmvc-core/src/test/resources/results/app185.json

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
"title": "OpenAPI definition",
55
"version": "v0"
66
},
7-
"servers": [{
8-
"url": "http://localhost",
9-
"description": "Generated server url"
10-
}],
7+
"servers": [
8+
{
9+
"url": "http://localhost",
10+
"description": "Generated server url"
11+
}
12+
],
1113
"paths": {
1214
"/dog": {
1315
"get": {
14-
"tags": ["pet-controller"],
16+
"tags": [
17+
"pet-controller"
18+
],
1519
"operationId": "getDog",
1620
"responses": {
1721
"200": {
1822
"description": "OK",
1923
"content": {
20-
"application/hal+json": {
24+
"*/*": {
2125
"schema": {
2226
"$ref": "#/components/schemas/Dog"
2327
}
@@ -29,21 +33,27 @@
2933
},
3034
"/any": {
3135
"get": {
32-
"tags": ["pet-controller"],
36+
"tags": [
37+
"pet-controller"
38+
],
3339
"operationId": "getAnyPet",
3440
"responses": {
3541
"200": {
3642
"description": "OK",
3743
"content": {
38-
"application/hal+json": {
44+
"*/*": {
3945
"schema": {
40-
"oneOf": [{
41-
"$ref": "#/components/schemas/Pet"
42-
}, {
43-
"$ref": "#/components/schemas/Cat"
44-
}, {
45-
"$ref": "#/components/schemas/Dog"
46-
}]
46+
"oneOf": [
47+
{
48+
"$ref": "#/components/schemas/Pet"
49+
},
50+
{
51+
"$ref": "#/components/schemas/Cat"
52+
},
53+
{
54+
"$ref": "#/components/schemas/Dog"
55+
}
56+
]
4757
}
4858
}
4959
}
@@ -56,32 +66,40 @@
5666
"schemas": {
5767
"Dog": {
5868
"type": "object",
59-
"allOf": [{
60-
"$ref": "#/components/schemas/Pet"
61-
}, {
62-
"type": "object",
63-
"properties": {
64-
"barks": {
65-
"type": "boolean"
69+
"allOf": [
70+
{
71+
"$ref": "#/components/schemas/Pet"
72+
},
73+
{
74+
"type": "object",
75+
"properties": {
76+
"barks": {
77+
"type": "boolean"
78+
}
6679
}
6780
}
68-
}]
81+
]
6982
},
7083
"Cat": {
7184
"type": "object",
72-
"allOf": [{
73-
"$ref": "#/components/schemas/Pet"
74-
}, {
75-
"type": "object",
76-
"properties": {
77-
"meows": {
78-
"type": "boolean"
85+
"allOf": [
86+
{
87+
"$ref": "#/components/schemas/Pet"
88+
},
89+
{
90+
"type": "object",
91+
"properties": {
92+
"meows": {
93+
"type": "boolean"
94+
}
7995
}
8096
}
81-
}]
97+
]
8298
},
8399
"Pet": {
84-
"required": ["type"],
100+
"required": [
101+
"type"
102+
],
85103
"type": "object",
86104
"properties": {
87105
"name": {
@@ -97,4 +115,4 @@
97115
}
98116
}
99117
}
100-
}
118+
}

0 commit comments

Comments
 (0)