当前位置:网站首页>Swagger UI教程 API 文档神器
Swagger UI教程 API 文档神器
2022-07-06 12:45:00 【51CTO】
目录
[TOC]
前言
在一些接口项目中,API的使用很频繁,所以一款API在线文档生成和测试工具非常有必要。而Swagger UI就是这么一款很实用的在线工具
本博客介绍如何在公司或者自己的电脑上按照Swagger UI,注意因为公司的测试服务器是Linux系统的,所以本博客也只介绍基于Linux系统的Swagger环境搭建过程
服务器环境安装##
NodeJS下载部署###
首先需要下载NodeJS,到nodejs官网 http://nodejs.org/dist/v0.10.26,下载node-v0.10.26-linux-x64.tar.gz,因为这个是已经编译好的,所以我们先使用软件将文件上传到Linux服务器,可以使用WinSCP
然后用Linux的cd命令进入到你nodejs压缩文件的位置
解压命令如下:
然后进入文件
执行
设置node全局
设置npm全局
检测nodejs和npm是否安装成功
可以看到版本号,什么安装成功
express下载部署####
安装好NodeJS和NPM之后,我们就可以安装express了
以下几个重要的模块是需要与 express 框架一起安装的:
body-parser - node.js 中间件,用于处理 JSON, Raw, Text 和 URL 编码的数据。
cookie-parser - 这就是一个解析Cookie的工具。通过req.cookies可以取到传过来的cookie,并把它们转成对象。
multer - node.js 中间件,用于处理 enctype="multipart/form-data"(设置表单的MIME编码)的表单数据。
检测是否安装成功
NodeJS开机启动####
然后设置NodeJS开机启动
安装forever
设置
Swagger UI安装部署##
github上clone: https://github.com/swagger-api/swagger-ui 如果有下载Git,就是用git下载,获取访问github,直接下载
之后可以根据公司需要,在Linux上mkdir,我是先在root路径,创建一个node_app文件
进入node_app
环境配置
下面的提示可以根据自己需要填写
VI编辑器使用:
加入代码
启用服务器
访问,输入http://公司服务器IP:3000
可以看到Helloworld,当然我们是要部署Swagger
在node_app下面创建一个public文件夹
然后将下载到的swagger ui里的dist文件夹里的文件复制到public文件夹里
修改index.js
然后输入 http://ip:3000/swapper,是可以看到类似page

这里写图片描述
Swagger Editor使用##
Swagger Editor是Swagger UI的在线编辑器,我们可以自己搭建一个,也可以使用官方的,下面给出官方的URL: http://editor.swagger.io/#/
github上Clone: https://github.com/swagger-api/swagger-editor 之后将swagger editor文件放在公司Linux服务器上
Http server安装###
启动该项目http-server swagger-editor,默认为8080端口
设置port并启动swagger editor
输入 http://ip:2017/#/可以访问到自己搭建的Swagger Editor编辑器
参考教程
http://www.linuxidc.com/Linux/2014-07/104489.htm
http://www.linuxidc.com/Linux/2014-06/103372.htm
边栏推荐
- What is the problem with the SQL group by statement
- [wechat applet] operation mechanism and update mechanism
- 全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
- Basic knowledge of lists
- 知识图谱构建流程步骤详解
- Utilisation de l'écran OLED
- 【每周一坑】信息加密 +【解答】正整数分解质因数
- 解剖生理学复习题·VIII血液系统
- Trends of "software" in robotics Engineering
- What are RDB and AOF
猜你喜欢
![[weekly pit] calculate the sum of primes within 100 + [answer] output triangle](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[weekly pit] calculate the sum of primes within 100 + [answer] output triangle

逻辑是个好东西

小孩子學什麼編程?

Pycharm remote execution
![[DSP] [Part 2] understand c6678 and create project](/img/06/54b1cf1f5b3308fffb4f84dcf7db9b.png)
[DSP] [Part 2] understand c6678 and create project

Activiti global process monitors activitieventlistener to monitor different types of events, which is very convenient without configuring task monitoring in acitivit

【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和

Reinforcement learning - learning notes 5 | alphago

Trends of "software" in robotics Engineering

1_ Introduction to go language
随机推荐
JMeter server resource indicator monitoring (CPU, memory, etc.)
强化学习-学习笔记5 | AlphaGo
Basic knowledge of lists
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
SSO single sign on
C language games - minesweeping
2022 construction electrician (special type of construction work) free test questions and construction electrician (special type of construction work) certificate examination
New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
1_ Introduction to go language
【每周一坑】输出三角形
Reinforcement learning - learning notes 5 | alphago
PG基础篇--逻辑结构管理(事务)
Manifest of SAP ui5 framework json
[DSP] [Part 1] start DSP learning
Taylor series fast Fourier transform (FFT)
Infrared thermometer based on STM32 single chip microcomputer (with face detection)
Redis insert data garbled solution
In line elements are transformed into block level elements, and display transformation and implicit transformation
Event center parameter transfer, peer component value transfer method, brother component value transfer
2022 nurse (primary) examination questions and new nurse (primary) examination questions