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

Rendering of nested objects break when using allOf in the main schema #8374

Open
Rutix opened this issue Feb 8, 2023 · 3 comments · Fixed by swagger-api/swagger-js#2844
Open

Comments

@Rutix
Copy link

Rutix commented Feb 8, 2023

Q&A (please complete the following information)

  • OS: Windows/OSX/Ubuntu
  • Browser: Edge
  • Version: Version 109.0.1518.78 (Official build) (64-bit)
  • Method of installation: npm (but also happens in online editor)
  • Swagger-UI version: v4.15.5
  • Swagger/OpenAPI version: OpenApi 3.0.1

Content & configuration

Broken example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: Testapi
  version: v1
paths: {}
components:
  schemas:
    SubjectBase:
      type: object
      properties:
        naam:
          type: string
          nullable: true
    TestSubject:
      required:
        - $type
      type: object
      allOf:
        - $ref: '#/components/schemas/SubjectBase'
      properties:
        sum:
          allOf:
            - $ref: '#/components/schemas/PeriodicGegevenAmount'
          description: One time payment
          nullable: true
      additionalProperties: false
      description: Test class
      discriminator:
        propertyName: $type
    Percentage:
      required:
        - amount
      type: object
      properties:
        amount:
          maximum: 100
          minimum: -100
          type: number
          format: double
      additionalProperties: false
    Periodic:
      required:
        - $type
        - einddatum
        - ingangsdatum
      type: object
      properties:
        startdate:
          type: string
          format: date
        enddate:
          type: string
          format: date
      additionalProperties: false
      discriminator:
        propertyName: $type
    PeriodicAmount:
      required:
        - $type
      type: object
      allOf:
        - $ref: '#/components/schemas/Periodic'
      properties:
        factor:
          allOf:
            - $ref: '#/components/schemas/Percentage'
          nullable: true
      additionalProperties: false
      discriminator:
        propertyName: $type
    PeriodicGegevenAmount:
      required:
        - isWaardevast
        - periodieken
      type: object
      properties:
        periodieken:
          type: array
          items:
            $ref: '#/components/schemas/PeriodicAmount'
        isWaardevast:
          type: boolean
      additionalProperties: false
      description: The amount and period to which this amount applies

Working example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: Testapi
  version: v1
paths: {}
components:
  schemas:
    SubjectBase:
      type: object
      properties:
        naam:
          type: string
          nullable: true
    TestSubject:
      required:
        - $type
      type: object
      allOf:
        - $ref: '#/components/schemas/SubjectBase'
      properties:
        sum:
          allOf:
            - $ref: '#/components/schemas/PeriodicGegevenAmount'
          description: One time payment
          nullable: true
      additionalProperties: false
      description: Test class
      discriminator:
        propertyName: $type
    Percentage:
      required:
        - amount
      type: object
      properties:
        amount:
          maximum: 100
          minimum: -100
          type: number
          format: double
      additionalProperties: false
    Periodic:
      required:
        - $type
        - einddatum
        - ingangsdatum
      type: object
      properties:
        startdate:
          type: string
          format: date
        enddate:
          type: string
          format: date
      additionalProperties: false
      discriminator:
        propertyName: $type
    PeriodicAmount:
      required:
        - $type
      type: object
      allOf:
        - $ref: '#/components/schemas/Periodic'
      properties:
        factor:
          allOf:
            - $ref: '#/components/schemas/Percentage'
          nullable: true
      additionalProperties: false
      discriminator:
        propertyName: $type
    PeriodicGegevenAmount:
      required:
        - isWaardevast
        - periodieken
      type: object
      properties:
        periodieken:
          type: array
          items:
            $ref: '#/components/schemas/PeriodicAmount'
        isWaardevast:
          type: boolean
      additionalProperties: false
      description: The amount and period to which this amount applies

Describe the bug you're encountering

When using the first YAML which contains an allOf to SubjectBase in TestSubject you will need see the properties correctly when you open periodieken in sum (see also screenshot).

To reproduce...

Steps to reproduce the behavior:

  1. Go to 'https://editor.swagger.io/'
  2. Paste in the YAML
  3. Open the schema TestSubject and keep opening until you come across the property factor
  4. See that properties are not being rendered

Expected behavior

You should see the properties of nested objects like in the working screenshot.

Screenshots

Not working:
swagger-ui-factor-not-showing

Working:
swagger-ui-factor-showing

Additional context or thoughts

This might have broken before 4.15.5 . We recently got a new customer which was looking at the swagger and then we discovered it has broken. A year ago it still worked.

@Rutix
Copy link
Author

Rutix commented Mar 9, 2023

@char0n when is the expectation that the fix is available on for example https://editor.swagger.io/ ?

@Rutix
Copy link
Author

Rutix commented Mar 28, 2023

@char0n are you sure the PR fixed this problem? I just tested it again (and made sure the version is online) and the problem still persists

@char0n
Copy link
Member

char0n commented Jul 27, 2023

@Rutix re-opening

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

Successfully merging a pull request may close this issue.

2 participants