Socket
Socket
Sign inDemoInstall

hls-doc

Package Overview
Dependencies
71
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hls-doc

a simple comand line tool to generate api doc


Version published
Maintainers
1
Install size
5.91 MB
Created

Readme

Source

hls-doc

Installation

$ npm install -g hls-doc

原理

通过启动一个本地代理的服务器,并修改项目中app请求url为此服务器地址,实现对app请求的拦截,因此可以记录其请求的url、参数以及真实的服务器返回的结果

配置

配置文件命名:doc.config.js,使用commonjs标准导出一个对象

example:

{
    rootPath:"http://172.16.100.107:8093/core/r/api",//基础url
    loginPath:"http://172.16.100.107:8093/core/oauth/token?client_id=client2&client_secret		        =secret&grant_type=password&username=CTAPP&password=CTAPPCTAPP",//中台获取token的url
    basePath: "http://172.16.100.107:8093/core/r/api?sysName=HLS_CT&apiName=",//带查询参数的url
    origin:"http://172.16.100.107:8093",//中台地址
    totalCount:2,//接口列表每页数量为50时的总页数
    headerId:"6ad30e7b-9daa-4836-b634-5c97c7371110",//头表id,可从中台接口返回的值获取
    cookie:'SESSIONID_HAP=36f6f90f-0a99-4a09-be2b-1efb1662b02e; loginKey=e25338c1-84ac-40b7-99eb-      243e321ee23b',//验证的cookie,可从中台接口返回的值获取
    token:'6559fa80-a624-46fb-80f9-a5cfd4ac1621'//防止csrf攻击的token,可从中台接口返回的值获取

}

使用

在所需文件夹下新建doc.config.js,完成上述配置(需保证配置文件中cookie、token的实效性),在当前目录下开启命令行,执行以下命令:

$ hlsDoc

此时服务器会监听本地3000端口,找到项目app/scripts/util.service.js,在hlsHttp服务的post方法体最前部增加url="http://localhost:3000"+url.split("?")[1],用于本地服务器代理所有app请求

在app中,浏览所有页面,输入必要信息,完成数据的交互。所有需要记录的接口均访问后,在浏览器中访问

"http://localhost:3000/end"提示服务器接口请求结束,此时,脚本将在本目录下生成需要的交接文档,格式为doc

FAQs

Last updated on 19 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc