import { SwaggerFetchOptions, CustomPath } from '../interfaces'; export declare type Url = string | [string, // swagger url string] | [string, // swagger url string, // swagger url 生成接口所在对应的文件夹名称 // swagger url 生成接口所在对应的文件夹名称 SwaggerFetchOptions | undefined]; export interface Options { extraImport?: string; /** * 同来替换 默认 生成的方法字符串 */ renderFunction?: (options: RenderFunctionOptions, path: CustomPath) => string; tagAlias?: TagAlias; include?: RegExp | string[]; exclude?: RegExp | string[]; fetchOptions?: SwaggerFetchOptions; urls: Url[]; hasBasePath?: boolean; outputPath: string; /** * 发送请求时是否需要传入自定义的属性 * @default true */ hasExtraFetchOptions?: boolean; /** * 返回 导入 request 的字符串 * @default () => `import request from '@/utils/request'`; */ importRequest?: (path: string) => string; /** * 返回 导入 stringify 的字符串 * @default () => `import stringify from '@/utils/stringify'`; */ importStringify?: (path: string) => string; /** * 返回 导入 ExtraFetchOptions 的字符串 * @default () => `import { ExtraFetchOptions } from '@/types'`; */ importExtraFetchOptions?: (path: string) => string; } /** * renderFunction 的参数 */ export interface RenderFunctionOptions { basePath: string; url: string; name: string; responseType: string; payloadType?: string; queryType?: string; paramsType?: string; paramsTypeMap: { [name: string]: string; }; method: string; hasBody: boolean; hasQuery: boolean; hasParams: boolean; extraFetchOptionsParaName: string; } /** * swagger tag 别名 * 用作生成的文件夹名称 */ export interface TagAlias { [key: string]: string; } export interface InterfaceNames { query: string; body: string; payload: string; } export declare const enum ParaPayloadName { query = "query", body = "body" } export interface PayloadContent { name: ParaPayloadName | string; typeName: string; description?: string; } export declare enum Status { success = "success", error = "error" } export interface GenMessage { outputPath: string; message: string; status: Status; } export interface GenMessageWrapper { successMessages: GenMessage[]; errorMessages: GenMessage[]; } export declare enum CommentType { single = 0, singleRight = 1, multiline = 2 } /** * 需要生成的 interface 结构 */ export interface InterfaceModel { /** * interface 字符串形式的结构 */ content: string; /** * 这个 interface 关联的 其他 interface 名称 */ relatedInterfaceNames: string[]; } /** * 需要生成的 一个文件 结构 */ export interface ApiModel extends InterfaceModel { hasQuery: boolean; }