PaloAltoNetworks / docusaurus-openapi-docs

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

defualt values dont show on enums when using a ref #977

Open Devon-White opened 1 month ago

Devon-White commented 1 month ago

Describe the bug

Will display the default value when the docs are generated:

primary_request_method:
          type: string
          enum:
            - GET
            - POST
          example: GET
          description: Primary request method of the External LAML Handler.
          default: GET

Will not display a default value

        primary_request_method:
          allOf:
            - $ref: '#/components/schemas/UrlMethodType'
          example: GET
          description: Primary request method of the External LAML Handler.
          default: POST

UrlMethodType Enum looks like:

    UrlMethodType:
      type: string
      enum:
        - GET
        - POST

Expected behavior

For Default value to always be shown, regardless if its using a ref or not.

Current behavior

No default is exposed when spec is written like the second example above.

Possible solution

Inline enums to allow default value to be shown.

Steps to reproduce

Look at examples above.

Context

Useful to allow this to work on refs so I can reuse the same type in multiple places, rather then constantly inlining my enum.

sserrata commented 1 month ago

Hi @Devon-White, thanks for reporting the issue. I think it stems from how we handle allOf - we are currently resolving/merging the allOf before passing the result on to SchemaItem for rendering. If the allOf doesn't include example, default, description, then I can see how those could be left out of the final render. Can you try moving the default property inside of the ref to see if that works?

like this:

UrlMethodType:
      type: string
      enum:
        - GET
        - POST
      default: POST
sserrata commented 1 month ago

That said, I think we should probably look to merge the result of allOf with the original schema so that we aren't missing anything.