-
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
Multiple responses using oneOf attribute do not appear in UI #3803
Comments
You've left out a bunch of details from the table - please fill them in. We also need a full API definition - we can't really test the issue with the snippet you provided. |
The following spec shows nothing in the responses section of the UI - replacing the oneOf section with just an object containing either of the refs and it works fine.
openapi: 3.0.0
info:
contact:
email: [email protected]
name: No Name
description: Example API
version: 0.0.2
title: example
paths:
"/test":
get:
responses:
'200':
description: OK
content:
application/json:
schema:
oneOf:
- "$ref": "#/definitions/foo"
- "$ref": "#/definitions/bar"
definitions:
foo:
type: string
bar:
type: int |
Similar issue occurs when using oneOf for a request body.
openapi: 3.0.0
info:
title: Test API
version: 0.0.1
servers:
- url: 'localhost:3000/api'
description: Local API URL.
paths:
/test:
get:
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/a'
- $ref: '#/components/schemas/b'
responses:
'200':
description: OK
components:
schemas:
a:
type: integer
b:
type: string |
Hello, I have the exact same problem and this issue still exists in version 3.5. |
I would be glad to see this implemented too. In the current state using multiple responses is not really usable because documentation consumer has to dig into YAML/JSON to find out all this information. |
@shockey I'm confused why this has been tagged as a |
Hey @crussell52, I tagged it as a feature because Swagger-UI hasn't/doesn't support In other news... Work on this stalled (clearly), I'm going to do my best to circle back in January. |
@shockey That makes sense... thanks for the clarification :) |
I am facing the same issue. Using oneOf in requestBody is fine. You can not see the exact example but can still see the model. User can dig inside. However, responses not working. :) Just to share |
i`m facing the same issue |
+1 |
@shockey I want to fix this issue. But I don't know how to do. There are two cases: schema:
type: array
items:
oneOf:
- type: string
- type: integer I can do like this schema:
oneOf:
- $ref: '#/components/schemas/a'
- $ref: '#/components/schemas/b'
components:
schemas:
a:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
b:
type: array
items:
type: integer
format: int64 Or something more complicated like in model tab? What do you think? |
i want the 2 type |
of those I prefer the second one. Since we can name examples in the yaml, would it be a stretch to have example2: |
@DustinOgan this is just two different case for oneOf attribute, for array and for object, and example like I can do. |
For arrays I like the approach to have one example of each item type in the example array. |
I too wish to see some way for Models to display oneOf. It is used in my OpenAPI document. It's not used in a particularly critical API endpoint, but thumbs-up to anybody working on a solution. |
@mikefidel Models in Swagger UI does display oneOf now. We just recently migrated our docs from swagger 2 to open api 3 just for that reason. See this help page: https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/ |
@rickyblaha The spec supports it, but not the UI (unless you're saying bug has been resolved in the UI code?) |
+1 |
any news from maintainers regarding this issue? |
Are there any updates from Swagger team regarding this functionality? |
+1 |
Any news about this issue? |
considering the website of SwaggerUI claims "Complete OAS Support Complete OAS Support Visualize APIs defined in Swagger 2.0 or OAS 3.0" (https://swagger.io/tools/swagger-ui/) and oneOf, anyOf and allOf are clearly part of openApi 3, this should thus be re-categorized as a Bug, or the softwares description be corrected. |
Any update here? Not working for subschemas in responses. |
Any news? |
I am having a similar issue here. See below an example spec in which I am attempting to describe a form which can accept one of two possible schemas: openapi: 3.0.1
info:
title: FooBar
version: 1.0.0
paths:
/foobar:
post:
summary: Summary
requestBody:
content:
application/x-www-form-urlencoded:
schema:
oneOf:
- type: object
properties:
Foo:
type: string
- type: object
properties:
Bar:
type: string
responses:
default:
description: Description
This endpoint should expect to receive a body of either This is not correct. It is representing the form as a JSON payload and causes invalid requests to be sent to the endpoint in which the Swagger UI is encoding each character as a separate form value. E.g. sending a value of This same issue occurs when using When using Are there any updates here regarding the support for such |
+1 to this - My scenario: Disregard above - I found a solution with current version:
|
If anyone is having this problem, I changed to using the latest 4.4.1 version from unpkg and it worked fine.
|
Any news about this? |
Try updating to the last version
…On Tue, Apr 19, 2022 at 7:46 AM EladG77 ***@***.***> wrote:
Any news about this?
—
Reply to this email directly, view it on GitHub
<#3803 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBGPQJ2AETYFBGEQ63F4UDVF2TJBANCNFSM4EALH5VQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hello, Does anyone have a solution or workaround ? |
Any update/workaround for the issue? |
👋 the is a workaround I've found working and built a simple demo: |
I'd like to thank alecnmk for the help with the code. |
@jaredbarranco ' solution worked for me. |
I am also having this issue, @alecnmk solution worked partially, but anyOf is not working at all. |
looks great but for anyone trying to use nestjs swagger module decorators, this unfortunately doesn't seem to apply |
Demonstration API definition
Configuration (browser query string, constructor, config.yaml)
Expected Behavior
Since I have two schemas passed in as a $ref to the 200 response I would expect to see two schemas in the Swagger UI application.
Current Behavior
Instead I see only the reference to the 200 response and its description with no example responses displayed as JSON in the black boxes.
Possible Solution
Context
The text was updated successfully, but these errors were encountered: