我正在尝试使用API Blueprint记录端点,使用规范的新Attributes和DataStructures部分.
我的请求有效负载如下所示:
{
"url": "http://requestb.in/11v7i7e1",
"active": true,
"types": [
{
"name": "sales",
"version": "2.0"
},
{
"name": "products",
"version": "2.0"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的响应有效负载看起来像这样:
{
"data": {
"id": "dc85058a-a683-11e4-ef46-e9431a15be8c",
"url": "http://requestb.in/11v7i7e1",
"active": true,
"types": [
{
"name": "products",
"version": "2.0"
},
{
"name": "sales",
"version": "2.0"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下API Blueprint markdown:
FORMAT: 1A
# Vend REST API 2.0
# Group Webhooks
## api/2.0/webhooks [/webhooks]
### List all Webhooks [GET]
Returns a list of Webhooks created by the …Run Code Online (Sandbox Code Playgroud) 我正在研究API Blueprint中新数据结构语法的可能性,尤其是MSON.是否可以附加或更确切地指定类似图案(正则表达式)的东西?没有找到关于这个主题的任何内容.
在 API Blueprint 中,如何避免对每个端点一遍又一遍地使用相同的请求 Authorization 标头块?
+ Request (application/json)
+ Headers
Authorization: Bearer jsonWebToken
Run Code Online (Sandbox Code Playgroud)
有没有办法在数据结构中对此进行模板化?
我正在使用API Blueprint和Agelo来呈现我的 API 文档。使用枚举类型时,我观察到一种奇怪的行为。响应未显示定义的枚举值,而架构显示所有枚举值(这是预期的)以及声明的值(“星期一”-参考实际值)。
数据结构部分
# Data Structures
## Days (enum[string])
+ `Monday`
+ `Tuesday`
+ `Wednesday`
+ `Thursday`
## ListEntry
- playOrder: 1 (number)
- Id: 37a21975a499494f03367 (string)
- programDay: `Tuesday` (Days)
## `sample-request-200`
- id: 58828b2941cc351348 (string)
- startDate: `2019-08-01T11:00:00.000Z` (string)
- endDate: `2019-08-05T11:55:59.000Z` (string)
- Language: `en-US` (string)
- entries: ListEntry (array[object])
Run Code Online (Sandbox Code Playgroud)
API请求文档部分
+ Request
+ Headers
Content-Type: application/json
+ Attributes (sample-request-200)
Run Code Online (Sandbox Code Playgroud)
实际的
---- JSON Body ----
{
"playOrder": 1,
"Id": "37a21975a499494f03367",
"programDay": …Run Code Online (Sandbox Code Playgroud) 我所谓的参数部分解决方案是
+ fields: [firstField, secondField] (array[enum], optional)
+ Members
+ firstField
+ secondField
+ extraField
+ dummyField
Run Code Online (Sandbox Code Playgroud)
但它在语义错误上失败了:
参数字段的示例值[firstField,secondField]不在其预期值列表中
我想创建一个嵌套数组,其中包含MSON格式的对象,以便与API Blueprint和Apiary一起使用.我的代码看起来是正确的,但是当我在Apiary中渲染它时,我没有获得预期的JSON.
示例我想要创建:导航有多个类别.每个类别可以有多个子类别.每个类别和子类别都有一个名称.
我为此创建的MSON:
FORMAT: 1A
# Test nested arrays-in-object-arrays
A navigation has multiple categories. Each category can have multiple subcategories.
# GET /navigation
+ Response 200 (application/json)
+ Attributes
+ categories (array)
+ (object)
+ name: Category One (string) - Name of the category
+ subcategories (array)
+ (object)
+ name: Sub category One (string) - Name of the subcategory
Run Code Online (Sandbox Code Playgroud)
我希望在JSON中输出的输出:
{
"categories": [
{
"name": "Category One",
"subcategories":
[
{
"name": "Sub category One"
}
] …Run Code Online (Sandbox Code Playgroud)