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

ka-ytt

v1.0.2

Published

根据yapi接口定义,生成对应的ts类型定义文件

Downloads

2

Readme

ka-ytt

YAPI 接口定义生成工具

安装

npm i -g ka-ytt

使用

进入项目,执行ka-ytt

进入 yapi 项目,点击生成按钮

参数

使用ka-ytt --help 查看所有参数

Options:
-p, --path <path>                指定生成接口类型定义文件的目标路径 (default: "src/api/model")
-d, --dataKey <key>              指定具体的key作为response的返回内容,若不指定默认为整个response (default: "data")
-i, --interface-prefix <prefix>  指定接口的前缀,如:ApiLogin (default: "api")
-q, --request-suffix <suffix>    指定请求类型接口的后缀,如:ApiLoginRequest (default: "request")
-r, --response-suffix <suffix>   指定响应类型接口的后缀, 如:ApiLoginResponse (default: "response")
-f, --file-suffix <suffix>       指定接口文件的后缀,如loginModel.ts (default: "Model")
-v, --version                    查看当前版本号

指定生成接口类型定义文件的目标路径,参数 -p--path,默认值src/api/model 比如文件目录如下,我希望在 login 页面下生成定义文件,并且放入 login-model 文件中,可以执行如下命令:ka-ytt src/views/login/custom-model

|-- src
|-- api
|-- views
|-- login

指定具体的 key 作为 response 的返回内容,参数 -d--dataKey,默认值data 目前@wshoto/lib-base中的request,直接返回 data,这里无需修改

指定接口的前缀,参数 -i--interface-prefix,默认值api 这里的主要作为是为了在编辑器中输入首字母有提示,比如说你喜欢的风格是I开头的接口命名风格,可以执行命令:ka-ytt -i i

// 默认
export interface ApiLoginRequest {...}
export interface ApiLoginResponse {...}

// 指定风格
export interface ILoginRequest {...}
export interface ILoginResponse {...}

指定请求类型接口的后缀,参数-q--request-suffix,默认值request 比如希望使用Params为后缀,可以执行命令:ka-ytt -q params

// 默认
export interface ApiLoginRequest {...}

// 指定后缀
export interface ApiLoginParams {...}

指定响应类型接口的后缀,参数-r--response-suffix,默认值response 比如希望使用Res为后缀,可以执行命令:ka-ytt -r res

// 默认
export interface ApiLoginResponse {...}

// 指定后缀
export interface ApiLoginRes {...}

指定接口文件的后缀,参数-f--file-suffix,默认值Model 比如希望使用Mod为后缀,可以执行命令:ka-ytt -f mod(不建议修改)

// 默认
loginModel.ts

// 指定后缀
loginMod.ts