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

allOf in $ref schema doesn't render properly #2765

Open
karlismelderis opened this issue Aug 25, 2021 · 3 comments
Open

allOf in $ref schema doesn't render properly #2765

karlismelderis opened this issue Aug 25, 2021 · 3 comments

Comments

@karlismelderis
Copy link

Q&A (please complete the following information)

used online version: https://editor.swagger.io/

  • OS: macOS
  • Browser: chrome

Content & configuration

Example Swagger/OpenAPI definition:

components:
    schemas:
      evidenceA:
        properties:
          anotherA:
            type: string
        type: object
      evidenceB:
        allOf:
          - properties:
              anotherB:
                type: string
            type: object
      Demo:
          properties:
              evidenceB:
                $ref: '#/components/schemas/evidenceB'
              evidenceA:
                $ref: '#/components/schemas/evidenceA'
          type: object
      ResponseBody:
          properties:
              _embedded:
                  $ref: '#/components/schemas/Demo'
          required:
              - _embedded
          type: object
info:
    title: 'test'
    version: 3.4.0
    description: 'Demo'
    contact: {}
openapi: 3.0.0
paths:
    '/test':
        put:
            responses:
                '200':
                    description: 'Update or Create'
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/ResponseBody'
            requestBody:
                required: true
                content:
                    application/json:
                        schema:
                            $ref: '#/components/schemas/Demo'

Describe the bug you're encountering

if $ref schema has allOf in it final schema is not rendered correctly. UI shows empty object and renders as string.

Screenshots

Screen Shot 2021-08-25 at 8 45 46 AM

Additional context or thoughts

@shj95
Copy link

shj95 commented Nov 27, 2021

I'm having same issue. Is there any workaround?

@aarbmx6s
Copy link

aarbmx6s commented Feb 8, 2022

I have the same problem.

@karlismelderis did you figure out this issue?

An example of document:

openapi: 3.0.1

info:
  version: 1.0.0
  title: API
  description: Test

components:
  schemas:
    ItemSimple:
      type: object
      properties:
        id:
          type: string

    GroupTitle:
      type: object
      properties:
        title:
          type: string

    GroupListItem:
      type: object
      properties:
        merged:
          allOf:
            - $ref: '#/components/schemas/ItemSimple'
            - type: object
              properties:
                extra:
                  type: string
            
    Group:
      type: object
      properties:
        title:
          $ref: '#/components/schemas/GroupTitle'
        list:
          type: array
          items:
            $ref: '#/components/schemas/GroupListItem'

paths:
  /path:
    get:
      summary: Some path
      responses:
        200:
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Group'

If allOf property change to anyOf or oneOf it recognises and renders as expected, but with allOf property it renders as string but expected to be a merged object.

image

@alexey-salmin-navee
Copy link

Moving paths above components seem to help.

https://stackoverflow.com/questions/69906612/swagger-example-response-not-respecting-nested-allof
swagger-api/swagger-ui#5972

Probably swagger-ui is a better repo for this bug, it's rendering of documentation that is buggy, not the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants