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

相关文章

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

Java调用DeepSeek API的最佳实践及详细代码示例

《Java调用DeepSeekAPI的最佳实践及详细代码示例》:本文主要介绍如何使用Java调用DeepSeekAPI,包括获取API密钥、添加HTTP客户端依赖、创建HTTP请求、处理响应、... 目录1. 获取API密钥2. 添加HTTP客户端依赖3. 创建HTTP请求4. 处理响应5. 错误处理6.

Python安装时常见报错以及解决方案

《Python安装时常见报错以及解决方案》:本文主要介绍在安装Python、配置环境变量、使用pip以及运行Python脚本时常见的错误及其解决方案,文中介绍的非常详细,需要的朋友可以参考下... 目录一、安装 python 时常见报错及解决方案(一)安装包下载失败(二)权限不足二、配置环境变量时常见报错及

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

浅析如何使用Swagger生成带权限控制的API文档

《浅析如何使用Swagger生成带权限控制的API文档》当涉及到权限控制时,如何生成既安全又详细的API文档就成了一个关键问题,所以这篇文章小编就来和大家好好聊聊如何用Swagger来生成带有... 目录准备工作配置 Swagger权限控制给 API 加上权限注解查看文档注意事项在咱们的开发工作里,API

一分钟带你上手Python调用DeepSeek的API

《一分钟带你上手Python调用DeepSeek的API》最近DeepSeek非常火,作为一枚对前言技术非常关注的程序员来说,自然都想对接DeepSeek的API来体验一把,下面小编就来为大家介绍一下... 目录前言免费体验API-Key申请首次调用API基本概念最小单元推理模型智能体自定义界面总结前言最

MySQL8.2.0安装教程分享

《MySQL8.2.0安装教程分享》这篇文章详细介绍了如何在Windows系统上安装MySQL数据库软件,包括下载、安装、配置和设置环境变量的步骤... 目录mysql的安装图文1.python访问网址2javascript.点击3.进入Downloads向下滑动4.选择Community Server5.

JAVA调用Deepseek的api完成基本对话简单代码示例

《JAVA调用Deepseek的api完成基本对话简单代码示例》:本文主要介绍JAVA调用Deepseek的api完成基本对话的相关资料,文中详细讲解了如何获取DeepSeekAPI密钥、添加H... 获取API密钥首先,从DeepSeek平台获取API密钥,用于身份验证。添加HTTP客户端依赖使用Jav

CentOS系统Maven安装教程分享

《CentOS系统Maven安装教程分享》本文介绍了如何在CentOS系统中安装Maven,并提供了一个简单的实际应用案例,安装Maven需要先安装Java和设置环境变量,Maven可以自动管理项目的... 目录准备工作下载并安装Maven常见问题及解决方法实际应用案例总结Maven是一个流行的项目管理工具

C#使用DeepSeek API实现自然语言处理,文本分类和情感分析

《C#使用DeepSeekAPI实现自然语言处理,文本分类和情感分析》在C#中使用DeepSeekAPI可以实现多种功能,例如自然语言处理、文本分类、情感分析等,本文主要为大家介绍了具体实现步骤,... 目录准备工作文本生成文本分类问答系统代码生成翻译功能文本摘要文本校对图像描述生成总结在C#中使用Deep