Archived
1
0
Fork 0

Change import * as XXX to import XXX in codegen of @koa/router and koa-body

This commit is contained in:
sup39 2022-08-13 04:39:34 +09:00
parent 469ba4d7bf
commit 64c6d14047
4 changed files with 7 additions and 5 deletions

View file

@ -608,6 +608,8 @@ interface Task {
This tool only supports `application/json` type for request and response body. Any other type like `multipart/form` or `image/*` are **not supported** and will be ignored. This tool only supports `application/json` type for request and response body. Any other type like `multipart/form` or `image/*` are **not supported** and will be ignored.
## Versions ## Versions
#### 2.1.4
- Change `import * as XXX` to `import XXX` in codegen of `@koa/router` and `koa-body`
#### 2.1.3 #### 2.1.3
- Use `JSON.stringify()` for pure object in `STP._string` - Use `JSON.stringify()` for pure object in `STP._string`
#### 2.1.2 #### 2.1.2

4
dist/codegen.js vendored
View file

@ -77,9 +77,9 @@ function codegenRouter(funcs, config, cp) {
// import // import
cp.writeln("import * as Schemas from './".concat(schemasName, "'")); cp.writeln("import * as Schemas from './".concat(schemasName, "'"));
cp.writeln("import {IServerAPI} from './".concat(IHandlerName, "'")); cp.writeln("import {IServerAPI} from './".concat(IHandlerName, "'"));
cp.writeln("import * as Router from '@koa/router'"); cp.writeln("import Router from '@koa/router'");
cp.writeln("import {FullDate, StrictTypeParser as STP} from '".concat(utilsTSPath, "'")); cp.writeln("import {FullDate, StrictTypeParser as STP} from '".concat(utilsTSPath, "'"));
cp.writeln("import * as bodyParser from 'koa-body'"); cp.writeln("import bodyParser from 'koa-body'");
// api // api
cp.writeln("\nimport api from '".concat(ServerAPITSPath, "'")); cp.writeln("\nimport api from '".concat(ServerAPITSPath, "'"));
cp.writeln("type IState = typeof api extends IServerAPI<infer T> ? T : any;"); cp.writeln("type IState = typeof api extends IServerAPI<infer T> ? T : any;");

View file

@ -79,10 +79,10 @@ function codegenRouter(funcs: APIFuncs, config: Config, cp: CodePrinter) {
// import // import
cp.writeln(`import * as Schemas from './${schemasName}'`); cp.writeln(`import * as Schemas from './${schemasName}'`);
cp.writeln(`import {IServerAPI} from './${IHandlerName}'`); cp.writeln(`import {IServerAPI} from './${IHandlerName}'`);
cp.writeln(`import * as Router from '@koa/router'`); cp.writeln(`import Router from '@koa/router'`);
cp.writeln( cp.writeln(
`import {FullDate, StrictTypeParser as STP} from '${utilsTSPath}'`); `import {FullDate, StrictTypeParser as STP} from '${utilsTSPath}'`);
cp.writeln(`import * as bodyParser from 'koa-body'`); cp.writeln(`import bodyParser from 'koa-body'`);
// api // api
cp.writeln(`\nimport api from '${ServerAPITSPath}'`); cp.writeln(`\nimport api from '${ServerAPITSPath}'`);
cp.writeln(`type IState = typeof api extends IServerAPI<infer T> ? T : any;`); cp.writeln(`type IState = typeof api extends IServerAPI<infer T> ? T : any;`);

View file

@ -1,6 +1,6 @@
{ {
"name": "@sup39/api-ts-gen", "name": "@sup39/api-ts-gen",
"version": "2.1.3", "version": "2.1.4",
"description": "OpenAPI code generator for TypeScript", "description": "OpenAPI code generator for TypeScript",
"main": "dist/lib/index.js", "main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",