redux-toolkit
redux-toolkit copied to clipboard
@rtk-query/codegen-openapi SyntaxError for bigger api schema
I am trying to generate api with
npx @rtk-query/codegen-openapi ./src/rqStore/apiConfigs/userConfig.ts
but I have error:
Generating ../hooks/userApi.ts SyntaxError: Type expected. (829:30) 827 | fleetNote4?: string; 828 | };
829 | export type FleetEntityDto = ; | ^ 830 | export type FleetEntityCreateResponse = { 831 | id?: string; 832 | }; at v (/prj112/node_modules/prettier/parser-typescript.js:1:14679) at _H (/prj112/node_modules/prettier/parser-typescript.js:49:10722) at Object.cH [as parse] (/prj112/node_modules/prettier/parser-typescript.js:49:11028) at Object.parse (/prj112/node_modules/prettier/index.js:7515:23) at coreFormat (/prj112/node_modules/prettier/index.js:8829:18) at formatWithCursor2 (/prj112/node_modules/prettier/index.js:9021:18) at /prj112/node_modules/prettier/index.js:38183:12 at Object.format (/prj112/node_modules/prettier/index.js:38197:12) at prettify (/prj112/node_modules/@rtk-query/codegen-openapi/src/utils/prettier.ts:35:19) at async generateEndpoints (/prj112/node_modules/@rtk-query/codegen-openapi/src/index.ts:20:63) { loc: { start: { line: 829, column: 30 } }, codeFrame: '\x1B[0m \x1B[90m 827 |\x1B[39m fleetNote4\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m string\x1B[33m;\x1B[39m\x1B[0m\n' + '\x1B[0m \x1B[90m 828 |\x1B[39m }\x1B[33m;\x1B[39m\x1B[0m\n' + '\x1B[0m\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 829 |\x1B[39m \x1B[36mexport\x1B[39m type \x1B[33mFleetEntityDto\x1B[39m \x1B[33m=\x1B[39m \x1B[33m;\x1B[39m\x1B[0m\n' + '\x1B[0m \x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m\x1B[0m\n' + '\x1B[0m \x1B[90m 830 |\x1B[39m \x1B[36mexport\x1B[39m type \x1B[33mFleetEntityCreateResponse\x1B[39m \x1B[33m=\x1B[39m {\x1B[0m\n' + '\x1B[0m \x1B[90m 831 |\x1B[39m id\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m string\x1B[33m;\x1B[39m\x1B[0m\n' +
"@rtk-query/codegen-openapi": "^1.2.0",
I checked it with @rtk-incubator/rtk-query-codegen-openapi
and it has no problem with the same API schema.
I think this issue comes from oazpfts. It should be resolved in a newer version. You could try adding a resolution to your package.json as suggested here: https://github.com/oazapfts/oazapfts/issues/520
{
"dependencies": {
"@rtk-query/codegen-openapi": "^1.2.0"
},
"resolutions": {
"@rtk-query/codegen-openapi/oazapfts": "^4.11.1"
}
}
Thanks for advice, but it didn't help.
Is there any progress on this issue? That case doesn't work:
{
"dependencies": {
"@rtk-query/codegen-openapi": "^1.2.0"
},
"resolutions": {
"@rtk-query/codegen-openapi/oazapfts": "^4.11.1"
}
}
But if the version of @rtk-query/codegen-openapi is 1.0.0, everything works fine. Also the problem appears only when api schema is big enouth.
Yes, "@rtk-query/codegen-openapi": "1.0.0" works fine for big schema.