diff --git a/README.md b/README.md index d60ed5e..ef3a4ea 100644 --- a/README.md +++ b/README.md @@ -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. ## Versions +#### 2.1.4 +- Change `import * as XXX` to `import XXX` in codegen of `@koa/router` and `koa-body` #### 2.1.3 - Use `JSON.stringify()` for pure object in `STP._string` #### 2.1.2 diff --git a/dist/codegen.js b/dist/codegen.js index 11dd7b1..0435bba 100644 --- a/dist/codegen.js +++ b/dist/codegen.js @@ -77,9 +77,9 @@ function codegenRouter(funcs, config, cp) { // import cp.writeln("import * as Schemas from './".concat(schemasName, "'")); 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 * as bodyParser from 'koa-body'"); + cp.writeln("import bodyParser from 'koa-body'"); // api cp.writeln("\nimport api from '".concat(ServerAPITSPath, "'")); cp.writeln("type IState = typeof api extends IServerAPI ? T : any;"); diff --git a/lib/codegen.ts b/lib/codegen.ts index c5a5bd9..a75061a 100644 --- a/lib/codegen.ts +++ b/lib/codegen.ts @@ -79,10 +79,10 @@ function codegenRouter(funcs: APIFuncs, config: Config, cp: CodePrinter) { // import cp.writeln(`import * as Schemas from './${schemasName}'`); cp.writeln(`import {IServerAPI} from './${IHandlerName}'`); - cp.writeln(`import * as Router from '@koa/router'`); + cp.writeln(`import Router from '@koa/router'`); cp.writeln( `import {FullDate, StrictTypeParser as STP} from '${utilsTSPath}'`); - cp.writeln(`import * as bodyParser from 'koa-body'`); + cp.writeln(`import bodyParser from 'koa-body'`); // api cp.writeln(`\nimport api from '${ServerAPITSPath}'`); cp.writeln(`type IState = typeof api extends IServerAPI ? T : any;`); diff --git a/package.json b/package.json index 5394646..2a767ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sup39/api-ts-gen", - "version": "2.1.3", + "version": "2.1.4", "description": "OpenAPI code generator for TypeScript", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts",