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

dox-swagger-cli

v0.3.7

Published

dox swagger cli

Downloads

6

Readme

安装

win npm install -g dox-swagger-cli

*nix sudo npm install -g dox-swagger-cli

基本使用

如果,你的代码注释是基于jsdoc style 来写那么就很简单了.只要在原来的注释基础上加几个标签就行.

基于dox 注释提取器,在dox 基础上,补充了几个 swagger 需要的标签.

对于一个api ,你必须拥有如下几个参数

/**
 * get user by id  api 描述
 * @resourcePath /users
 * @path /users/{id} 参数描述
 * @method GET
 * @param {string|paramType=path} id 参数描述
 */
exports.getUserById = function (id, done) {

}

|注释参数|说明| |:--|:--| |@resourcePath|该api 的资源根目录| |@path|该api 具体路径| |@method|http请求方法, GET, POST, PUT, DELETE| |@param|参数,约定第一个为数据类型,string,object,integer,float|

@param

第一个为数据类型,第二个为为api 文档的设置,用竖线 | 分隔

  • paramType path|query|form
  • required true|false

例如例子中id 的paramType 为path 路径,在文档生成时候,就会自动填充路径上同样参数.

文档生成

 Usage: doxswagger [options] [command]

 Commands:

   server [options]       run a simple static server

 Options:

   -h, --help                              output usage information
   -V, --version                           output the version number
   -b, --basePath [http://localhost:1984]  api url path default use localhost
   -d, --description                       api description
   -c, --client [swaggerui]                default swagger ui
   -m, --models [models]                   spec doc models dir
   -o, --output [swaggerdocs]              spec doc output dir
   -i, --input [lib]                       code dir default use lib

一般而言,你需要指定你的代码目录,还有api 访问的地址

doxswagger -i controllers -b  localhost:5000

没有任何东西输出的时候,就说明成功了,你当前目录就会有一个docs 的目录了,你可以把它拷到任何一个静态服务器里面.

接着你用

doxswagger server

用浏览器打开 http://localhost:1984/swaggerdocs 就可以看到生成的文档了

  Usage: server [options]

  Options:

    -h, --help                output usage information
    -s, --server [swaggerui]  spec doc dir
    -p, --port [port]         spec api doc server port

填上你的api-docs 的路径就可以用了..