1.0.13 • Published 1 year ago

ypts v1.0.13

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

ypts

yapi to typescript

一个将yapi转化为typescript定义的🔧

配置

暂时只支持用户名密码登录,不支持LDAP登录方式

url -> yapi地址
email -> yapi用户名
password -> yapi用户密码

一次配置终身使用 -> 配置文件路径~/.ypts.json

举个🌰

在命令行的工作目录下生成两个目录文件 yapiInterface/index.ts -> 参数与返回值定义文件 ypaiService/index.ts -> 接口定义文件

 ypts http://yidod.co:6090/project/13/interface/api/15
🌟 文件生成成功
 

yapiInterface/index.ts

/**
* 测试接口1
* request params类型
*/
export type TApiGetTestGETParams ={
  /** 备注1 */
  id?: string;
  /** 备注2 */
  name?: string;
};

/**
* 测试接口1
* request body类型
*/
export type TApiGetTestGETReq = {
  name?: {
    name1?: string;
  };
  password?: string;
}
/**
* 测试接口1
* response body类型
*/
export type TApiGetTestGETRes = {
  /** 备注2 */
  /** 备注3 */
  data?: string;
}

yapiService/index.ts

/**
 * 测试接口1
 * request params类型
 */
export const apiApiGetTestGETRes = ( params: TApiGetTestGETParams,  data: TApiGetTestGETReq) => { 
  return request<TApiGetTestGETRes>(`/api/get/test`, {
    method: 'GET',
    params,
    data,
  });
};

如果文件存在的话会提示删除同名的yapiInterfaceyapiService文件夹及其中所有文件「此步骤谨慎操作

 ypts http://yidod.co:6090/project/13/interface/api/15
? 存在yapiService文件夹,即将删除该文件夹及其文件 › - Use arrow-keys. Return to submit.
❯   是
    否
1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago