npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

yapi-to-typescript-test

v3.12.21

Published

根据 YApi 的接口定义生成 TypeScript/JavaScript 的接口类型及其请求函数代码。

Readme

YApi to TypeScript Test codecov

根据 YApiSwagger 的接口定义生成 TypeScript/JavaScript 的接口类型及其请求函数代码。

钉钉扫码加入交流群:

预览

特性

  • 支持多服务器、多项目、多分类
  • 支持预处理接口信息
  • 可自定义类型或函数名称
  • 完整的注释
  • 支持生成 React Hooks 的请求代码
  • 支持参数路径
  • 支持上传文件
  • 支持生成 JavaScript 代码
  • 支持 Swagger

环境要求

  • Node >= 10.19.0
  • YApi >= 1.5.12

安装

# yarn
yarn add yapi-to-typescript

# 或者,npm
npm i yapi-to-typescript --save

使用

yapi-to-typescript 基于当前目录下的 ytt.config.{ts,js} 配置文件进行相关操作。

生成配置文件

使用命令 ytt init 可在当前目录自动创建配置文件 ytt.config.{ts,js},如果配置文件已存在,将会询问你是否覆盖:

# yarn
yarn ytt init

# 或者,npm
npx ytt init

修改配置文件

打开当前目录下的 ytt.config.{ts,js} 配置文件,直接修改即可。查看配置说明

生成代码

直接执行命令 ytt 即可抓取 YApi 的接口定义并生成相应的 TypeScript/JavaScript 代码:

# yarn
yarn ytt

# 或者,npm
npx ytt

配置

概论

从实质上而言,配置就是一个服务器列表,各个服务器又包含一个项目列表,各个项目下都有一个分类列表,其类型大致如此:

type Servers = Array<{
  projects: Array<{
    categories: Array<{
      // ...
    }>
  }>
}>

// 配置实质是一个服务器列表
type Config = Servers

因此,你可分别在 服务器级别项目级别分类级别 进行相关配置,如果不同级别存在相同的配置项,低级别的配置项会覆盖高级别的配置项,也就是说:

  • 如果存在相同的配置项,分类级别 的配置会覆盖 项目级别服务器级别 的配置项;
  • 如果存在相同的配置项,项目级别 的配置会覆盖 服务器级别 的配置项。

配置项

具体配置项见:API 文档

参与贡献

为避免无用功,功能新增或变更请提 issue 由维护者评估后再决定是否继续;功能修复以及经评估可行的功能新增或变更请提 PR。

  • 安装依赖:yarn
  • 运行测试:yarn test

许可

MIT (c) Jay Fong