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

never type field in schema is rendered as string #10118

Open
nhollander-alert opened this issue Sep 3, 2024 · 0 comments
Open

never type field in schema is rendered as string #10118

nhollander-alert opened this issue Sep 3, 2024 · 0 comments

Comments

@nhollander-alert
Copy link

Q&A (please complete the following information)

  • OS: macOS
  • Browser: Firefox
  • Version: 130.0b7
  • Method of installation: npm
  • Swagger-UI version: 5.17.14
  • Swagger/OpenAPI version: OpenAPI 3.1

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: Never type render issue demo
  version: 0.0.0
components:
  schemas:
    base_type:
      type: object
      additionalProperties: false
      properties:
        foo:
          type: string
        bar:
          type: number
        baz:
          type: boolean
paths:
  /test:
    get:
      responses:
        '200':
          description: This is a test
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/base_type'
                  - properties:
                      bar: false

Swagger-UI configuration options:

SwaggerUI({
  url: "./openapi.json"
})

Describe the bug you're encountering

When using never typed objects in the JSON schema, they are correctly displayed as never in the schema preview box, but get rendered as "string" in the automatically generated sample inputs.

To reproduce...

Steps to reproduce the behavior:

  1. Go to the Swagger Editor
  2. Paste the above OpenAPI definition into the panel on the left
  3. Click the /test endpoint under the default tag
  4. Click between Example Value and Schema to see the difference in expected types.

Expected behavior

Fields with the never type should be omitted from the example value generator

Screenshots

image
image

Additional context or thoughts

Not sure if this is a problem with Swagger-UI directly or the library that is being used to generate the previews internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant