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

Response schema not built fully #227

Closed julianbirkett closed 2 years ago

julianbirkett commented 2 years ago

Describe the bug

I have a response schema that includes an allOf with an array and another referenced schema. For some reason the array part is not displaying in the Schema section of my API page. The schema definition looks like this.

  allOf:
    - properties:
        customers:
          description: Customer search success results
          uniqueItems: false
          type: array
          items:
            $ref: '#/components/schemas/CustomerReferenceSimple'
    - $ref: '#/components/schemas/Common.Response.Collection'

Expected behavior

I would expect the array and the array and the common response collection to appear on the page

Current behavior

Currently the page looks like this

image

Possible solution

I think it may be the fact that this is either in an array or allOf is not being recognised by the parser

Steps to reproduce

customers.v3.txt

I have attached the customers yaml spec I used as a .txt file.

  1. Copy the attached customers.v3.txt file onto your machine

  2. Rename it to .yaml

  3. Add the plugin for the spec into the docusaurus.config.js

    id: "apiDocs", docsPluginId: "classic", config: { customer: { specPath: "apidocs/customer.v3.yaml", // Path to designated spec file outputDir: "docs/apis/customer", // Output directory for generated .mdx docs sidebarOptions: { groupPathsBy: "tag", categoryLinkSource: "tag", sidebarCollapsible: true, customProps: {}, }, }

  4. Add the entry into a sidebar somewhere

{ type: "category", label: "Customer", link: { type: "generated-index", title: "Customer API", description: "This is a sample server Customer server. You can find out more about Swagger at http://swagger.io/ or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.", slug: "/category/customer-api" }, // @ts-ignore items: require("./docs/apis/customer/sidebar.js") }

  1. Generate the mdx files with npm run gen-api-docs all
  2. Run the site with npm run start
  3. Navigate to the defined page via the sidebar and pick Customer, Customer Search

Screenshots

image

image

Context

This style of definition covers a number of API specs we use so it would be really helpful to get this fixed

Your Environment

sserrata commented 2 years ago

Hi @julianbirkett, I believe I found the root cause.

Traced it back to this option in the json-schema-merge-allof library:

https://github.com/mokkabonna/json-schema-merge-allof#:~:text=ignoreAdditionalProperties%20default%20false

https://user-images.githubusercontent.com/9343811/186950422-5db8e940-84c7-47d0-8eab-2d06c537beb6.mov

Still testing but I'll merge once the fix is verified.

sserrata commented 2 years ago

Hi, canary release 0.0.0-434 is available to test now. Thanks!

julianbirkett commented 2 years ago

I've tested the canary release and that is giving the output I'd expect. Thanks very much.