redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

OpenAPI codegen + Prettier 3 plugins

Open philsp opened this issue 2 years ago • 4 comments

Adding Tailwind plugin to Prettier breaks codegen

{
  "name": "openapi-test",
  "dependencies": {
    "@rtk-query/codegen-openapi": "^1.0.0",
    "prettier": "^3.0.0",
    "prettier-plugin-tailwindcss": "^0.4.1"
  }
}
// openapi.config.js
module.exports = {
  schemaFile: 'https://raw.githubusercontent.com/reduxjs/redux-toolkit/master/packages/rtk-query-codegen-openapi/test/fixtures/petstore.json',
  apiFile: 'https://raw.githubusercontent.com/reduxjs/redux-toolkit/master/packages/rtk-query-codegen-openapi/test/fixtures/emptyApi.ts',
  outputFile: './example.ts',
};
// prettier.config.js
module.exports = {
  printWidth: 10000,
  plugins: ['prettier-plugin-tailwindcss'], // remove this to make codegen work
}

Output

npx @rtk-query/codegen-openapi openapi.config.js
Generating ./example.ts
TypeError: Cannot read properties of undefined (reading 'startsWith')
    at printAngular (___\openapi-test\node_modules\@rtk-query\codegen-openapi\node_modules\prettier\index.js:24775:22)
    ...

philsp avatar Jul 19 '23 07:07 philsp