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

openapi-schema-code

v0.2.18

Published

```node npm i --save-dev openapi-schema-code ``` 在项目根目录新建 ```osc.config.ts``` ```ts const { generate } = require('openapi-schema-code')

Readme

介绍

使用

npm i --save-dev openapi-schema-code

在项目根目录新建 osc.config.ts

const { generate } = require('openapi-schema-code')

generate({
  schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
  serversPath: './servers',
  requestImportStatement: 'import request from "@/utils/request"',
  // apiPrefix: "'apiPrefix'",
  projectName: 'proa',
  single: true,
})

package.jsonscript 中添加 api: "osc": "ts-node osc.config.ts",

生成api

npm run openapi

参数

export type GenerateProps = {
  requestLibPath?: string;
  requestImportStatement?: string;
  /**
   * api 的前缀
   */
  apiPrefix?:
    | string
    | ((params: {
        path: string;
        method: string;
        namespace: string;
        functionName: string;
        autoExclude?: boolean;
      }) => string);
  /**
   * 生成的文件夹的路径
   */
  serversPath?: string;
  /**
   * Swagger 2.0 或 OpenAPI 3.0 的地址
   */
  schemaPath?: string;
  /**
   * 项目名称
   */
  projectName?: string;

  hook?: {
    /** 自定义函数名称 */
    customFunctionName?: (data: OperationObject) => string;
    /** 自定义类型名称 */
    customTypeName?: (data: OperationObject) => string;
    /** 自定义类名 */
    customClassName?: (tagName: string) => string;
    /**
     * 自定义过滤器
     */
    customeFilter?: (api: APIDataType) => boolean;

  };
  namespace?: string;

  /**
   * 默认为false,true时使用null代替可选
   */
  nullable?: boolean;

  mockFolder?: string;
  /**
   * 模板文件的文件路径
   */
  templatesFolder?: string;

  /**
   * 枚举样式
   */
  enumStyle?: 'string-literal' | 'enum';

  /**
   * 单接口 单文件
   */
  single?: boolean;

  /**
   * 是否需要 index文件统一导出,默认不需要,方便做tree-shaking
   */
  ableCombineIndex?: boolean;
  
}

  1. diff 不做删除 只做新增:
  • interface 文件需要预生成一个interface.json 记录当前全量的 types array, 下次生成时 只做 重名update & 新插入
  1. 文件单个生成
  2. 模板 使用js 文件
  3. 增加 filter 来过滤接口
  4. 接口(文件)名自定义, 重名文件如何处理