-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Ft/3803 multiple responses using one of attribute do not appear in ui #5530
base: master
Are you sure you want to change the base?
Ft/3803 multiple responses using one of attribute do not appear in ui #5530
Conversation
…ribute-do-not-appear-in-UI
…ribute-do-not-appear-in-UI
Merge it please! |
Is this intended to only work with type: "object"
properties:
"options":
oneOf:
- …
- …
oneOf/anyOf can appear at the top level of a schema, too. type: "object"
oneOf:
- …
- … |
openapi: 3.0.1
info:
title: OneOf examples
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
version: 1.0.0
servers:
- url: localhost
paths:
/delivery-addresses/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: string
patch:
summary: Update delivery address
operationId: patchDeleiverAddress
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DeliveryAddress'
application/xml:
schema:
$ref: '#/components/schemas/DeliveryAddress'
responses:
'200':
description: successful operation
x-content:
application/hal-form+json:
schema:
type: object
x-schemaRef: '#/components/schemas/DeliveryAddress'
get:
summary: Read delivery address
operationId: getDeliveryAddress
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/DeliveryAddress'
components:
schemas:
DeliveryAddress:
oneOf:
- type: object
title: Online Delivery
properties:
email:
type: string
example: [email protected]
- type: object
title: Delivery Address
description: OneOf Example
properties:
address:
type: string
city:
type: string
options:
oneOf:
- type: object
title: Delivery Express
required:
- company
properties:
company:
type: string
shipping:
type: string
default: STANDARD
example: STANDARD
x-oneOf:
- const: FAST
title: 24h + EUR 40
- const: STANDARD
title: 3-5 Days
- type: object
title: Parcel Quick
required:
- company
properties:
company:
type: string
x-const: PQ
remarks:
type: string
options2:
oneOf:
- type: object
title: US
properties:
state:
type: string
zipCode:
type: string
required:
- zipCode
- state
- type: object
title: Europe
properties:
county:
type: string
postCode:
type: string
required:
- postCode
|
Interesting. I tried your branch on my spec and couldn't get it to work. Is it because the children of my |
Upps, interesting! I'll try to consider your scenario as well... |
Hi Hannes, |
Cool! What do you think about adding support for discriminator? With my spec this would eliminate the issue that the example value for Also noticed that for lists of documents whose schema has a oneOf, the examples only represent a partial set of properties. The "manually selected" UI element also doesn't populate a list of alternatives but I'm not sure that is needed here. It may make more sense to simply select the first alternative for the first document, the second alternative for the second document and so on. |
The above screen shot is from the 200 response for the |
@desponda I think I'm incorrectly mentioned here :-) |
+1 for xml! https://bintray.com/soberich/maven/com.github.soberich%3Aswagger-ui |
Great to see some activities around :-) |
Hi @VIIgit Thanks for taking the time and implementing a solution for oneOf directive. Not Working schema
Scenario where is it working
|
Hi @faraazbrcm |
…ribute-do-not-appear-in-UI
Any plan to get this merged ? :) |
…ribute-do-not-appear-in-UI
Any update on whether this could get merged? We came up against this limitation recently and it would be really nice to have this supported. |
I really need this fix, please merge it. |
ping |
May also solve #6540 |
Any idea when this will merge? |
For goodness sake, maintainers, speak up! If lack of XML support is holding this up, please reconsider. Who cares if this improvement is only available for JSON, not XML? Right now its implemented for neither so this would be a clear improvement. Omitting XML support does not accrue any new debt so insisting that it be added make no sense. In my opinion. |
Are there any plans to merge and release this anytime soon? |
Please supply us with an update on this. The feature request has been dragging on for 3+ years... |
They are probably too busy redistributing profits from becoming a specification still. Maybe the phrase will get attention to get this merged ) |
@VIIgit it's sad to see this awesome work go to waste... have you considered turning this into a plugin instead of a base preset? then people would be able to actually use this without depending on swagger-ui |
Yes, I've started with a plugin, but it was not possible due to missing or not accessible context data within the plugin. So I've decided to fix it in the core. |
When you say "context data" what do you mean exactly? |
I envy your patience, Erwin. |
+1 |
+1 , and dont undestand why this 3 yeas old bug isnt fixed, when there are clearly pull requests pending .. |
+1, is there any timeline for the above merge proposal? Thank you |
+1 |
Description
Display oneOf/anyOf schema in Example View.
showAlternativeSchemaExample: false
)oneOf:
anyOf:
Not yet supported/considered:
Motivation and Context
Fixes #3803 Multiple responses using oneOf attribute do not appear in UI
How Has This Been Tested?
Swagger to demonstrate the feature
Screenshots:
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests