swagger-codegen-ts icon indicating copy to clipboard operation
swagger-codegen-ts copied to clipboard

Controllers are generated with unused variable

Open morozovamv opened this issue 5 years ago • 7 comments

After starting generate I receive an error in generated controllers. The error is image

generate function is same as test1 in tests

Libs:

"fp-ts": "^2.4.4",
"io-ts": "^2.0.1",
"io-ts-reporters": "^1.0.0",
"io-ts-types": "^0.5.2",
"@devexperts/swagger-codegen-ts": "^2.0.0-alpha.17",
"@devexperts/utils": "^1.0.0-alpha.11",

System: win10

Also, I checked tests here and got the same result.

STR:

  • clone project
  • yarn install
  • yarn test:run

image

morozovamv avatar Feb 13 '20 10:02 morozovamv

Could you provide the spec?

raveclassic avatar Feb 13 '20 12:02 raveclassic

the spec that I used for tests

our project spec: swagger.zip

morozovamv avatar Feb 13 '20 15:02 morozovamv

This is very annoying. @raveclassic do you happen to know how difficult to fix this?

sutarmin avatar Mar 06 '20 09:03 sutarmin

Quickfix - just disable linting on the generated code.

raveclassic avatar Mar 06 '20 09:03 raveclassic

We have the same issue. Vote for the fix! :)

timofeevda avatar Jul 10 '20 11:07 timofeevda

Generally, generated code is not expected to be linted, neither adhere any codestyle. The only option available at the moment is a prettier config for formatting the code. Personally I do agree unused imports should be removed, but at the same time I don't get why this is a problem for the end project which should (and it really should) just disable linting of the generated code. We'd gladly review any PRs facing this issue, but at the moment we consider this as a low priority improvement.

raveclassic avatar Jul 10 '20 14:07 raveclassic

Sounds reasonable :)

timofeevda avatar Jul 10 '20 20:07 timofeevda