Skip to content

Commit 5af7e9b

Browse files
committed
Revert "fix: StackOverflowError with recursive data model #4852"
This reverts commit 13e287a.
1 parent 13e287a commit 5af7e9b

File tree

4 files changed

+15
-51
lines changed

4 files changed

+15
-51
lines changed

modules/swagger-core/src/main/java/io/swagger/v3/core/util/PrimitiveType.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public DateSchema createProperty() {
198198
}
199199
@Override
200200
public Schema createProperty31() {
201-
return new JsonSchema().typesItem("string").type("string").format("date");
201+
return new JsonSchema().typesItem("object").type("object").format("date");
202202
}
203203
},
204204
DATE_TIME(java.util.Date.class, "date-time") {
@@ -208,7 +208,7 @@ public DateTimeSchema createProperty() {
208208
}
209209
@Override
210210
public Schema createProperty31() {
211-
return new JsonSchema().typesItem("string").type("string").format("date-time");
211+
return new JsonSchema().typesItem("object").type("object").format("date-time");
212212
}
213213
},
214214
PARTIAL_TIME(java.time.LocalTime.class, "partial-time") {
@@ -218,7 +218,7 @@ public Schema createProperty() {
218218
}
219219
@Override
220220
public Schema createProperty31() {
221-
return new JsonSchema().typesItem("string").type("string").format("partial-time");
221+
return new JsonSchema().typesItem("object").type("object").format("partial-time");
222222
}
223223
},
224224
FILE(java.io.File.class, "file") {
@@ -572,7 +572,7 @@ private static <K> void addMultiKeys(Map<K, Collection<PrimitiveType>> map, Prim
572572
}
573573
}
574574

575-
private static class DateStub {
575+
public static class DateStub {
576576
private DateStub() {
577577
}
578578
}

modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket2992Test.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,6 @@ public void testLocalTime() throws Exception {
1818

1919
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
2020

21-
Schema model = context
22-
.resolve(new AnnotatedType(TestObject2992.class));
23-
24-
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "LocalTime:\n" +
25-
" type: object\n" +
26-
" properties:\n" +
27-
" hour:\n" +
28-
" type: integer\n" +
29-
" format: int32\n" +
30-
" minute:\n" +
31-
" type: integer\n" +
32-
" format: int32\n" +
33-
" second:\n" +
34-
" type: integer\n" +
35-
" format: int32\n" +
36-
" nano:\n" +
37-
" type: integer\n" +
38-
" format: int32\n" +
39-
"TestObject2992:\n" +
40-
" type: object\n" +
41-
" properties:\n" +
42-
" name:\n" +
43-
" type: string\n" +
44-
" a:\n" +
45-
" $ref: \"#/components/schemas/LocalTime\"\n" +
46-
" b:\n" +
47-
" $ref: \"#/components/schemas/LocalTime\"\n" +
48-
" c:\n" +
49-
" $ref: \"#/components/schemas/LocalTime\"\n" +
50-
" d:\n" +
51-
" type: string\n" +
52-
" format: date-time\n" +
53-
" e:\n" +
54-
" type: string\n" +
55-
" format: date-time\n" +
56-
" f:\n" +
57-
" type: string\n" +
58-
" format: date-time");
59-
60-
PrimitiveType.enablePartialTime();
61-
context = new ModelConverterContextImpl(modelResolver);
62-
6321
context
6422
.resolve(new AnnotatedType(TestObject2992.class));
6523

modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/APIResponsesResourceTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ private Schema getResponseSchema(String path) {
5555
public void testSchemaAPIResource31(String schema) {
5656
Schema responseSchema = getResponseSchema(schema);
5757

58-
// Debug output for type and types
59-
System.out.println("Schema path: " + schema);
60-
System.out.println("type: " + responseSchema.getType());
61-
System.out.println("types: " + responseSchema.getTypes());
62-
6358
// Value of field "type" must equal value of field "types"
6459
assertEquals(responseSchema.getType(), responseSchema.getTypes().iterator().next());
6560
}

modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/resources/APIResponsesResource.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.swagger.v3.jaxrs2.resources;
22

3+
import io.swagger.v3.core.util.PrimitiveType;
34
import io.swagger.v3.oas.annotations.media.Content;
45
import io.swagger.v3.oas.annotations.media.Schema;
56
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -147,6 +148,16 @@ public void postBigDecimalSchemaContent() { }
147148
})
148149
public void postNumberSchemaContent() { }
149150

151+
@POST
152+
@Path("postDateStubSchemaContent")
153+
@ApiResponses({
154+
@ApiResponse(
155+
responseCode = "200",
156+
content = @Content(schema = @Schema(implementation = PrimitiveType.DateStub.class))
157+
)
158+
})
159+
public void postDateStubSchemaContent() { }
160+
150161
@POST
151162
@Path("postDateSchemaContent")
152163
@ApiResponses({

0 commit comments

Comments
 (0)