wcandillon / swagger-js-codegen

A Swagger Codegen for typescript, nodejs & angularjs
Apache License 2.0
693 stars 286 forks source link

Add typescript compilation to tests. #161

Closed mgmarino closed 7 years ago

mgmarino commented 7 years ago

By ensuring that typescript compilation actually succeeds, this can catch errors in the generated typescript code.

If a test fails, it also outputs errors like:

typescript generation: tests/apis/test.json: (7,8): '=' expected.
     ERROR line: type x - any = any;

typescript generation: tests/apis/test.json: (7,10): Cannot find name 'any'.
     ERROR line: type x - any = any;

typescript generation: tests/apis/test.json: (7,14): ';' expected.
     ERROR line: type x - any = any;

typescript generation: tests/apis/test.json: (7,16): Cannot find name 'any'.
     ERROR line: type x - any = any;
     ERRORS seen, generated code preserved in: tmp-14119f8ix0j7tPPOJ/tmp-14119xCh86tpdRHqL.ts

or

typescript generation: tests/apis/uber.json: (160,29): Argument of type '"{id}"' is not assignable to parameter of type 'RegExp'.
     ERROR line: path = path.replace('{id}', parameters['id']);

typescript generation: tests/apis/uber.json: (205,33): Argument of type '"{id}"' is not assignable to parameter of type 'RegExp'.
     ERROR line: path = path.replace('{id}', parameters['id']);
   generated code preserved in:tmp-13001eulrYDIm346L/tmp-13001X0iZIo8ED9z9.ts

These can be cleaned up by a call to npm run clean.

Note: the above errors were also fixed in this PR.

wcandillon commented 7 years ago

Thank you for this PR! Can you just fix the indentation issues in tests/generation.js? thks!

mgmarino commented 7 years ago

done. An editorconfig would also be helpful. :-)

wcandillon commented 7 years ago

@mgmarino Thks for this great PR!