openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
558 stars 67 forks source link

Typegen: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'replace' of undefined #42

Closed MelonCola closed 4 years ago

MelonCola commented 4 years ago

Whenever I run typegen on my openapi yml file, I get the following error

typegen http://localhost:8080/openapi.yml
(node:21928) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'replace' of undefined
    at Object.normalizeTypeName (D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\node_modules\@anttiviljami\dtsgenerator\dist\core\typeNameConvertor.js:37:17)
    at generateMethodForOperation (D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:143:53)
    at D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:191:66
    at Array.map (<anonymous>)
    at generateOperationMethodTypings (D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:191:39)
    at D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:124:40
    at step (D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:52:23)
    at Object.next (D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:33:53)
    at fulfilled (D:\Programs\nvm\v14.12.0\node_modules\openapi-client-axios-typegen\typegen.js:24:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

anttiviljami/dtsgenerator doesn't have issues open, and the original dtsgenerator doesn't have the file where the error occurs, so I figured it'd be best to post it here.

Edit: Realized I forgot to add operationId's, once I added them it solved the problem

patarapolw commented 3 years ago

Why can't it parse without operationId?

I want to lazily use Swagger for strongly typed Axios...