Swagger-ui: apiKey security token causes v.forEach is not a function error

Created on 24 Aug 2018  路  2Comments  路  Source: swagger-api/swagger-ui

Q&A (please complete the following information)

  • OS: Ubuntu 18.04
  • Browser: chrome
  • Version: 68
  • Method of installation: dist
  • Swagger-UI version: 3.18.1
  • Swagger/OpenAPI version: Swagger 2.0

Content & configuration

Swagger/OpenAPI definition:

{
"swagger": "2.0",
"securityDefinitions": {
    "auth-token": {
      "type": "apiKey",
      "in": "header",
      "name": "auth-token"
    }
  },
  "security": {
    "auth-token": []
  },
 "info": {
    "title": "AdminAPI.proto",
    "version": "version not set"
  },
  "schemes": [

    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
"paths": {
    "/admin/api/v1/GetAllExecutionStats": {
      "post": {
        "summary": "ExecutionStats",
        "operationId": "GetAllExecutionStats",
        "responses": {
          "200": {
            "description": "",
            "schema": {
              "$ref": "#/definitions/AdminAPIGetAllExecutionStatsResp"
            }
          }
        },
        "parameters": [{
          "name": "body",
          "in": "body",
          "required": true,
          "schema": {
            "$ref": "#/definitions/AdminAPIGetAllExecutionStatsReq"
          }
        }],
        "tags": [
          "Admin"
        ]
      }
    },
...
}

Error

system.js:461 TypeError: v.forEach is not a function
    at o (index.js:1)
    at t.default (index.js:1)
    at Object.o [as buildRequest] (index.js:1)
    at actions.js:402
    at utils.js:121
    at bindActionCreators.js:3
    at wrap-actions.js:30
    at Object.r (system.js:173)
    at Object.executeRequest (system.js:458)
    at actions.js:442

How can we help?

I get this error when I have the anything set for the auth-token. It even happens if i make the auth-token "test". But, when nothing is set for auth-token, the api call goes through. I've looked at the swagger 2.0 doc, and I don't understand what's wrong. Could you please point me in the correct direction?

lock-bot

Most helpful comment

http://editor.swagger.io is a great tool to check for syntax errors. In your example, security must be an array. You need to change

  "security": {
    "auth-token": []
  },

to

  "security": [
    {"auth-token": []}
  ],

All 2 comments

http://editor.swagger.io is a great tool to check for syntax errors. In your example, security must be an array. You need to change

  "security": {
    "auth-token": []
  },

to

  "security": [
    {"auth-token": []}
  ],

Thank you. I appreciate it. That solved the issue. I didn't realize the array format in yaml and all the docs are in yaml only. I'll keep the editor in mind.

Was this page helpful?
0 / 5 - 0 ratings