API Blueprint笔记

API Blueprint是一种使用Markdown语法规范,用于编写Web API的工具。通过API Blueprint,你可以轻松创建具有实时预览功能的文档,便于团队协作和前端测试。本文将从关键字和符号入手,介绍如何使用API Blueprint。
摘要由CSDN通过智能技术生成

0 前言

Node还没好好看完,又得开新坑了。

API Blueprint,是一个用于编写web api的规范,采用类似于markdown的语法,语法本身没什么难点,记住几个关键词,也就差不多了。其强大之处在于丰富的工具、插件。

apiaryio提供了实时预览的功能,让书写web api更加便捷和规范,并且可以讲web api文档转换成虚拟的web server,直接提供给前端测试,这样让团队开发耦合度更低,效率也更高。
这里写图片描述

Blueprint的项目托管在Github上,有比较详细的指导说明。


1 使用

Blueprint的书写方式类似markdown,所以对于习惯用markdown写博客的人来说,十分具有亲和力,上手完全没有障碍。

由于内容比较杂,所以我就从例子出发,阐述一下各个关键字的用法,这个例子的完整代码在官方的文档里有,不过我还是复制一遍,方便讲解:

FORMAT: 1A

# Gist Fox API
Gist Fox API is a **pastes service** similar to [GitHub's Gist](http://gist.github.com).

## Authentication
*Gist Fox API* uses OAuth Authorization. First you create a new (or acquire existing) OAuth token using Basic Authentication. After you have acquired your token you can use it to access other resources within token' scope.

## Media Types
Where applicable this API uses the [HAL+JSON](https://github.com/mikekelly/hal_specification/blob/master/hal_specification.md) media-type to represent resources states and affordances.

Requests with a message-body are using plain JSON to set or update resource states.

## Error States
The common [HTTP Response Status Codes](https://github.com/for-GET/know-your-http-well/blob/master/status-codes.md) are used.

# Gist Fox API Root [/]
Gist Fox API entry point.

This resource does not have any attributes. Instead it offers the initial API affordances in the form of the HTTP Link header and
HAL links.

## Retrieve the Entry Point [GET]

+ Response 200 (application/hal+json)
    + Headers

            Link: <http:/api.gistfox.com/>;rel="self",<http:/api.gistfox.com/gists>;rel="gists",<http:/api.gistfox.com/authorization>;rel="authorization"

    + Body

            {
                "_links": {
                    "self": { "href
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值