Product Guide

ReadMe Documentation

Welcome to the ReadMe Documentation, where you'll find comprehensive guides and community support to help you start working with ReadMe as quickly as possible!

Get Started
Ask A Question

Questions

7
ANSWERED

No discriminator support in Swagger

I used the `discriminator` feature of Swagger, in combination with `allOf` and `$ref` to create a form of polymorphism in my API spec. * Here's the documentation on the intended use of `discriminator` in Swagger specs: http://swagger.io/specification/#composition-and-inheritance--polymorphism--83 * And here's a more clarifying example: http://swagger.io/specification/#models-with-polymorphism-support-91 I use this in [my own spec](https://github.com/opentripmodel/opentripmodel/blob/master/api/swagger.yaml) a couple of times. It doesn't get rendered right in Readme.io's swagger implementation. The `discriminator` field is rendered as an ordinary text field, whereas it should be rendered as a drop down to select the desired sub type. Also, whenever a subtype is selected, the additional fields defined in that sub type should be rendered as well. Otherwise, there is no way to read the documentation of the sub types, let alone test them. The "Swagger UI" that is provided by the Swagger project itself, doesn't render this right either. However, the [Redoc](https://github.com/Rebilly/ReDoc) documentation template proves that it is perfectly possible to implement this. As a work around, I don't use Readme.io's Swagger support now, but link to a self-hosted website where I host a Redoc-rendered version of my API documentation. Needless to say that it would be much better if I could use Readme.io for this as well, enabling the creation of examples in different languages, Readme.io's excellent feedback options and of course the "try it" functionality, all of which I am missing in my current solution.

Posted by Bart Kummel 3 years ago