api自动生成html,Restful API接口自动生成markdown/html文档

文章目录

Postman

docgen

此处介绍一个方法,用于将Restful API接口自动化生成markdown/html文档,需要用到两个工具

Postman(Restful API接口开发测试工具)

docgen(API文档生成工具)

Postman

下载、安装、创建collection,在collection中做Restful API开发,用于开发测试,在此处不做详述

开发好API后将API导出为json文件,在postman工具中单击 collection,选择 Export 即可实现。

docgen

下载地址:https://github.com/thedevsaddam/docgen

安装

工具使用说明:

[root@×××]$ docgen --help

_____ _____

| __ \ / ____|

| | | | ___ ___ | | __ ___ _ __

| | | |/ _ \ / __| | | |_ |/ _ \ '_ \

| |__| | (_) | (__ | |__| | __/ | | |

|_____/ \___/ \___| \_____|\___|_| |_|

Generate API documentation from Postman JSON collection

For more info visit: https://github.com/thedevsaddam/docgen

Usage:

docgen [command]

Available Commands:

build Build html/markdown documentation from postman collection

help Help about any command

server Serve live html from postman collection

version Provide version information

Flags:

-h, --help help for docgen

Use "docgen [command] --help" for more information about a command.

工具使用举例

假设从postman中导出的json文件名为postman_collection.json

To view live HTML documentation from postman collection

docgen server -f postman_collection.json -p 8000

This will open the html version of postman collection to the defined port

To view live Markown documentation from postman collection

docgen server -f postman_collection.json -p 8000 -m

To make HTML documentation

docgen build -i postman_collection.json -o ~/Downloads/index.html

To make Markdown documentation

docgen build -i postman_collection.json -o ~/Downloads/index.md -m

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
生成REST API文档自动生成Python接口通常需要使用以下工具和步骤: 1. Swagger UI:Swagger UI是一种用于呈现和交互RESTful API的开源工具。使用Swagger UI可以生成REST API的静态文档,并提供可视化的界面,以便用户可以轻松地了解API的用法和参数。您可以使用Swagger UI在线生成REST API文档,也可以在本地运行Swagger UI。 2. Swagger Codegen:Swagger Codegen是一个支持多种语言的命令行工具,可以根据Swagger规范自动生成API客户端库、服务器存根和文档。使用Swagger Codegen可以生成Python客户端库和服务器存根,其中包括Python接口。您可以使用Swagger Codegen在线或在本地运行。 3. 使用Python包管理器安装Swagger客户端库:在Python项目中使用Swagger客户端库可以轻松地调用REST API。您可以使用包管理器(如pip)安装Swagger客户端库,然后将其导入Python代码中。 4. 使用Swagger工具集:Swagger工具集是一组用于设计、构建和文档RESTful API的工具。您可以使用Swagger工具集生成REST API文档,并使用Swagger Codegen生成Python接口和客户端库。 总体而言,生成REST API文档自动生成Python接口需要以下步骤: 1. 设计和编写REST API,并使用Swagger规范定义API。 2. 使用Swagger UI生成REST API文档。 3. 使用Swagger Codegen生成Python接口和客户端库。 4. 使用包管理器安装Swagger客户端库,并将其导入Python代码中。 5. 使用生成的Python接口调用REST API

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值