openapi-client-axios icon indicating copy to clipboard operation
openapi-client-axios copied to clipboard

`typegen` command reads file from `node_modules\@apidevtools\json-schema-ref-parser\dist` directory

Open dzikoysk opened this issue 1 year ago • 2 comments

Docs references that definition can be read from file located in project dir:

typegen ./openapi.yml > client.d.ts - generate a type definition file

Unfortunately, it's not the case 7.3.2:

$ typegen xxx.json > src/types/openapi.d.ts

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

JSONParserError: Error opening file "P:\xxx\xxx-frontend\node_modules\@apidevtools\json-schema-ref-parser\dist\xxx.json"
ENOENT: no such file or directory, open 'P:\xxx\xxx-frontend\node_modules\@apidevtools\json-schema-ref-parser\dist\xxx.json'        
    at Object.<anonymous> (P:\xxx\xxx-frontend\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\file.js:72:23)        
    at Generator.throw (<anonymous>)
    at rejected (P:\xxx\xxx-frontend\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\file.js:29:65) {
  code: 'ERESOLVER',
  name: 'ResolverError',
  source: 'P:\\xxx\\xxx-frontend\\node_modules\\@apidevtools\\json-schema-ref-parser\\dist\\xxx.json',
  path: null,
  toJSON: [Function: toJSON],
  ioErrorCode: 'ENOENT',
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect]
}

I've replaced it with the following command and it works:

$ curl http://localhost:8080/v3/api-docs > node_modules/@apidevtools/json-schema-ref-parser/dist/xxx.json && typegen xxx.json > src/types/openapi.d.ts"

But it doesn't seems to be right. Am I missing something or it's just a bug?

dzikoysk avatar Aug 10 '23 12:08 dzikoysk