Object with additionalProperties (i.e. map of string to object) does not display schema
Context
Swagger specs can define string-to-object dictionary mappings with the following config:
type: object
additionalProperties:
type: object
properties:
...
In these cases, the object keys can be any string, but the object values have a fixed schema.
Current Behavior
Elements does not display the object value schema for dictionary mappings. It simply says "object" with no further details:
Expected Behavior
Elements should display the object value schema. For example, ReDoc allows expanding object value schema:
Steps to Reproduce
Example referenced in the above two screenshots:
{
"definitions": {
"Foo": {
"type": "object",
"properties": {
"bars": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Bar"
},
},
}
},
"Bar": {
"type": "object",
"properties": {
"text": {
"type": "string",
},
"code": {
"type": "integer",
}
}
}
},
"paths": {
"/foos": {
"post": {
"operationId": "CreateFoo",
"parameters": [
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/Foo"
}
}
],
"tags": [
"Foo"
]
}
},
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"swagger": "2.0"
}
Environment
- Version used: whatever is currently being hosted by
unpkg.com/@stoplight/elements. - Environment name and version (e.g. Chrome 39, node.js 5.4): Chrome 103.0.5060.134 (arm64)
- Operating System and version (desktop or mobile): desktop
Note, I believe the root issue here is actually in another repo: https://github.com/stoplightio/json-schema-viewer/issues/108
FWIW I am experiencing the same behaviour using YAML schemas
Even worse, when you open a reusable schema with additionalProperties you see a blank page.
Just wanted to add for someone still experiencing this issue:
We bumped the @stoplight/elements package from 7.7.7 to 8.0.2 (https://github.com/dyte-io/docs/pull/261/files) , and this issue was resolved somewhere in between, we see the correct "Dictionary" type now: