Inheritance and Polymorphism in Swagger UI

6,921 views
Skip to first unread message

Edwin Fuquen

unread,
Aug 12, 2013, 11:02:03 AM8/12/13
to swagger-sw...@googlegroups.com
I've implemented the changes to my swagger spec to include the extends and discriminator keywords as described in this document https://gist.github.com/leedm777/5730877

However, when the latest swagger-ui reads it (using develop-2.0 branch) it never pulls in children model onto the display for different rest actions.  For example, if i have a call that returns a model that references Animal, and I have a Cat and Dog class that inherit from it, swagger-ui will only show the Animal model and never the Cat and Dog model.  Is this a known limitation with the current ui, or a bug?  I just want to know if I'm doing something wrong or if this is a feature that has yet to be added?

tony tam

unread,
Aug 12, 2013, 11:22:13 AM8/12/13
to swagger-sw...@googlegroups.com
Should be in today or tomorrow, track here:

Edwin Fuquen

unread,
Aug 12, 2013, 3:01:05 PM8/12/13
to swagger-sw...@googlegroups.com
Very cool, thanks for pointing me to the issue.  One thing, the issue is referencing swagger-core, will an update to swagger-ui to render the models properly come at the same time?  I already am building my json to the swagger spec by hand, so the extends and discriminator keywords are there in the json schema, they just won't show up on the UI.

tony tam

unread,
Aug 12, 2013, 5:29:32 PM8/12/13
to swagger-sw...@googlegroups.com
Just pushed support for subType hints in the swagger-core:


The UI will trail the release of the spec and swagger-core for certain.  But it will get the subtype support.

Edwin Fuquen

unread,
Aug 14, 2013, 1:16:51 PM8/14/13
to swagger-sw...@googlegroups.com
Cool.  To be clear that spec now lincudes a subType field in a model?  For example, the Animal model should include a properly like this:

    ...
    "subTypes": ["Dog", "Cat"],
     ...
}

I ask since I'm generating this json for the spec myself.

tony tam

unread,
Aug 16, 2013, 11:39:55 AM8/16/13
to swagger-sw...@googlegroups.com
That's correct.

hayder Marzouk

unread,
Oct 5, 2013, 5:14:22 AM10/5/13
to swagger-sw...@googlegroups.com
Hi,
Is this feature is already implemented in swagger-ui ?

Thx

levg

unread,
Jan 1, 2014, 3:01:10 AM1/1/14
to swagger-sw...@googlegroups.com
Same question - does swagger-ui support this feature already?

tony tam

unread,
Jan 2, 2014, 10:52:28 AM1/2/14
to swagger-sw...@googlegroups.com
It is not right now.  Finishing oauth2 support then we'll get this worked in.

Chris Smith

unread,
Mar 10, 2014, 9:38:03 AM3/10/14
to swagger-sw...@googlegroups.com
Hi Tony et al.

Can someone point me in the direction of the extends and subtype documentation. I can follow the subtype use, as discussed above, but can't find anything for extends.

Is it as simple as adding:
{
   ....
   "extends" : "model name"
   ....
}

to the model definition?

Cheers!

tony tam

unread,
Mar 18, 2014, 10:43:45 PM3/18/14
to swagger-sw...@googlegroups.com
Hi Chris, we've recently moved the spec documentation to here:


Which has descriptions for the inheritence.

ste...@ziftr.com

unread,
Sep 7, 2014, 11:32:14 PM9/7/14
to swagger-sw...@googlegroups.com
Hi Tony,

What is the status of the "subType" and/or "extends" support for the swagger-ui project?

Thank you,
Stephen M

Ron

unread,
Sep 8, 2014, 4:20:15 AM9/8/14
to swagger-sw...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages