openapi-generator
Quick View
openapi-generator from swagger 2.0 or OpenAPI 3.0:
Simple
openapi-generator url http://xxx/v2/api-docs -c true
Use Config
openapi-generator config ./xxx.js
or openapi-generator config ./xxx.json
Config interface:
interface CliConfig {
api: string;
sdkDir: string;
templatePath?: string;
interfaceTemplatePath?: string;
requestLib = true;
camelCase?: boolean | 'lower' = false;
type?: 'ts' | 'js' = 'ts';
serviceType?: 'function' | 'class' = 'function';
namespace?: string = 'API';
/** 自动清除旧文件时忽略列表 */
ignoreDelete: string[] = [];
}
genAPISDK
function genAPISDK(data: RouteMetadataType[], config: GenConfig) => void