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

1.0.78 • 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,
  ],
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.783latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.783
1.0.772
1.0.760
1.0.752
1.0.740
1.0.730
1.0.720
1.0.710
1.0.700
1.0.690
1.0.670
1.0.662
1.0.652
1.0.640
1.0.630
1.0.622
1.0.610
1.0.600
1.0.592
1.0.580
1.0.570
1.0.560
1.0.550
1.0.542
1.0.532
1.0.522
1.0.512
1.0.500
1.0.490
1.0.480
1.0.472
1.0.462
1.0.452
1.0.442
1.0.430
1.0.420
1.0.412
1.0.400
1.0.392
1.0.380
1.0.370
1.0.360
1.0.352
1.0.342
1.0.330
1.0.322
1.0.310
1.0.302
1.0.290
1.0.282
1.0.272
1.0.262
1.0.252
1.0.240
1.0.230
1.0.222
1.0.210
1.0.200
1.0.192
1.0.182
1.0.172
1.0.160
1.0.150
1.0.140
1.0.132
1.0.120
1.0.110
1.0.102
1.0.91
1.0.80
1.0.62
1.0.52
1.0.42
1.0.22
1.0.12
1.0.00

Package Sidebar

Install

npm i yapi-service-builder-v2

Weekly Downloads

74

Version

1.0.78

License

MIT

Unpacked Size

3.7 MB

Total Files

1088

Last publish

Collaborators

  • weibangxin