swagger-api / swagger-api/swagger-ui
Object property description not rendered correctly when no type specified
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
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

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:
- Go to Swagger Editor and paste the example above
Expected behavior
The object property with no type specified correctly renders the description. E.g.:

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

Screenshots
Screenshot of this error in the wild:

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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in Swagger Editor using the YAML example, then trace Swagger UI’s schema-property rendering from the displayed object property. Done means a property with no type renders its description correctly without requiring an invalid type value, while the OpenAPI definition remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100