docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
defualt values dont show on enums when using a ref
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.
- Version used: 3.0.2
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
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.