Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

api-to-interface

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-to-interface

将 yapi 接口数据转换为 typescript interface

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

api-to-interface

将 yapi 接口数据转换为 typescript interface

NPM version NPM David npm

install

npm i api-to-interface -g

初始化

ati init 

此命令将创建 ati.config.js 配置文件

// ati.config.js
module.exports = {
  // yapi 项目 url
  url: '',
  // 项目 id
  projectId: '',
  // yapi 项目 token
  token: '',
  // interface 输出目录
  output: '',
  // 项目内的分组 id
  groupId: [],
  // (可选) 自定义 interface name 
  customInterfaceName: (name, type) => {
    if (type === 'req') {
      return `${name}Req`
    } else {
      return `${name}Res`
    }
  }
}

API signature

type CustomInterfaceName = (name: string, type: string, response: any) => string

interface YapiConfig {
  url: string
  projectId: string
  token: string
  output?: string
  groupId?: string[]
  json2TsOptions?: Partial<Options>
  customInterfaceName?: CustomInterfaceName
}

生成 interface

ati run

configs

属性说明类型默认值
urlyapi 项目 urlstring
projectId项目 idstring
tokenyapi 项目 tokenstring
outputinterface 输出目录string
groupId项目内的分组 idstring[]
customInterfaceName自定义interface nameCustomInterfaceName

support customInterfaceName start at V1.0.6!

Keywords

FAQs

Package last updated on 11 Jan 2021

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