Redocly / redoc

📘 OpenAPI/Swagger-generated API Reference Documentation
https://redocly.github.io/redoc/
MIT License
23.44k stars 2.29k forks source link

Discriminator support in JSON samples #459

Open ben-foster-cko opened 6 years ago

ben-foster-cko commented 6 years ago

Are there plans, following the upgrade to 2.0 to support discriminated fields in JSON payloads? Currently these are not included in the examples.

trip-somers commented 6 years ago

I also have this question. This would be a great feature that would allow people to maintain their examples just by documenting/updating their requests and responses.

The current alternative/work-around is to explicitly define examples for each discriminator choice which is obviously cumbersome from a documentation maintenance perspective.

That said, I'm sure this isn't a small request. It would be nice to know if it's on the road map and/or when it might be prioritized. Given the current state of the examples in my documentation, I would likely be able to contribute to this on-the-clock. :-)

trip-somers commented 6 years ago

Digging into this a bit, it looks like it works if you define the request body as a oneOf, but not if a sub-object has a discriminator.

UPDATE: Nope. That's not quite right either. I tried some things based on what the OP of this thread -- https://github.com/Rebilly/ReDoc/issues/524 -- was able to achieve, but I could not duplicate his results.

jim5359 commented 6 years ago

For me, the models work perfectly for discriminator. But the examples do not work if the sub-object has a discriminator. See example attached. The result is the same for both requests and responses.

redoc-product-api

cmeeren commented 6 years ago

I too experience problems when using oneOf on a sub-object (with or without a discriminator doesn't matter).

tjf commented 5 years ago

@RomanGotsiy Any thoughts or updates on this?

sayanroy7 commented 5 years ago

Anyone has any update or example of how to achieve this?

atte-backman commented 5 years ago

Yes, this is a bit annoying. Any plans going on tackling this one?

toby-knott-cko commented 5 years ago

@RomanHotsiy Has there been any progress on this?

epark-brex commented 2 years ago

Bump!