swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Object property description not rendered correctly when no type specified

Open outdooracorn opened this issue 3 years ago • 0 comments

Q&A (please complete the following information)

  • OS: Ubuntu 20.04.5
  • Browser: Firefox
  • Version: 104.0
  • Method of installation: npm
  • Swagger-UI version: 4.14.0
  • Swagger/OpenAPI version: OpenAPI 3.0.3

Content & configuration

Example Swagger/OpenAPI definition (created using the Swagger Editor):

openapi: 3.0.3
info:
  title: Example
  version: '0.1'
paths:
  /example/path:
    get:
      responses:
        '200':
          description: Example response description
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExampleSchema'
components:
  schemas:
    ExampleSchema:
      type: object
      properties:
        string_property:
          description: Example description of a string property
          type: string
          example: This is an example string
        property_of_any_type_without_description:
          example:
            - could
            - be
            - an
            - array
        property_of_any_type_with_description:
          description: Example description of a property with any type
          example: 42

image

Swagger-UI configuration options:

SwaggerUI( {
	spec,
	dom_id: '#swagger'
} );

Describe the bug you're encountering

As can been seen in the screenshot above, the description for object properties that don't specify a type (i.e. can accept any type) is not rendered correctly. https://swagger.io/docs/specification/data-models/data-types/#any

To reproduce...

Steps to reproduce the behavior:

  1. Go to Swagger Editor and paste the example above

Expected behavior

The object property with no type specified correctly renders the description. E.g.: image

Optionally, the type could be "any" to indicate any type is accepted. E.g.: image

Screenshots

Screenshot of this error in the wild: image

Additional context or thoughts

I can get Swagger UI to render correctly if I use type: any or type: {} but that then fails validations and breaks other tools using the OpenAPI definition.

outdooracorn avatar Sep 12 '22 16:09 outdooracorn