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 🙏

© 2025 – Pkg Stats / Ryan Hefner

unoapi-vscode-extension

v0.0.2

Published

自动生成前端 API 代码

Downloads

95

Readme

UnoAPI 自动化编码助手

Version Installs

基于 OpenAPI 规范自动生成前端 API 代码的 VS Code 扩展。

✨ 功能特性

  • 🚀 一键生成 - 从 OpenAPI 文档自动生成 TypeScript API 代码
  • 🔍 智能搜索 - 支持关键字搜索接口,快速定位需要的 API
  • 📝 类型安全 - 自动生成 TypeScript 类型定义
  • 🎯 灵活配置 - 支持自定义函数模板、类型映射等
  • 📊 状态栏显示 - 实时显示配置状态,一键初始化
  • 🎨 多种生成方式 - 支持生成全部接口、单个接口或仅 Model

📦 安装

在 VS Code 扩展市场搜索 UnoAPI点击安装

🚀 快速开始

1. 初始化配置

点击状态栏的 ⚠ UnoAPI 或运行命令 UnoAPI: [init] 生成配置文件

初始化配置

2. 生成 API 代码

  • 命令面板: Ctrl/Cmd + Shift + PUnoAPI: [code] 生成 API 代码
  • 右键菜单: 在文件或文件夹上右键 → UnoAPI: [code] 生成 API 代码
  • 状态栏: 点击 ✓ UnoAPI

生成代码

3. 选择接口

  • 输入关键字搜索接口
  • 支持多选
  • 选择 "生成所有接口" 可一次性生成全部

选择接口

📝 配置说明

支持三种配置方式:

package.json

{
  "unoapi": {
    "openapiUrl": "https://api.example.com/openapi.json",
    "output": "src/api"
  }
}

unoapi.config.js

export default {
  openapiUrl: 'https://api.example.com/openapi.json',
  output: 'src/api',
  typeMapping: {
    integer: 'number'
  }
}

unoapi.config.ts

import { defineUnoConfig } from '@unoapi/core';

export default defineUnoConfig({
  openapiUrl: 'https://api.example.com/openapi.json',
  output: ['src/api', 'src/models'],
  funcTpl: (context) => {
    return `export function ${context.name}() { /* custom */ }`;
  }
});

🎯 配置选项

| 选项 | 类型 | 默认值 | 说明 | |------|------|--------|------| | openapiUrl | string | - | OpenAPI 文档地址 | | output | string \| [string, string] | src/api | 输出目录,数组表示 [API目录, Model目录] | | cacheFile | string | .openapi-cache.json | 缓存文件路径 | | typeMapping | Record<string, string> | - | 自定义类型映射 | | funcTpl | Function | - | 自定义函数模板 | | asGlobalModel | boolean | false | 是否生成全局类型 | | imports | string \| string[] | - | API 文件头部导入代码 |

🎨 使用场景

场景 1: 生成单个接口

  1. 打开目标文件
  2. 右键 → UnoAPI: [code] 生成 API 代码
  3. 选择接口
  4. 输入自定义函数名(可选)
  5. 代码自动追加到当前文件

场景 2: 生成到指定目录

  1. 在资源管理器中右键文件夹
  2. 选择 UnoAPI: [code] 生成 API 代码
  3. 选择接口
  4. 代码生成到选中的目录

场景 3: 仅生成 Model

  1. 运行命令 UnoAPI: [model] 生成 Model 代码
  2. 选择接口
  3. 只生成 TypeScript 类型定义

🔧 命令列表

| 命令 | 说明 | |------|------| | UnoAPI: [init] 生成配置文件 | 初始化配置文件 | | UnoAPI: [download] 下载 OpenAPI 文档 | 下载并缓存 OpenAPI 文档 | | UnoAPI: [code] 生成 API 代码 | 生成 API 函数和类型 | | UnoAPI: [model] 生成 Model 代码 | 仅生成类型定义 |

📊 状态栏

  • ✓ UnoAPI - 已配置,点击生成代码
  • ⚠ UnoAPI - 未配置,点击初始化
  • ⏳ UnoAPI - 正在加载文档

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT

🔗 相关链接


Made with ❤️ by 前端星河