File tree Expand file tree Collapse file tree 3 files changed +61
-2
lines changed
main/java/io/swagger/v3/core/util
test/java/io/swagger/v3/core/resolving
swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2 Expand file tree Collapse file tree 3 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public static AnnotatedType unwrapOptional(AnnotatedType type) {
4242 .name (type .getName ())
4343 .parent (type .getParent ())
4444 .jsonUnwrappedHandler (type .getJsonUnwrappedHandler ())
45- .skipOverride (true )
45+ .skipOverride (type . isSkipOverride () )
4646 .schemaProperty (type .isSchemaProperty ())
4747 .ctxAnnotations (type .getCtxAnnotations ())
4848 .resolveAsRef (type .isResolveAsRef ())
Original file line number Diff line number Diff line change 1+ package io .swagger .v3 .core .resolving ;
2+
3+ import io .swagger .v3 .core .converter .AnnotatedType ;
4+ import io .swagger .v3 .core .converter .ModelConverterContextImpl ;
5+ import io .swagger .v3 .core .jackson .ModelResolver ;
6+ import io .swagger .v3 .core .matchers .SerializationMatchers ;
7+ import io .swagger .v3 .oas .models .media .Schema ;
8+ import org .testng .annotations .Test ;
9+
10+ import java .util .Optional ;
11+
12+ public class Ticket3703Test extends SwaggerTestBase {
13+
14+ @ Test
15+ public void testSelfReferencingOptional () throws Exception {
16+
17+ final ModelResolver modelResolver = new ModelResolver (mapper ());
18+
19+ ModelConverterContextImpl context = new ModelConverterContextImpl (modelResolver );
20+
21+ Schema model = context
22+ .resolve (new AnnotatedType (ModelContainer .class ));
23+
24+ SerializationMatchers .assertEqualsToYaml (context .getDefinedModels (), "Model:\n " +
25+ " type: object\n " +
26+ " properties:\n " +
27+ " model:\n " +
28+ " $ref: '#/components/schemas/Model'\n " +
29+ "ModelContainer:\n " +
30+ " type: object\n " +
31+ " properties:\n " +
32+ " model:\n " +
33+ " $ref: '#/components/schemas/Model'\n " +
34+ " bytes:\n " +
35+ " type: string\n " +
36+ " format: byte" );
37+
38+ }
39+
40+ static class ModelContainer {
41+ public Optional <Model > model ;
42+
43+ @ io .swagger .v3 .oas .annotations .media .Schema (type = "string" , format = "byte" )
44+ public Optional <Bytes > getBytes () {
45+ return null ;
46+ }
47+
48+ }
49+
50+ static class Model {
51+ public Optional <Model > model ;
52+ }
53+
54+ static class Bytes {
55+ public String foo ;
56+ public String bar ;
57+ }
58+
59+ }
Original file line number Diff line number Diff line change @@ -2248,7 +2248,7 @@ public void testTicket3587() {
22482248 SerializationMatchers .assertEqualsToYamlExact (openAPI , yaml );
22492249 }
22502250
2251- @ Test (description = "Optional hanlding " )
2251+ @ Test (description = "Optional handling " )
22522252 public void testTicket3624 () {
22532253 Reader reader = new Reader (new OpenAPI ());
22542254
You can’t perform that action at this time.
0 commit comments