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 🙏

© 2024 – Pkg Stats / Ryan Hefner

apitots-swaggers

v1.1.3

Published

当前端web项目中应用了ts,我们不可能对成千上百的接口进行 interface的类型定义,那样效率是极低的,但是我们又需要ts智能友好的提示信息,该怎么办?这是我们必须要面对的问题。

Downloads

13

Readme

apitots-swaggers swagger自动生成ts

当前端web项目中应用了ts,我们不可能对成千上百的接口进行 interface的类型定义,那样效率是极低的,但是我们又需要ts智能友好的提示信息,该怎么办?这是我们必须要面对的问题。

介绍

根据swagger.json地址迅速生成ts接口,以及相关请求响应参的interface模块命令行工具。且支持swagger的V2、V3版本。其宗旨是利用swagger接口文档让前端的效率变得更高,接口的请求参、响应参以及接口命名将不在需要手动引入,让前端更聚焦在业务功能的开发,接口将全面与swagger进行同步。

快速入门

1.安装

npm i apitots-swaggers -g 或者yarn add apitots-swaggers -g

ps:

全局安装能让命令在任何地方能运行,如果只安装在项目上,可执行文件将被安装到 node_modules/.bin下,通常这个目录通常不会被加入系统的 PATH 环境变量,所以就需要在script内定义脚本进行运行方可成功跑通脚本,如下:

"scripts": {
    "apits:init": "apits init",
    "apits:gen": "apits tots",
  }

全局安装则不需要,可直接运行apits命令,两种方式可任意选择。

2.帮助文档

输入apits,根据命令提示进行操作,如图。

Local Image

创建配置文件

apits init 

执行配置文件生成代码

apits tots

执行完成完成如图 Local Image

3.API说明

| 参数 | 说明 | 类型 | 是否必填 | 默认值 | |:----------:|:----------:|:----------:|:----------:|:----------:| | serverUrl | 服务地址,此处填其 json 地址 | string | 是 | | | requestInstanceUrl | 请求文件路径(request路径) | string | 否 | axios | | outputFilePath | 输出文件路径 | string | 否 | src/api | | ImportBaseURL | 设置接口的baseURL导入地址 | string | 否,搭配baseURL | | | baseURL | 设置接口的baseURL | string | 否,搭配ImportBaseURL | | | includeTags | 包含的接口Tag | string | 否 | [] | | excludeTags | 排除的接口Tag | string | 否| [] | | prefix | 添加前缀,如代理请求模式,所有请求均请求到指定接口 | string | 否 | |

4.示例

配置:

Local Image

结果:

Local Image

注意:

1.如出现生成出错,请检查后端返回的json是否服务标准。

2.生成格式会默认配置,如果本地有配置.prettierrc,会自动读取.prettierrc内配置,根据配置生成具体的代码格式

3.配置baseURL的文件需要指定文件路径,内容全量导出。