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

vswagger-cli

v1.2.1

Published

vue接口自动化

Downloads

56

Readme

vswagger npm package

vswagger是一个基于 swagger 快速生成 API 调用文件的命令行工具, 主要功能将接口同步到本地文件

  • Installation

Prerequisites: Node.js (>=6.x, 8.x preferred), npm version 3+ and Git.

$ npm install -g vswagger-cli
  • Usage

$ vswagger init

Example:

$ vswagger init
  • 使用方法(步骤):

  1. 全局安装vswagger
npm install -g vswagger-cli
  1. 添加根目录配置文件 .vswagger.js

/**
 * .vswagger 配置文件
 */

module.exports = {
    template: '', // 可为空使用默认接口生成模板
    generateType: 'souche', // 默认不要写
    safe: true, // 是否生成保护数据
    output: "src/api", // 输出到api目录
    projectDir: "src", // 代码存放目录(可不配置默认为src路径)
    suffix: [".js",".vue"], // 指定查询的文件(可不配置,默认.js,.vue文件)
    projects: [{
        version: '2.x', 
        domain: 'TEST', // 环境变量
        token: '值', // swagger令牌
        modelName: "demo1", // 模块化名称
        docUrl: ['api-docs', 'api-docs', 'api-docs', 'api-docs']  // swagger base-url
    }, {
        version: '1.x', 
        domain: 'TEST', // 环境变量
        token: '值', // swagger令牌
        modelName: 'demo2',
        docUrl: ['api-docs'] // 多个
    }] // 项目配置
};
  1. 生成接口
vswagger init
  1. 只更新/生成某个模块的接口
vswagger init 项目目录(.vswagger.js目录) 模块名称(a模块,b模块,c模块)
vswagger init ./ a
  1. 项目结束后开始清理无用的接口
vswagger clean
  1. 增加接口保护功能
通过safe开启
  1. 新增接口检测功能
vswagger check

8.支持2.x版本数据结构解析处理

直接上图看效果

生成的目录

index.js 文件是接口存放文件 instance.js 文件是配置 开发/预发/线上 接口访问的域名 util.js 文件是工具方法

 模块化结构

生成接口结构

 接口结构

配置接口访问的域名

调用接口

打包时会检查接口是否有遗漏(如果有遗漏会给出提示)

 清理接口接口遗漏