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 🙏

© 2026 – Pkg Stats / Ryan Hefner

yapi-ts-codegen

v1.1.2

Published

A tool to generate typescript interfaces from yapi

Readme

yapi-ts-codegen

NPM

Yapi codegen ts can automatically generate type definitions for each layer based on the data structure returned by YAPI. Additionally, it allows you to configure whether to generate request functions.

Installation

npm install yapi-ts-codegen

Generate config file

npx yts --init

config file demo

{
  // yapi url, you can get it from project setting
  "apiUrl": "https://yapi.xxx.com/api/open/plugin/export-full?type=json&pid=111&status=all&token=token",
  
  // request function, you can use "" to remove it
  "append": `import request from '@/api/request';`,

  // clear the generated files
  "clear": true,

  // save error logs or not  yts.error.log
  "saveErrLog": true,

  // output
  "output": 'src/api-type',

  // includeReg for filter
  "includeReg": [/api|apiv2/g],
  
  // excludeReg for filter
  "excludeReg": [/\?act=.+$/],
}

Run it

npx yts --clear

Demo

Schema data

// monthbill api name
{
  "$schema":"http://json-schema.org/draft-04/schema#",
  "type":"object",
  "properties": {
    "startMonth":{ 
      "type":"string"
    },
    "endMonth": {
      "type":"string",
      "description":"2024-10"
    }
  },
  "required": ["startMonth","endMonth"]
}

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errNo": {
      "type": "number"
    },
    "errstr": {
      "type": "string"
    },
    "data": {
      "type": "object",
      "properties": {
        "contents": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "month": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "fullName": {
                "type": "string"
              },
              "feeType": {
                "type": "string"
              },
              "fee": {
                "type": "number"
              },
              "feeDetail": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "type": {
                      "type": "string"
                    },
                    "price": {
                      "type": "number"
                    }
                  },
                  "required": ["count", "type", "price"]
                }
              },
              "productName": {
                "type": "string"
              },
              "appName": {
                "type": "string"
              }
            },
            "required": ["month", "name", "fullName", "feeType", "fee", "feeDetail", "productName", "appName"]
          }
        },
        "sumFee": {
          "type": "number"
        }
      }
    }
  }
}

Output type data

import request from '@/api/request';

export interface PostMonthbillReq {
    endMonth:   string;
    startMonth: string;
    [property: string]: any;
}

export interface PostMonthbill {
    data?:   PostMonthbillData;
    errNo?:  number;
    errstr?: string;
    [property: string]: any;
}

export interface PostMonthbillData {
    contents?: PostMonthbillContent[];
    sumFee?:   number;
    [property: string]: any;
}

export interface PostMonthbillContent {
    appName:     string;
    fee:         number;
    feeDetail:   PostMonthbillFeeDetail[];
    feeType:     string;
    fullName:    string;
    month:       string;
    name:        string;
    productName: string;
    [property: string]: any;
}

export interface PostMonthbillFeeDetail {
    count: number;
    price: number;
    type:  string;
    [property: string]: any;
}

export async function apiPostMonthbill(data: PostMonthbillReq): Promise<PostMonthbill> {
  return request({
    url: '/monthbill',
    method: 'POST',
    headers: {
      "content-type": 'application/json',
    },
    data: data,
  });
}