Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object with additionalProperties (i.e. map of string to object) does not display schema #2213

Open
codygibb opened this issue Aug 4, 2022 · 4 comments
Labels
enhancement New feature or request s/needs-wire Needs design help triaged

Comments

@codygibb
Copy link

codygibb commented Aug 4, 2022

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:

Screen Shot 2022-08-04 at 3 18 29 PM

Expected Behavior

Elements should display the object value schema. For example, ReDoc allows expanding object value schema:

Screen Shot 2022-08-04 at 3 18 21 PM

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
@codygibb
Copy link
Author

codygibb commented Aug 8, 2022

Note, I believe the root issue here is actually in another repo: stoplightio/json-schema-viewer#108

@mnaumanali94 mnaumanali94 added enhancement New feature or request s/needs-wire Needs design help labels Aug 11, 2022
@ahopkinstk
Copy link

FWIW I am experiencing the same behaviour using YAML schemas

@Thore1954
Copy link

Even worse, when you open a reusable schema with additionalProperties you see a blank page.

@thebongy
Copy link

thebongy commented Jan 31, 2024

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:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request s/needs-wire Needs design help triaged
Projects
None yet
Development

No branches or pull requests

6 participants