Skip to content

never type field in schema is rendered as string #10118

Open
@nhollander-alert

Description

@nhollander-alert

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions