auto-request
Version:
通过Yapi JSON Schema生成接口Axios或Taro接口
122 lines • 3.2 kB
TypeScript
export interface ParametersDef {
type: 'integer' | 'string' | 'any' | 'body';
description: string;
name: string;
required: boolean;
in: 'query' | 'header' | 'path' | 'body';
enum?: string[];
default: string;
schema?: isRequestParamsSchema<true>;
}
type isRequestParamsSchema<T extends boolean> = T extends true ? RequestParametersDefSchema : ResponsesDefSchema;
export declare enum MethodsType {
Get = "get",
Post = "post",
Delete = "delete",
Put = "put"
}
export interface RequestParametersDefSchema {
type: 'object' | 'array';
properties: {
[key: string]: ResponsesDefSchemaProperties<true>;
};
is_required?: boolean;
required: string[];
}
export interface ResponsesDefSchema {
type: 'object' | 'array';
items?: any;
properties?: {
[key: string]: ResponsesDefSchemaProperties<false>;
};
is_required?: boolean;
example?: string;
}
export interface ProperItems {
type: 'object';
properties: {
[key: string]: ResponsesDefSchemaProperties<false>;
};
}
export interface PropertiesArray<T extends boolean> {
type: 'array';
items: isRequestParamsSchema<T>;
description: string;
}
export interface PropertiesInt {
type: 'integer';
description: string;
}
export interface PropertiesString {
type: 'string';
description: string;
}
export interface PropertiesBool {
type: 'boolean';
description: string;
}
type ResponsesDefSchemaProperties<T extends boolean> = PropertiesArray<T> | PropertiesInt | PropertiesString | PropertiesBool;
export interface GetResponsesDef {
description: string;
schema: isRequestParamsSchema<false>;
}
export interface GetSchemaRes {
[key: number]: GetResponsesDef;
}
export interface GetSchema {
tags: string[];
summary: string;
description: string;
produces: string[];
parameters: ParametersDef[];
responses: GetSchemaRes;
}
export interface Paths {
[MethodsType.Delete]: GetSchema;
[MethodsType.Get]: GetSchema;
[MethodsType.Post]: GetSchema;
[MethodsType.Put]: GetSchema;
}
export interface SwaggerJSON {
swagger: string;
info: {
title: string;
version: string;
};
schemes: string[];
paths: Paths;
}
export interface RootDefine {
title: string;
type: 'object' | 'number' | 'integer' | 'string' | 'array';
properties: RootDefineProperties;
definitions?: RootDefineDefinitions;
additionalProperties: boolean;
required: string[];
}
export interface RootDefineProperties {
$ref: string;
}
export interface childProperties {
title: string;
type: 'object' | 'number' | 'integer' | 'string' | 'array';
items?: {
type: 'object' | 'number' | 'integer' | 'string' | 'array';
$ref?: string;
};
properties: {
[key: string]: childProperties;
};
additionalProperties: boolean;
required: string[];
}
export interface RootDefineDefinitions {
[key: string]: {};
}
export interface ApiInterfaces {
key: string;
propertiesKey?: RootDefineProperties | any;
definitionsKey?: childProperties | any;
}
export {};
//# sourceMappingURL=index.d.ts.map