Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of discriminator field is broken #195

Closed
andrewjtech123 opened this issue Feb 1, 2017 · 9 comments
Closed

use of discriminator field is broken #195

andrewjtech123 opened this issue Feb 1, 2017 · 9 comments

Comments

@andrewjtech123
Copy link

we have been using discriminator field to indicate custom vs. regular object (with different attributes and required fields depending on how discriminator is set (true or false). This functionality is now broken.

descriminator

not possible to select true or false any longer from the dropdown.

@RomanHotsiy
Copy link
Member

@andrewjtech123 discriminator is not broken in ReDoc. Your spec is invalid.

You use discriminator incorrectly:

The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it.

If you want to have true and false in discriminator you have to have definitions with the same name. I can't see such definitions in your spec.
Also discriminator field technically must be string as it MUST be the NAME of this schema or any schema that inherits it.

Having top-level definition with name true is an ugly idea but It's just how OpenAPI/Swagger discriminator works.
To fix this issue, I have implemented special vendor extension BUT you should understand that only ReDoc will use it.
It is not documented yet. Let me know if you are interested in this so I can document.
I am closing this issue. But you are welcome to post your questions here

@andrewjtech123
Copy link
Author

Hi @RomanGotsiy yes I would be very interested in the vendor extension. I was never happy with the way i "hacked" the spec to do this, so I'm not surprised that it stopped working.

@andrewjtech123
Copy link
Author

hay @RomanGotsiy is there a link or some info you can send me on this ? we have a public beta starting soon and I need to get the fix in

@RomanHotsiy
Copy link
Member

RomanHotsiy commented Feb 2, 2017

Here is an example spec using this vendor extension: https://gist.github.com/a62b1dc9324b99a689c31c8411844d09#file-extendedDiscriminator-yaml

Would be great If you manage to get guts out of it yourself. I am too busy today to document this detailed.
I'm going to document this till the end of the week though

@RomanHotsiy
Copy link
Member

@andrewjtech123 updated previous post with a correct link

@RomanHotsiy
Copy link
Member

hey @andrewjtech123, did you manage to hack the spec as you needed using that vendor-extension ?

@andrewjtech123
Copy link
Author

hi @RomanGotsiy . I was able to play around with discriminator to get it to do something that works for now. latest version in the repo should have it. Thanks for checking in ! https://andrewjtech123.github.io/rebilly-validschema/

@RomanHotsiy
Copy link
Member

Great. I'm glad you managed to get that working. I've seen you published it as a public beta on Shopify docs 🎉

I will let you know once I'm done with documenting x-extendedDiscriminator

@RomanHotsiy
Copy link
Member

Hey @andrewjtech123,
I'm just done with documenting x-extendedDiscriminator.

Hope it will be helpful:
https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md#x-extendeddiscriminator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants