New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@xm-fe/create-api

Package Overview
Dependencies
Maintainers
7
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xm-fe/create-api

API快速导入

  • 0.0.5-beta.1
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-38.89%
Maintainers
7
Weekly downloads
 
Created
Source

⚡️ 简介

鲜沐科技 前端API生成工具

🚀 使用

npm i @xm-fe/create-api -g

运行capi命令时,会读取当前项目根目下的的 capi.config.js文件,该文件中的配置会覆盖默认配置文件。

capi.config.js 具体配置及解释看文末

方式一

capi http://127.0.0.1:4523/export/openapi/5?version=3.0

直接使用导出的地址,无需再拼写 projectId

备注:此方法不适用于 全部导出,如需全部导出请使用 方式二

方式二

capi http://127.0.0.1:4523/export/openapi/9?version=3.0 954456

capi apifox导出的URL projectId

方式三

capi

读取项目根目录配置文件 capi.config 中的 remotePath

默认项目配置

        954456: 'SAAS',
        1164722: 'summerfarm-manage',
        1164725: 'pms-service',
        1295278: 'summerfarm-crm',
        1409074: 'tms',
        1965722: 'summerfarm-wms',
        2020406: 'OFC',
        2437205: 'saas-manage',
        2437206: 'saas-oms',
        2437207: 'saas-mall',
        2517920: 'summerfarm-wnc',
        2546551: 'saas-pms',
        2546569: 'SCP',
        2546585: 'SRM',
        2546600: 'bms-service',
        2737704: 'summerfarm-mall'

缺少的项目 请联系我加进去

0.0.1

  • 初始化

🚀 开发


# 安装依赖
npm i
# 发布流程

# 编译
npm run build

# 本项目
npm link

# 引用调试的项目
npm link 包名

# 取消关联
npm unlink 包名

# 查看
npm ls -g

capi.config.js 配置

module.exports = {
  remotePath: `http://127.0.0.1:4523/export/openapi/4?version=3.0`,
  // 插入的模板代码
  getApiCodeTpl(api) {
    const pathParams = api.pathParams
      .map((param) => `${param.name}${param.required ? '' : '?'}: ${param._type},`)
      .join('\r\n')
    return `
  import net from '@/utils/net'
  import { NetConfig } from '@/interface/IAxiosConfig'
  /**
   * ${api.summary}
   */
  export function ${api.name}(
    ${pathParams ? pathParams : ''}
    ${api.queryParams ? `params?: ${api.queryParams._name},` : ''}
    ${api.bodyParams ? `data?: ${api.bodyParams._name},` : ''}
    config?: NetConfig
  ): Promise<${api.resType}> {
    return net(
      {
        url: \`${api.url}\`,
        method: '${api.method}',
        ${api.isDownload ? `_download: true,` : ''}
        ${api.queryParams ? `params,` : ''}
        ${api.bodyParams ? ` data,` : ''}
      },
      config
    )
  }
  `
  }
}

Keywords

FAQs

Package last updated on 20 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc