yapi-service-builder-v2
TypeScript icon, indicating that this package has built-in type declarations

1.0.77 • Public • Published

描述

使用auto-services从yapi下载多个swagger.json (命名为Type1.json, Type2.json ...........)

使用webpack进行打包,导出模块

导出模块的结构

export yApiAjax //配置请求地址和token相关

export PlatformAccess, //导出命名空间,包含apisType1涉及到全部数据结构

export const apisPlatformAccess, //聚合了按照名称分类的接口 (yapi接口分类) export const apisWsPlatformAccess, //包含websocket接口

export Type2,//导出命名空间,包含apisType2涉及到全部数据结构

export const apisType2 //聚合了按照名称分类的接口 (yapi接口分类)

使用

    Typescript :

    import { apisPlatformAccess, PlatformAccess, yApiAjax } from "yapi-service-builder-v2";

    const authLoginBody: PlatformAccess.AuthLoginBody = {
        username: "1",
        password: "1",
    };

    apisPlatformAccess.AuthApi.authLoginPost(authLoginBody).then((result) => {
    if(result.code == 0){
        yApiAjax.ConfigServerInfo("", result.data.token, () => {});

        setTimeout(() => {
            apisPlatformAccess.AuthApi.authLogoutPost({})
            }, 3000)
        }
    });

    apisPlatformAccess.AuthApi.authUserinfoGet(
    {},
    { headers: { Authorization: "", Cookie: "" } }
    );

tips

yapi中为字段添加枚举时:

枚举是string类型的,会生成对应的枚举类型。字段类型将为该枚举类型。

枚举是number类型的,无法自动生成对应的枚举。枚举是string类型是正常的。为了代码提示,生成程序将备注添加到description

{
  "type": "number",
  "description": "报警类型",
  "enum": [
    1,
    2,
  ],
  "enumDesc": "磁盘错误,磁盘空间不足"
}

将转换成

{
  "type": "number",
  "description": "报警类型: 磁盘错误,磁盘空间不足",
  "enum": [
    1,
    2,
  ],
}

Readme

Keywords

none

Package Sidebar

Install

npm i yapi-service-builder-v2

Weekly Downloads

7

Version

1.0.77

License

MIT

Unpacked Size

4.9 MB

Total Files

1088

Last publish

Collaborators

  • weibangxin