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

fx-spec-hub

v0.0.34

Published

API 规范中心/控制台

Readme

swagger-admin

把本仓库作为一个可复用的依赖包使用:提供 OpenAPI -> TS Client 生成,以及 Strapi 枚举生成。

安装(示例)

在你的其它项目里(推荐开发依赖):

pnpm add -D file:../swagger-admin

或从 git 安装(按你自己的仓库地址调整):

pnpm add -D git+ssh://git@your-host/your-org/swagger-admin.git

CLI

1) 生成 Swagger 客户端

swagger-admin swagger --input ./openapi.json --output ./src/api --baseURL https://api.example.com

也可以输入 URL:

swagger-admin swagger --input https://example.com/openapi.json --output ./src/api --baseURL https://api.example.com

常用可选参数:

  • --baseURL:index.ts 里的 baseURL 字符串(必填)
  • --httpClientPath:HttpClient import 路径(默认 @/utils/request
  • --templateDir:自定义模板目录(默认使用本包 swagger-template
  • --httpClientType axios|fetch:默认 axios

2) 生成 Strapi 枚举

swagger-admin strapi-enums --input https://cms.example.com/api/options --output ./src/api/enum.ts

--input 不包含 ? 时,会自动拼接默认 query(pageSize/locale/populate)。如果你想完全自定义 query,直接把完整 URL(带 ?)传进去即可。

也可以不传 --input,默认使用本包内置的 data/strapi-enum-options.json 进行离线生成。

作为库使用(可选)

import { generateSwaggerApi, generateStrapiEnums } from 'swagger-admin';

await generateSwaggerApi({
  input: 'https://example.com/openapi.json',
  output: './src/api',
  baseURL: 'https://api.example.com',
  onSuccess(result) {
    console.log('生成完成:', result.outputDir);
  },
});

// 不传 input 时,会读取包内默认 OpenAPI JSON;第二个参数 isStrapi 默认为 false
// await generateSwaggerApi({ output: './src/api', baseURL: 'https://api.example.com' }, true);