File tree 2 files changed +46
-0
lines changed
modules/swagger-parser/src/test
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1
1
package io .swagger .parser ;
2
2
3
+ import com .fasterxml .jackson .databind .node .ObjectNode ;
3
4
import io .swagger .matchers .SerializationMatchers ;
4
5
import io .swagger .models .*;
5
6
import io .swagger .models .parameters .Parameter ;
@@ -354,4 +355,24 @@ public void testIssue364() {
354
355
assertTrue (pathParameter .isReadOnly ());
355
356
assertTrue (pathParameter .getAllowEmptyValue ());
356
357
}
358
+
359
+ @ Test (description = "it should read an example within an inlined schema" )
360
+ public void testIssue1261InlineSchemaExample () {
361
+ final SwaggerParser parser = new SwaggerParser ();
362
+ final Swagger swagger = parser .read ("issue-1261.yaml" );
363
+
364
+ Path path = swagger .getPath ("/user" );
365
+ assertNotNull (path );
366
+ Operation get = path .getGet ();
367
+ assertNotNull (get );
368
+ assertTrue (get .getResponses ().size () == 1 );
369
+ Response response = get .getResponses ().get ("200" );
370
+ Property schema = response .getSchema ();
371
+ Object example = schema .getExample ();
372
+ assertNotNull (example );
373
+ assertTrue (example instanceof ObjectNode );
374
+ ObjectNode objectNode = (ObjectNode ) example ;
375
+ assertEquals (objectNode .get ("id" ).intValue (), 42 );
376
+ assertEquals (objectNode .get ("name" ).textValue (), "Arthur Dent" );
377
+ }
357
378
}
Original file line number Diff line number Diff line change
1
+ swagger : ' 2.0'
2
+ info :
3
+ version : " 1"
4
+ title : Inline schema example
5
+
6
+ paths :
7
+ /user :
8
+ get :
9
+ produces :
10
+ - application/json
11
+ responses :
12
+ 200 :
13
+ description : OK
14
+ schema :
15
+ type : object
16
+ properties :
17
+ id :
18
+ type : integer
19
+ format : int32
20
+ name :
21
+ type : string
22
+ required : [id, name]
23
+ example :
24
+ id : 42
25
+ name : Arthur Dent
You can’t perform that action at this time.
0 commit comments