readmeio/api

Operations unable to be detected under certain circumstances

Closed this issue · 1 comments

    TypeError: Cannot read property 'getSecurity' of undefined

      16 |   };
      17 | 
    > 18 |   if (operation.getSecurity().length === 0) {
         |                 ^
      19 |     return matchers;
      20 |   }
      21 | 

      at getAuthSources (src/index.js:18:17)
      at module.exports (src/index.js:81:23)
      at node_modules/httpsnippet/src/index.js:197:14
          at Array.map (<anonymous>)
      at HTTPSnippet.convert (node_modules/httpsnippet/src/index.js:196:33)
      at it.each (__tests__/index.test.js:83:39)
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "issue-81"
  },
  "servers": [
    {
      "url": "https://example.com"
    }
  ],
  "paths": {
    "/pets/orders/:id": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}
{
  "log": {
    "entries": [
      {
        "request": {
          "allHeaders": {"content-type": "application/json"},
          "bodySize": 0,
          "cookies": [],
          "fullUrl": "https://example.com/v2/orders/:id",
          "headers": [{
            "name": "Content-Type",
            "value": "application/json"
          }],
          "headersSize": 0,
          "httpVersion": "HTTP/1.1",
          "method": "POST",
          "postData": {
            "jsonObj": false,
            "mimeType": "application/octet-stream",
            "paramsObj": false,
            "size": 0
          },
          "queryString": [],
          "url": "https://example.com/v2/orders/:id"
        }
      }
    ]
  }
}

This appears to be a problem when the server URL has a trailing /.