Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object #60

Closed CodeSteele closed 4 years ago

CodeSteele commented 4 years ago

Seems to barf on the empty components:{} section, I removed it manually and it still errors on #59

$ npm run gen

> client@0.1.0 gen C:\Dev\[App]
> node ./codegen.js

openApi version: 3.0.1
isV3 true
(node:15668) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at Object.componentsCodegen (C:\Dev\[App]\node_modules\swagger-axios-codegen\dist\componentsCodegen\index.js:9:33)
    at codegen (C:\Dev\[App]\node_modules\swagger-axios-codegen\dist\index.js:68:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:15668) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise 
which was not handled with .catch(). (rejection id: 1)
(node:15668) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero 
exit code.

With the following swagger.json output from Swashbuckle:

{
  "openapi": "3.0.1",
  "info": {
    "title": "API",
    "description": "Internal API",
    "version": "v0"
  },
  "paths": {
    "/api/v0/accounts": {
      "get": {
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/addresses": {
      "get": {
        "tags": [
          "Address"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/conferences": {
      "get": {
        "tags": [
          "Conference"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/exhibitors": {
      "get": {
        "tags": [
          "ExhibitorContoller"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/facilities": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/functions": {
      "get": {
        "tags": [
          "Function"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/function-resources": {
      "get": {
        "tags": [
          "FunctionResource"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/function-resource-types": {
      "get": {
        "tags": [
          "FunctionResourceType"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/notes": {
      "get": {
        "tags": [
          "Note"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/roles": {
      "get": {
        "tags": [
          "Role"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/roomes": {
      "get": {
        "tags": [
          "Room"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/room-styles": {
      "get": {
        "tags": [
          "RoomStyle"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/sponsors": {
      "get": {
        "tags": [
          "Sponsor"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/unit-of-measures": {
      "get": {
        "tags": [
          "UnitOfMeasure"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/api/v0/users": {
      "get": {
        "tags": [
          "User"
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "components": { }
}
Manweill commented 4 years ago

fix in v0.9.4

CodeSteele commented 4 years ago

Yep that fixed it. Thanks a ton!