API Blueprint的安装

2024-04-12 07:08
文章标签 安装 api blueprint

本文主要是介绍API Blueprint的安装,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

什么是API Blueprint

API Blueprint 是一套基于 markdown 的 API 描述语言规范,API Blueprint 配套工具可以生成对应的HTML文档进行查看,方便生成离线文件保存,也便于对文件的查看

API Blueprint的工具

Aglio

aglioAglio是一种将API文件转换为HTML的工具。Aglio是惊人的,它非常快,默认情况下有一个很好的设计,并且可以通过自定义主题进行扩展。

Drafter

Drafter是由定义API Blueprint规范的Apiary制定的。您指定一个API Blueprint文件,然后Drafter将其转换为JSON对象。然后可以将此JSON对象提供给各种可解析API Blueprint JSON的工具。

Httpsnippet

Mashape提供的httpsnippet是一款非常棒的工具,它会采用HAR文件并为各种语言生成代码片段。

API Blueprint生成文件的流程图

这里写图片描述

API Blueprint工具 Aglio的安装

安装过程:

准备

在Visual Studio Code中安装API Blueprint
1、nodeJs环境的安装,npm的安装,Python的安装,并在Visual Studio Code的用户设置中设置Python的安装路径;
2.安装Aglio
执行命令:

npm install -g aglio

产生报错信息:

在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
D:\ST\nodejs\node_global\node_modules\aglio\node_modules\protagonist\build\drafter\libdrafter.vcxproj(20,3): error MSB4019: 未找到导入的项目“D:\Microsoft.Cpp.Defau
lt.props
”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。
D:\ST\nodejs\node_global\node_modules\aglio\node_modules\protagonist\build\drafter\ext\snowcrash\libmarkdownparser.vcxproj(20,3): error MSB4019: 未找到导入的项目“D
:\Micros
oft.Cpp.Default.props”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。
D:\ST\nodejs\node_global\node_modules\aglio\node_modules\protagonist\build\drafter\ext\snowcrash\libsnowcrash.vcxproj(20,3): error MSB4019: 未找到导入的项目“D:\Mic
rosoft.C
pp.Default.props”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。
D:\ST\nodejs\node_global\node_modules\aglio\node_modules\protagonist\build\drafter\libsos.vcxproj(20,3): error MSB4019: 未找到导入的项目“D:\Microsoft.Cpp.Default.p
rops”。请确
认 <Import> 声明中的路径正确,且磁盘上存在该文件。
D:\ST\nodejs\node_global\node_modules\aglio\node_modules\protagonist\build\drafter\ext\snowcrash\libsundown.vcxproj(20,3): error MSB4019: 未找到导入的项目“D:\Micro
soft.Cpp
.Default.props”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\ST\nodejs\node_global\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 6.1.7601

网上提供解决方案:

npm install -global -production windows-build-tools

通过执行该命令,发现主要是安装Python,本人已直接本地安装过Python,并设置过环境变量,并在VIsual Studio Code中设置”python.pythonPath”为本地安装路径

最终通过仔细查找报错信息发现是因为未安装C++编译环境,最后安装了一个 Visual Studio Community 2017,并安装了Microsoft Visual C++ Redistributable for Visual Studio 2017;

上述两文件下载路径均在:
https://www.visualstudio.com/zh-hans/downloads/?rr=http%3A%2F%2Flandinghub.visualstudio.com%2Fvisual-cpp-build-tools

安装后在执行npm install -g aglio,执行过程中需注意若安装了360可能会拦截权限更改,所有点击允许,最终安装成功。

Aglio的使用

foo.md编写的源文件;
bar.html是输出的HTML文件;
进入foo.md文件所在路径,执行命令:

aglio -i foo.md -o bar.html

输出文件bar.html在foo.md文件所在文件夹中;

源文件:

FORMAT: 1A
HOST: http://polls.apiblueprint.org/# PollsPolls is a simple API allowing consumers to view polls and vote in them. You can view this documentation over at [Apiary](http://docs.pollsapi.apiary.io).# Polls API Root [/]This resource does not have any attributes. Instead it offers the initial API affordances in the form of the links in the JSON body.It is recommend to follow the “url” link values, [Link](https://tools.ietf.org/html/rfc5988) or Location headers where applicable to retrieve resources. Instead of constructing your own URLs, to keep your client decoupled from implementation details.## Retrieve the Entry Point [GET]+ Response 200 (application/json){"questions_url": "/questions"}## Group QuestionResources related to questions in the API.## Question [/questions/{question_id}]A Question object has the following attributes:+ question
+ published_at - An ISO8601 date when the question was published.
+ url
+ choices - An array of Choice objects.+ Parameters+ question_id: 1 (required, number) - ID of the Question in form of an integer### View a Questions Detail [GET]+ Response 200 (application/json){"question": "Favourite programming language?","published_at": "2014-11-11T08:40:51.620Z","url": "/questions/1","choices": [{"choice": "Swift","url": "/questions/1/choices/1","votes": 2048}, {"choice": "Python","url": "/questions/1/choices/2","votes": 1024}, {"choice": "Objective-C","url": "/questions/1/choices/3","votes": 512}, {"choice": "Ruby","url": "/questions/1/choices/4","votes": 256}]}## Choice [/questions/{question_id}/choices/{choice_id}]+ Parameters+ question_id: 1 (required, number) - ID of the Question in form of an integer+ choice_id: 1 (required, number) - ID of the Choice in form of an integer### Vote on a Choice [POST]This action allows you to vote on a question's choice.+ Response 201+ HeadersLocation: /questions/1## Questions Collection [/questions{?page}]+ Parameters+ page: 1 (optional, number) - The page of questions to return### List All Questions [GET]+ Response 200 (application/json)+ HeadersLink: </questions?page=2>; rel="next"+ Body[{"question": "Favourite programming language?","published_at": "2014-11-11T08:40:51.620Z","url": "/questions/1","choices": [{"choice": "Swift","url": "/questions/1/choices/1","votes": 2048}, {"choice": "Python","url": "/questions/1/choices/2","votes": 1024}, {"choice": "Objective-C","url": "/questions/1/choices/3","votes": 512}, {"choice": "Ruby","url": "/questions/1/choices/4","votes": 256}]}]### Create a New Question [POST]You may create your own question using this action. It takes a JSON object containing a question and a collection of answers in the form of choices.+ question (string) - The question
+ choices (array[string]) - A collection of choices.+ Request (application/json){"question": "Favourite programming language?","choices": ["Swift","Python","Objective-C","Ruby"]}+ Response 201 (application/json)+ HeadersLocation: /questions/2+ Body{"question": "Favourite programming language?","published_at": "2014-11-11T08:40:51.620Z","url": "/questions/2","choices": [{"choice": "Swift","url": "/questions/2/choices/1","votes": 0}, {"choice": "Python","url": "/questions/2/choices/2","votes": 0}, {"choice": "Objective-C","url": "/questions/2/choices/3","votes": 0}, {"choice": "Ruby","url": "/questions/2/choices/4","votes": 0}]}

生成HTML文件:
这里写图片描述

这篇关于API Blueprint的安装的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/896445

相关文章

Knife4j+Axios+Redis前后端分离架构下的 API 管理与会话方案(最新推荐)

《Knife4j+Axios+Redis前后端分离架构下的API管理与会话方案(最新推荐)》本文主要介绍了Swagger与Knife4j的配置要点、前后端对接方法以及分布式Session实现原理,... 目录一、Swagger 与 Knife4j 的深度理解及配置要点Knife4j 配置关键要点1.Spri

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

HTML5 getUserMedia API网页录音实现指南示例小结

《HTML5getUserMediaAPI网页录音实现指南示例小结》本教程将指导你如何利用这一API,结合WebAudioAPI,实现网页录音功能,从获取音频流到处理和保存录音,整个过程将逐步... 目录1. html5 getUserMedia API简介1.1 API概念与历史1.2 功能与优势1.3

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

MySQL MCP 服务器安装配置最佳实践

《MySQLMCP服务器安装配置最佳实践》本文介绍MySQLMCP服务器的安装配置方法,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下... 目录mysql MCP 服务器安装配置指南简介功能特点安装方法数据库配置使用MCP Inspector进行调试开发指

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

Nexus安装和启动的实现教程

《Nexus安装和启动的实现教程》:本文主要介绍Nexus安装和启动的实现教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Nexus下载二、Nexus安装和启动三、关闭Nexus总结一、Nexus下载官方下载链接:DownloadWindows系统根

Java SWT库详解与安装指南(最新推荐)

《JavaSWT库详解与安装指南(最新推荐)》:本文主要介绍JavaSWT库详解与安装指南,在本章中,我们介绍了如何下载、安装SWTJAR包,并详述了在Eclipse以及命令行环境中配置Java... 目录1. Java SWT类库概述2. SWT与AWT和Swing的区别2.1 历史背景与设计理念2.1.

安装centos8设置基础软件仓库时出错的解决方案

《安装centos8设置基础软件仓库时出错的解决方案》:本文主要介绍安装centos8设置基础软件仓库时出错的解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录安装Centos8设置基础软件仓库时出错版本 8版本 8.2.200android4版本 javas