Support dropdown for discriminator#10224
Support dropdown for discriminator#10224YousefHaggy wants to merge 6 commits intoswagger-api:masterfrom
Conversation
| getConfigs={ getConfigs } | ||
| isExecute={ isExecute } | ||
| specSelectors={ specSelectors } | ||
| specActions={ specActions } |
There was a problem hiding this comment.
Is there a better way to get specAction down to model-wrapper.jsx than plumbing it down everywhere like this? I couldn't find a context provider with specActions in the hierarchy
src/style/_models.scss
Outdated
There was a problem hiding this comment.
for OAS 3.0.X, the model is inline with the dropdown if we don't specify this
|
@char0n Could I get you or another maintainers review on this? Thanks! |
23368f0 to
55fb35d
Compare
|
Hi @YousefHaggy thank you for taking the time to create this. I think it would be great to get a selector to change between discriminator types. There are a bunch of edge-cases to consider, including discriminator resolving which hasn't been addressed. It's something new that popped up with 3.0.4/3.1.1 versions of OpenAPI Specification. We will take a look when we can to help move this forward, thanks for your patience here! |
|
@ponelat Thanks for your reply. I'm happy to work on testing and addressing the edge cases associated with discriminator. Wanted to see if this selector idea had traction before jumping down the rabbit hole :) While this PR doesn't factor in the edge cases, it does address imo the most popular and common manifestation of allOf / discriminator polymorphism. It addresses the example provided in the Github issue as well as some examples in the OAS 3.1.1 official spec What do you think about exposing this current fix behind a configuration parameter, |
|
Hi @YousefHaggy, Thank you for your contribution. We’ve decided to close this PR, as we will be handling the processing of the discriminator in ApiDOM with proper dereferencing and normalization. We are currently working on a proof of concept to handle it there. |
Fixes #2438 and adds a dropdown to select between schemas that extend a base schema via allOf with discriminator
Sample spec:
spec.json
Description
Motivation and Context
OpenAPI spec supports inheritance via allOf and discriminator, but currently in Swagger UI when you reference a schema that is extended with allOf, there's no indication of this inheritance and valid child schemas a user can input. Provides a poor user experience for specs that rely on this kind of structure
This works in other tools like Redoc: https://github.com/Rebilly/ReDoc/blob/master/docs/images/discriminator-demo.gif
Fixes #2438. Solves a very common allOf usecase, some examples in the OAS 3.1.1 official spec
How Has This Been Tested?
I've manually tested this change using the attached sample spec. I tested for both 3.0 and 3.1. I tested a spec with no explicit mappings, all explicit mappings, and a mix
spec.json
Ran all existing unit tests successfully. Tried to run
npm run e2eas the README.md says, but no script e2e existsScreenshots (if appropriate):
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests