swagger-axios-codegen
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -12,2 +12,3 @@ export interface ISwaggerOptions { | ||
include?: Array<string | IInclude>; | ||
format?: (s: string) => string; | ||
} | ||
@@ -14,0 +15,0 @@ export interface IPropDef { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IDefinitionProperties } from "../saggerInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IEnumDef } from "../baseInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IDefinitions } from '../saggerInterfaces'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IDefinitionProperty } from "../saggerInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
import { ISwaggerOptions } from './baseInterfaces'; | ||
export declare function codegen(params: ISwaggerOptions): Promise<void>; |
@@ -67,3 +67,3 @@ "use strict"; | ||
const fileDir = path.join(options.outputDir || '', 'definitions'); | ||
writeFile(fileDir, item.name + '.ts', format(text)); | ||
writeFile(fileDir, item.name + '.ts', format(text, options)); | ||
}); | ||
@@ -73,3 +73,3 @@ Object.values(models).forEach(item => { | ||
const fileDir = path.join(options.outputDir || '', 'definitions'); | ||
writeFile(fileDir, item.name, format(text)); | ||
writeFile(fileDir, item.name, format(text, options)); | ||
}); | ||
@@ -138,3 +138,3 @@ } | ||
apiSource += reqSource + defSource; | ||
writeFile(options.outputDir || '', options.fileName || '', format(apiSource)); | ||
writeFile(options.outputDir || '', options.fileName || '', format(apiSource, options)); | ||
} | ||
@@ -165,3 +165,3 @@ else { | ||
}); | ||
writeFile(options.outputDir || '', options.fileName || '', format(apiSource)); | ||
writeFile(options.outputDir || '', options.fileName || '', format(apiSource, options)); | ||
} | ||
@@ -186,3 +186,8 @@ catch (error) { | ||
} | ||
function format(text) { | ||
function format(text, options) { | ||
if (options.format) { | ||
console.log('use custom formatter'); | ||
return options.format(text); | ||
} | ||
console.log('use default formatter'); | ||
return prettier_1.default.format(text, { | ||
@@ -189,0 +194,0 @@ "printWidth": 120, |
@@ -0,0 +0,0 @@ import { IParameter } from "../saggerInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRequestMethod } from "../saggerInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IPaths } from '../saggerInterfaces'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface ISwaggerSource { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IPropDef } from "./baseInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IDefinitionClass, IDefinitionEnum } from "./baseInterfaces"; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "swagger-axios-codegen", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"main": "./dist/index", | ||
@@ -39,2 +39,2 @@ "typings": "./dist/", | ||
} | ||
} | ||
} |
@@ -41,3 +41,3 @@ # swagger-axios-codegen | ||
fileName: 'index.ts', | ||
useStaticMethod: true, | ||
useStaticMethod: true, // >= 0.4 | ||
useCustomerRequestInstance: false | ||
@@ -44,0 +44,0 @@ } |
57588
33
1048