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

oneOf, anyOf not works #4819

Closed
kalinick opened this issue Aug 17, 2018 · 9 comments

Comments

@kalinick
Copy link

commented Aug 17, 2018

Q&A (please complete the following information)

  • OS: macOS
  • Browser: [chrome, safari]
  • Method of installation: dist assets
  • Swagger-UI version: 3.18.1
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0

Content & configuration

oneOf, anyOf not works

Example Swagger/OpenAPI definition:

  /v2/teams/{id}:
    delete:
      tags:
      - Teams
      summary: Delete a team
      parameters:
      - in: path
        name: id
        required: true
        type: string
        allowEmptyValue: false
      responses:
        204:
    get:
      tags:
      - Teams
      summary: Get a team by id
      parameters:
      - in: path
        name: id
        required: true
        type: string
        allowEmptyValue: false
      responses:
        200:
          schema:
            oneOf:
              - $ref: "#/definitions/Team1"
              - $ref: "#/definitions/Team2"

Expected behavior

oneOf, anyOf works

Screenshots

image

@hkosova

This comment has been minimized.

Copy link
Collaborator

commented Aug 17, 2018

Thanks for the report! This issue is already being tracked in #3803.

Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0

Just FYI, oneOf and anyOf are an OpenAPI 3.0 feature and are not supported in Swagger 2.0.

@kalinick

This comment has been minimized.

Copy link
Author

commented Aug 17, 2018

If, I'm trying to set swagger version > 2.0 it shows me this error
image

@hkosova

This comment has been minimized.

Copy link
Collaborator

commented Aug 17, 2018

It should be openapi: 3.0.0 not swagger: '3.0'

@kalinick

This comment has been minimized.

Copy link
Author

commented Aug 17, 2018

this is my general.yaml
swagger: '2.0'
openapi: '3.0'
and I have swagger-ui version 3.18.1

@hkosova

This comment has been minimized.

Copy link
Collaborator

commented Aug 17, 2018

@kalinick openapi: '3.0' is not valid, it should be openapi: 3.0.0 with the three-digit version number - as explained in the help text on your image. And remove swagger: '2.0'.

Check out the OpenAPI 3.0 syntax guide.

@kalinick

This comment has been minimized.

Copy link
Author

commented Aug 20, 2018

set in general.yaml
openapi: '3.0.0'

set path:
/v2/teams/{id}/full:
get:
tags:
- Teams
summary: Get a team by id
responses:
'200':
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/FullTeam"

it's not works
image

but works

/v2/teams/{id}/full:
get:
tags:
- Teams
summary: Get a team by id
responses:
'200':
content:
application/json:
schema:
$ref: "#/components/schemas/FullTeam"

image

@shockey

This comment has been minimized.

Copy link
Member

commented Aug 20, 2018

@kalinick, as mentioned above, oneOf is not currently supported in Swagger UI - you can follow
#3803 for updates on that feature 😄

@kalinick

This comment has been minimized.

Copy link
Author

commented Aug 21, 2018

Thanks for your support, will be looking forward to the release of this feature :)

@shockey

This comment has been minimized.

Copy link
Member

commented Aug 22, 2018

Glad we could help!

Closing this out in favor of #3803.

@shockey shockey closed this Aug 22, 2018

@lock lock bot added the locked-by: lock-bot label Aug 22, 2019

@lock lock bot locked and limited conversation to collaborators Aug 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.