yapi-devloper-mcp
Version:
YApi MCP Integration
136 lines (135 loc) • 3.47 kB
TypeScript
export interface ApiInterface {
_id: string;
title: string;
path: string;
method: string;
project_id: number;
catid: number;
req_params: Array<{
name: string;
desc: string;
required: "0" | "1";
}>;
req_body_form: Array<{
name: string;
type: "text" | "file";
required: "0" | "1";
desc?: string;
}>;
req_headers: Array<{
name: string;
value: string;
required?: "0" | "1";
desc?: string;
}>;
req_query: any[];
req_body_type: string;
res_body_type: string;
req_body_other: string;
res_body: string;
desc: string;
markdown: string;
}
export interface GetApiResponse {
errcode: number;
errmsg: string;
data: ApiInterface;
}
export interface LoginResponse {
errcode: number;
errmsg: string;
data: any;
}
export interface AuthConfig {
type: 'password' | 'token';
username?: string;
password?: string;
token?: string;
}
export interface ListResponse<T> {
errcode: number;
errmsg: string;
data: {
count: number;
total: number;
list: T[];
};
}
export declare class YApiError extends Error {
code: number;
response?: any | undefined;
constructor(message: string, code: number, response?: any | undefined);
}
export declare class YApiService {
private readonly baseUrl;
private token;
private readonly authConfig;
private axiosInstance;
private cookies;
constructor(baseUrl: string, authConfig: AuthConfig);
login(): Promise<void>;
private ensureToken;
private request;
getApiInterface(id: string): Promise<ApiInterface>;
createBasicInterface(data: {
title: string;
path: string;
method: string;
project_id: number;
catid: number | string;
tag?: string[];
desc?: string;
res_body_type?: string;
res_body?: string;
}): Promise<ApiInterface>;
updateInterfaceDetails(id: string, data: {
title?: string;
path?: string;
method?: string;
req_params?: any[];
req_body_form?: any[];
req_headers?: any[];
req_query?: any[];
req_body_type?: string;
res_body_type?: string;
res_body?: string;
desc?: string;
markdown?: string;
tag?: string[];
status?: string;
switch_notice?: boolean;
api_opened?: boolean;
req_body_is_json_schema?: boolean;
res_body_is_json_schema?: boolean;
catid?: string | number;
req_body?: any;
[key: string]: any;
}): Promise<ApiInterface>;
createFullInterface(data: {
title: string;
path: string;
method: string;
project_id: number;
catid: number | string;
desc?: string;
req_params?: any[];
req_body_form?: any[];
req_headers?: any[];
req_query?: any[];
req_body_type?: string;
res_body_type?: string;
res_body?: string;
markdown?: string;
tag?: string[];
status?: string;
switch_notice?: boolean;
api_opened?: boolean;
req_body_is_json_schema?: boolean;
res_body_is_json_schema?: boolean;
req_body?: any;
req_body_other?: any;
}): Promise<ApiInterface>;
private retryRequest;
private requestLogger;
private handleError;
}