swagger-ui: using this param causes render error

v3.0.8

"parameters": [ { "name": "parts", "in": "query", "required": true, "description": "Parts to retrieve", "type": "array", "items": { "type": "string" }, "enum": [ "A", "B", "C", "D", "E", "F" ], "collectionFormat": "multi" } ] Is this just invalid syntax? when you click “Try It Now”

it renders that field as: ‘Could not render this component, see the console.’ Console has: TypeError: p.count is not a function at t.value (swagger-ui-bundle.js:95945) at t.n.render (swagger-ui-bundle.js:38091) at p._renderValidatedComponentWithoutOwnerOrContext (swagger-ui-bundle.js:50643) at p._renderValidatedComponent (swagger-ui-bundle.js:50643) at performInitialMount (swagger-ui-bundle.js:50643) at p.mountComponent (swagger-ui-bundle.js:50643) at Object.mountComponent (swagger-ui-bundle.js:44096) at performInitialMount (swagger-ui-bundle.js:50643) at p.mountComponent (swagger-ui-bundle.js:50643) at Object.mountComponent (swagger-ui-bundle.js:44096)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

The enum should be on the items level, not on the array level.

  "parameters": [
    {
      "name": "parts",
      "in": "query",
      "required": true,
      "description": "Parts to retrieve",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "A",
          "B",
          "C",
          "D",
          "E",
          "F"
        ]
      },
      "collectionFormat": "multi"
    }
  ]

That said, the UI should probably handle this more gracefully.