0.2.7 • Published 12 months ago

@ccs-ui/open-api v0.2.7

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

open-api 可视化代码生成插件

特性

  • 本地打开 Swagger UI
  • 本地打开 Swagger UI TS 版本
  • 在线生成代码文件:http 请求和 typing.d 定义文件
  • typing 泛型化
  • 根据 controller 生成独立文件

插件安装

  • pnpm add @ccs-ui/open-api

插件启用

export default defineConfig({
  ccsOpenApi: [
    {
      projectName: 'default',
      serversPath: './src/service',
      schemaPath: 'http://136.25.60.144:30472/api/service-sysmgr/v3/api-docs',
      authorization: `Basic bWljcm86QE1pY3JvLC4xMjM=`,
      namespace: 'API',
      commonIntfs: ['Result<T>', 'PageRsp<T>', 'PageReq<T>', 'OrderProp'],
      requestImportStatement: `import { request } from '@/utils/http'`,
    },
    {
      projectName: 'easy-im',
      serversPath: './src/service',
      schemaPath: 'http://136.25.60.143:30314/easy/easy-im/v3/api-docs',
      authorization: `Basic bWljcm86QE1pY3JvLC4xMjM=`,
      namespace: 'APIM',
      commonIntfs: ['Result<T>', 'PageRsp<T>', 'PageReq<T>', 'OrderProp'],
      requestImportStatement: `import { request } from '@/utils/http'`,
    },
  ],
});

参数说明

  • projectName 项目服务名称。
  • serversPath 请求和定义文件生成目录。
  • schemaPath 接口信息地址,参考 swagger 获取的数据。
  • authorization 文档登录凭证。
  • namespace typing 定义的命名空间。
  • commonIntfs 公共类型,统一生成到 common.d.ts 文件中,避免冗余。
  • requestImportStatement: 本地 http 请求引入

生成结果示例

import { request } from '@/utils/http';

/** 清空所有缓存 */
export async function clearAllCachesUsingGet() {
  return request<API.Result<void>>(
    '/easy-im/access/CacheController/clearAllCaches',
    {
      method: 'GET',
    },
  );
}

/** 清空所有组织缓存 */
export async function clearAllOrgsCacheUsingGet() {
  return request<API.Result<void>>(
    '/easy-im/access/CacheController/clearAllOrgsCache',
    {
      method: 'GET',
    },
  );
}
declare namespace API {
  type Result<T> = {
    /** 错误编码 */
    code?: string;
    /** 业务数据 */
    data?: T;
    /** 错误信息 */
    msg?: string;
    /** 业务调用是否成功 */
    success?: boolean;
  };
}
0.2.7

12 months ago

0.2.6

12 months ago

0.2.5

12 months ago

0.2.4

12 months ago

0.2.3

12 months ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago