PaloAltoNetworks / docusaurus-openapi-docs

🦝 OpenAPI plugin for generating API reference docs in Docusaurus v3.
https://docusaurus-openapi.tryingpan.dev
MIT License
704 stars 236 forks source link

allOf not displayed correctly when part of an array type #349

Closed philip-ellis-sp closed 1 year ago

philip-ellis-sp commented 1 year ago

Describe the bug

If I have a spec defined with an array with items that are allOf under it, the generated documentation does not show the response correctly

Expected behavior

The response should show all of the objects defined in the schema.

Current behavior

Currently, the only thing that is displayed is the text "allOf" Example below:

image

Possible solution

Unsure at this time.

Steps to reproduce

Live example can be found here: https://developer.sailpoint.com/idn/api/v3/list-identity-profiles/

to reproduce this bug, you can create a schema with a response that has an array type with allOf in the items. An example response yaml:

  responses:
    '200':
      description: List of identityProfiles.
      content:
        application/json:
          schema:
            type: array
            items:
              allOf:
              - type: object
                properties:
                  id:
                    description: System-generated unique ID of the Object
                    type: string
                    example: id12345
                    readOnly: true
              - type: object
                properties:
                  description:
                    type: string
                    description: The description of the Identity Profile.
                    example: My custom flat file profile
                    nullable: true

Then generate the documentation and not that the all of is not presented properly.

Context

Our specification has a few instances of this scenario and they are not rendered properly on the page. I tried limiting the schema to just two objects and the error still persisted. I also switched it from allOf to oneOf and the oneOf was presented just fine, so it appears to be limited to just the allOf type.

Your Environment

sserrata commented 1 year ago

Available for testing in 0.0.0-522. Thanks!

maciekpitucha commented 1 year ago

I'd be also interested in that. I tested the 0.0.0-522 but it seems to display just one (the second) of the two properties from the @philip-ellis-sp's example:

image

I think both should be displayed.

@sserrata would you mind taking a look?

maciekpitucha commented 1 year ago
  1. @sserrata I've looked into this and the unexpected behaviour from my previous post appears only if readOnly: true is used, like in @philip-ellis-sp's example. Without it, it works as expected in 0.0.0-522.
  2. However, if the array with allOf is a property of the top level object, the schema is not displayed.
type: object
properties:
  top_level_property:
    type: array
    items:
      allOf:
        - type: object
          properties:
            id:
              description: System-generated unique ID of the Object
              type: string
              example: id12345
              # readOnly: true
        - type: object
          properties:
            description:
              type: string
              description: The description of the Identity Profile.
              example: My custom flat file profile
              nullable: true

produces the following output:

image

would you rather I report it in a new issue?