swagger-ui
swagger-ui copied to clipboard
Rendering string:string dictionary example in Schemas
Q&A (please complete the following information)
- OS: [e.g. macOS]
- Browser: [chrome]
- Version: [73]
- Method of installation: [editor.swagger.io]
- Swagger-UI version: [e.g. 3.10.0]
- Swagger/OpenAPI version: [OpenAPI 3.0]
Content & configuration
Example Swagger/OpenAPI definition:
components:
schemas:
Order:
type: object
properties:
testMap:
type: object
additionalProperties:
type: string
example:
en-us: Map
fr: le Map
Describe the bug you're encountering
Per https://swagger.io/docs/specification/data-models/dictionaries/
Examples of Dictionary Contents You can use the example keyword to specify sample dictionary contents:
type: object additionalProperties: type: string example: en: Hello! fr: Bonjour!
UI does not render any of these examples in the schema section, it only shows { < * >: String }
To reproduce...
Steps to reproduce the behavior:
- Go to editor.swagger.io
- Add a dictionary with examples to a component schema
- Look at render
- See no examples in the schemas section.
Expected behavior
Component schema preview shows examples in-line.
Screenshots
Additional context or thoughts
It's still not fixed yet..
This still doesn't seem to be fixed....
Any update on this? The rendered result is confusing. Try this:
openapi: 3.0.0
info:
title: Example
version: '1.0.0'
paths:
/example:
get:
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
components:
schemas:
Response:
type: object
properties:
listOfAccounts:
type: array
items:
$ref: '#/components/schemas/Account'
mapOfAccounts:
type: object
additionalProperties:
$ref: '#/components/schemas/Account'
mapOfListsOfAccounts:
type: object
additionalProperties:
type: array
items:
$ref: '#/components/schemas/Account'
Account:
type: object
properties:
accountId:
type: string
accountName:
type: string
Result (Example value):
{
"listOfAccounts": [
{
"accountId": "string",
"accountName": "string"
}
],
"mapOfAccounts": {
"additionalProp1": {
"accountId": "string",
"accountName": "string"
},
"additionalProp2": {
"accountId": "string",
"accountName": "string"
},
"additionalProp3": {
"accountId": "string",
"accountName": "string"
}
},
"mapOfListsOfAccounts": {
"additionalProp1": [
{
"accountId": "string",
"accountName": "string"
}
],
"additionalProp2": [
{
"accountId": "string",
"accountName": "string"
}
],
"additionalProp3": [
{
"accountId": "string",
"accountName": "string"
}
]
}
}
Result (Schema):