auto-request
Version:
通过Yapi JSON Schema生成接口Axios或Taro接口
91 lines • 3.95 kB
TypeScript
import { MethodsType, GetSchema, ApiInterfaces } from '@/define';
import { ParametersDef } from '@/define';
export declare const pascalCaseReplaceString: (str: string, pascalCase?: boolean) => any;
export declare const renderMethodArgs: (args: string[]) => string;
/**
* 标准化并格式化 URL
* 1. 移除路径参数中的正则表达式 {userid:\d+} -> {userid}
* 2. 将路径参数转换为模板字符串格式 {userid} -> ${userid}
*/
export declare const normalizeUrl: (parameters: ParametersDef[] | undefined, url: string) => string;
export declare const formatUrl: (parameters: ParametersDef[] | undefined, url: string) => string;
export declare const createMethodsName: (url: string, method: string, parameters?: any[]) => any;
export declare const formatParamtersItemType: (type: ParametersDef["type"]) => "string" | "number";
export declare const renderRenderParametersPaths: (parmeters: ParametersDef[], isTypeScript?: boolean) => string;
export declare const getParameterPath: (parmeters: ParametersDef[]) => ParametersDef[];
export declare const getParameterData: (parmeters: ParametersDef[]) => ParametersDef[];
export declare const getParameterParams: (parmeters: ParametersDef[]) => ParametersDef[];
export declare const getTemplatePrefix: () => "\n import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'\n \n\n " | "import axios from 'axios'\n";
export declare class Helper {
uri: string;
method: MethodsType;
sourceSchema: GetSchema;
summary: string;
description: string;
getApiInteraces: ApiInterfaces[];
renderOptionsStr: {
params: string;
data: string;
};
constructor(uri: string, method: MethodsType, params: GetSchema);
getUrl(): string;
getMethodsName(): any;
getJsDocTypes(): string;
getMethodPrePath(): string;
getMethodPreParams(): "" | "params" | "params: P";
getJsDocMethodPreParams(): "" | "params: P";
getMethodOption(): "options: AxiosRequestConfig = {}" | "options = {}";
getJsDocMethodOption(): string;
getMethodPreDefineParams(): string | undefined;
__vaildateGetMethodPrePath(getParams: ParametersDef[]): void;
debugPrint(desc: string, errMsg?: string): void;
getMethodParams(): void;
getMethodData(): ParametersDef[];
renderGetMethodData(): "" | "data" | "data: D";
renderJsDocGetMethodData(): "" | "data: D";
renderGetMethodDefineData(): string | undefined;
getMethodsDefineResponse(): string;
renderTsDefineResFeature(): never[];
renderTsDefineReqFeature(): never[];
generatorDefineParams(): {
key: string | undefined;
propertiesKey: {
$ref?: undefined;
};
definitionsKey: {
title?: undefined;
type?: undefined;
additionalProperties?: undefined;
properties?: undefined;
description?: undefined;
required?: undefined;
};
} | {
key: string;
propertiesKey: {
$ref: string;
};
definitionsKey: {
title: string;
type: string;
additionalProperties: boolean;
properties: any;
description: string;
required: string[];
};
};
formatProperties(title: string, itemSchema: any): any;
setTypeObjToInstances(preName: string, key: string, itemSchema: any): void;
setTypeNotProperties(preName: string, key: string, itemSchema: any): void;
setTypeNotProperToArrRef(preName: string, key: string, itemSchema: any): void;
generatorDeepDefine(preName: string, key: string, itemSchema: any): void;
parseExampleToSchema(example: string): any;
inferSchemaFromValue(value: any): any;
generatorDefineData(): {
key: string;
propertiesKey: {};
definitionsKey: {};
};
generatorDefineResponse(): ApiInterfaces[];
}
//# sourceMappingURL=base.d.ts.map