Skip to content

Commit

Permalink
typescript-node: clean up require and import (#6947)
Browse files Browse the repository at this point in the history
* Fix for issue 4656 typescript-node generate invalid require statement instead of import statement

* Fixed broken link under testing templates

* Result of run generate-samples.sh / typescript-node*

* import stmt depending on flag supportsES6

* Update petstore sample for typescript-node

* import ... from stmt for http/request module

* update samples

* update doc

Co-authored-by: William Cheng <[email protected]>
  • Loading branch information
laubfall and wing328 authored Jul 31, 2020
1 parent 0f3edb1 commit b838e18
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 21 deletions.
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ To add test cases (optional) covering the change in the code generator, please r
To test the templates, please perform the following:

- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh .
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/t
ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/tree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro
m time to time. If you've questions or concerns, please open a ticket to start a discussion)
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`.
Expand Down
3 changes: 1 addition & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ To add test cases (optional) covering the change in the code generator, please r
To test the templates, please perform the following:

- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh .
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/t
ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/tree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro
m time to time. If you've questions or concerns, please open a ticket to start a discussion)
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{>licenseInfo}}
import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
{{#imports}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export * from '{{{ classFilename }}}';
{{/model}}
{{/models}}

import localVarRequest = require('request');
import localVarRequest from 'request';

{{#models}}
{{#model}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,
"moduleResolution": "node",
"removeComments": true,
Expand Down
5 changes: 3 additions & 2 deletions samples/client/petstore/typescript-node/default/api/petApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Do not edit the class manually.
*/

import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
import { ApiResponse } from '../model/apiResponse';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Do not edit the class manually.
*/

import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
import { Order } from '../model/order';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Do not edit the class manually.
*/

import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
import { User } from '../model/user';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export * from './pet';
export * from './tag';
export * from './user';

import localVarRequest = require('request');
import localVarRequest from 'request';

import { ApiResponse } from './apiResponse';
import { Category } from './category';
Expand Down
5 changes: 3 additions & 2 deletions samples/client/petstore/typescript-node/npm/api/petApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Do not edit the class manually.
*/

import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
import { ApiResponse } from '../model/apiResponse';
Expand Down
5 changes: 3 additions & 2 deletions samples/client/petstore/typescript-node/npm/api/storeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Do not edit the class manually.
*/

import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
import { Order } from '../model/order';
Expand Down
5 changes: 3 additions & 2 deletions samples/client/petstore/typescript-node/npm/api/userApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Do not edit the class manually.
*/

import localVarRequest = require('request');
import http = require('http');

import localVarRequest from 'request';
import http from 'http';

/* tslint:disable:no-unused-locals */
import { User } from '../model/user';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export * from './pet';
export * from './tag';
export * from './user';

import localVarRequest = require('request');
import localVarRequest from 'request';

import { ApiResponse } from './apiResponse';
import { Category } from './category';
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/typescript-node/npm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "ES5",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,
"moduleResolution": "node",
"removeComments": true,
Expand Down

0 comments on commit b838e18

Please sign in to comment.