Swagger UI's display of multiple-typed attributes is confusing
See original GitHub issueQ&A (please complete the following information)
- OS: OS X
- Browser: Firefox Developer Edition
- Version: 63.0b14
- Method of installation: dist assets
- Swagger-UI version: 3.19.3
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: '3.0.0'
info:
title: Foo API
version: '0.1.0'
components:
schemas:
FooType:
type: ['null', 'string', 'number']
(The important part is the JSON Schema type
field being a list.
Swagger-UI configuration options:
We use the defaults in the dist assets, except we set validatorUrl
to null
.
Describe the bug you’re encountering
The output is confusing. This is how the above JSONSchema will be rendered by Swagger UI:
Some whitespace between the different possible types, perhaps a ,
, or some indication that it must be one of those types, would greatly clarify what is happening.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why is multiple types shown in a bad way in Swagger UI
Show activity on this post. In OpenAPI 3.0, type cannot be a list of types, it must be a single type. A nullable...
Read more >Adding Examples - Swagger
Note for Swagger UI users: Support for multiple examples is available since Swagger UI 3.23.0 ... Note: Do not confuse example values with...
Read more >OpenAPI Specification - Version 2.0 - Swagger
The schema exposes two types of fields. Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for...
Read more >Adding Examples - Swagger
Adding Examples. An API specification can include examples for: response MIME types,; schemas (data models),; individual properties in schemas.
Read more >Media Types - Swagger
Media type is a format of a request or response body data. ... One or multiple media types go as child keywords of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thanatos:
OpenAPI does incorporate JSON Schema, but there are limits, which the specification covers in detail (emphasis mine):
Thanks for the feedback 😄
We’ve made the decision to keep validation in Swagger Editor, since the UI is commonly used by folks that can’t edit the document (think of a company using Swagger UI to host their documentation… if I’m using their API and there’s a bug in their document, why should I get a validation error about it?), while the Editor is almost always used by someone that has the power to fix any errors that crop up.
Closing due to inactivity.
This is simply to keep our issue tracker clean - feel free to comment if there are any further thoughts or concerns, and we’ll be happy to reopen this issue.