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

Multiple oneOf tags not rendering 2.0.0-alpha.29 #569

Open
viralanomaly opened this issue Jul 19, 2018 · 5 comments
Open

Multiple oneOf tags not rendering 2.0.0-alpha.29 #569

viralanomaly opened this issue Jul 19, 2018 · 5 comments
Labels
openapi Questions about specification, validity, and edge cases Type: Bug

Comments

@viralanomaly
Copy link
Contributor

I am using "redoc": "2.0.0-alpha.29".

I have pasted a stripped down version of my api that shows what is happening. I was expecting both sets of choices (the oneOfs) from RequestObject to be rendered, but instead I only get Single Piece Identifier and (IdentifierPart1 and IdentifierPart2). There should be another "One Of" line with another set of buttons for the choice in "ObjectWithAnotherOneOf", and "OtherThing" should be rendered all the time. Nothing from ObjectWithAnotherOneOf is being rendered.

I hope this is clear enough of an example!

openapi: 3.0.1
info:
  version: 0.0.1
  title: My RESTful API
servers:
- url: /blah
  description: Development server running locally
paths:
  /thing1:
    post:
      tags:
        - Thing1
      summary: Thing1
      description: All about Thing1
      operationId: api.thing1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestObject'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseObject'
components:
  schemas:
    ObjectWithAnotherOneOf:
      allOf:
        - oneOf:
          - $ref: '#/components/schemas/Detail2'
          - $ref: '#/components/schemas/Detail1'
        - $ref: '#/components/schemas/OtherThing'
    OtherThing:
      type: object
      properties:
        details:
          type: string
          description: Placeholder for minimum reproduction
    IdentifierPart1:
      type: object
      properties:
        part1:
          type: string
    IdentifierPart2:
      type: object
      properties:
        part2:
          type: string
    IdentifierPart2Identifier:
      oneOf:
        - $ref: '#/components/schemas/SinglePieceIdentifier'
        - allOf:
          - title: IdentifierPart1 and IdentifierPart2
          - $ref: '#/components/schemas/IdentifierPart1'
          - $ref: '#/components/schemas/IdentifierPart2'
    SinglePieceIdentifier:
      type: object
      title: SinglePieceIdentifier
      properties:
        myIdentifier:
          type: string
    RequestObject:
      allOf:
        - $ref: '#/components/schemas/IdentifierPart2Identifier'
        - $ref: '#/components/schemas/ObjectWithAnotherOneOf'
        - $ref: '#/components/schemas/AnotherDataPiece'
    ResponseObject:
      type: object
      properties:
        details:
          type: string
          description: Placeholder for minimum reproduction
    AnotherDataPiece:
      type: object
      properties:
        dataPiece:
          type: string
    Detail1:
      type: object
      title: Detail 1
      properties:
        detail1:
          type: boolean
          description: Placeholder for minimum reproduction
    Detail2:
      type: object
      title: Detail 2
      properties:
        detail2:
          type: boolean
          description: Placeholder for minimum reproduction
  securitySchemes:
    bearerAuth:
      description: >
        All services must use this method of authentication after a
        successful [Login](#operation/login)
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
  - bearerAuth: []

@viralanomaly viralanomaly changed the title Multiple oneOf tags not rendering Multiple oneOf tags not rendering 2.0.0-alpha.29 Jul 19, 2018
@RomanHotsiy
Copy link
Member

Got the issue. It's not so obvious how to fix it 😞.
I will check it once I have some time.

Until this is fixed try to omit cases when you have reference to scheme with top level oneOf inside of allOf. Instead tyr inlining oneOf directly into allOf:

But I'm curious, did it use to work with alpha.28 😐?

@viralanomaly
Copy link
Contributor Author

viralanomaly commented Jul 19, 2018 via email

@viralanomaly
Copy link
Contributor Author

Same behavior with 28. I had cleaned up my spec for the allOf and oneOf changes you put in, and the before for that cleanup might have hidden this issue.

@viralanomaly
Copy link
Contributor Author

I can do it this way as a workaround, but I was hoping to not have to repeat ObjectWithAnotherOneOf everywhere now.


openapi: 3.0.1
info:
  version: 0.0.1
  title: My RESTful API
servers:
- url: /blah
  description: Development server running locally
paths:
  /thing1:
    post:
      tags:
        - Thing1
      summary: Thing1
      description: All about Thing1
      operationId: api.thing1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestObject'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseObject'
components:
  schemas:
    ObjectWithAnotherOneOf:
      allOf:
        - oneOf:
          - $ref: '#/components/schemas/Detail2'
          - $ref: '#/components/schemas/Detail1'
        - $ref: '#/components/schemas/OtherThing'
    OtherThing:
      type: object
      properties:
        details:
          type: string
          description: Placeholder for minimum reproduction
    IdentifierPart1:
      type: object
      properties:
        part1:
          type: string
    IdentifierPart2:
      type: object
      properties:
        part2:
          type: string
    IdentifierPart2Identifier:
      oneOf:
        - allOf:
          - $ref: '#/components/schemas/SinglePieceIdentifier'
          - $ref: '#/components/schemas/ObjectWithAnotherOneOf'
        - allOf:
          - title: IdentifierPart1 and IdentifierPart2
          - $ref: '#/components/schemas/IdentifierPart1'
          - $ref: '#/components/schemas/IdentifierPart2'
          - $ref: '#/components/schemas/ObjectWithAnotherOneOf'
    SinglePieceIdentifier:
      type: object
      title: SinglePieceIdentifier
      properties:
        myIdentifier:
          type: string
    RequestObject:
      allOf:
        - $ref: '#/components/schemas/IdentifierPart2Identifier'
        - $ref: '#/components/schemas/AnotherDataPiece'
    ResponseObject:
      type: object
      properties:
        details:
          type: string
          description: Placeholder for minimum reproduction
    AnotherDataPiece:
      type: object
      properties:
        dataPiece:
          type: string
    Detail1:
      type: object
      title: Detail 1
      properties:
        detail1:
          type: boolean
          description: Placeholder for minimum reproduction
    Detail2:
      type: object
      title: Detail 2
      properties:
        detail2:
          type: boolean
          description: Placeholder for minimum reproduction
  securitySchemes:
    bearerAuth:
      description: >
        All services must use this method of authentication after a
        successful [Login](#operation/login)
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
  - bearerAuth: []

@lornajane lornajane added the openapi Questions about specification, validity, and edge cases label Jul 26, 2023
@lornajane
Copy link
Contributor

This behaviour is still present in the current release. We need to decide how this should look, perhaps we can take the existing oneOf rendering which uses the component names as labels, and make it clear that some of the fields are always there, and are siblings to the oneOf representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi Questions about specification, validity, and edge cases Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants