Dereferencing $ref string from Body parameter

14 views
Skip to first unread message

shreeji...@gmail.com

unread,
May 30, 2016, 1:20:19 PM5/30/16
to Swagger
Taking the petstore example,

I am trying to dereference the $Ref in the /pet -> put operation which is currently:
$ref: #definitions/Pet

I am trying to resolve this but unable to get this text out from the json file.
This is what I have:

BodyParameter bp = (BodyParameter) param;
System.out.println(((RefModel) bp.getSchema()).get$ref());

I thought this would give me the above text out which I could later map with  a definition Map and resolve it but got the following error:

Exception in thread "main" java.lang.ClassCastException: io.swagger.models.ModelImpl cannot be cast to io.swagger.models.RefModel

Would anyone know of a way to extract this string out from a body parameter?

Reply all
Reply to author
Forward
0 new messages