openapi-io-ts
openapi-io-ts copied to clipboard
openapi-io-ts generator script thrown an error
We are running into an issue generating for our project. The instructions in the readme were followed, and summarized below as follows.
Added to package.json
as a devDependency
using:
npm i -D @openapi-io-ts/cli
Added a command in our package.json
using:
scripts: {
...
"openapi-io-ts:generate": "openapi-io-ts -i apps/dashboard-api/src/docs/openapi.yaml -o apps/dashboard-api/src/codecs/generated",
...
}
Note that apps/dashboard-api/src/docs/openapi.yaml
is a valid openapi format using:
openapi: 3.0.1
We get the following:
$ npm run openapi-io-ts:generate
> [email protected] openapi-io-ts:generate
> openapi-io-ts -i apps/dashboard-api/src/docs/openapi.yaml -o apps/dashboard-api/src/codecs/generated
/Users/paolo/Dyn/redcoast/node_modules/@openapi-io-ts/cli/dist/bin.js:981
return (0, import_function16.pipe)(RTE12.Do, RTE12.bind("schema", () => JsonReference.is(s) ? getOpenapiSchemaFromRef(s) : RTE12.right(s)), RTE12.map((obj) => obj.schema.default));
^
TypeError: Cannot read properties of undefined (reading 'default')
at /Users/paolo/Dyn/redcoast/node_modules/@openapi-io-ts/cli/dist/bin.js:981:173
at /Users/paolo/Dyn/redcoast/node_modules/fp-ts/lib/Either.js:268:52
at Object.pipe (/Users/paolo/Dyn/redcoast/node_modules/fp-ts/lib/function.js:286:20)
at Object._map [as map] (/Users/paolo/Dyn/redcoast/node_modules/fp-ts/lib/Either.js:56:49)
at /Users/paolo/Dyn/redcoast/node_modules/fp-ts/lib/Functor.js:19:92
My expectation is that the command will generate the the necessary files based on the openapi.yml file passed in as a parameter. Is there something I am missing here? Thanks!