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

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

Open
Devon-White opened this issue Sep 25, 2024 · 2 comments
Open

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

Devon-White opened this issue Sep 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Devon-White
Copy link

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
@Devon-White Devon-White added the bug Something isn't working label Sep 25, 2024
@sserrata
Copy link
Member

sserrata commented Oct 4, 2024

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
Copy link
Member

sserrata commented Oct 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants