标签: apiblueprint

如何用养蜂场记录多部分请求?

我想记录如下的多部分请求:

Content-Length: 477
Content-Type: multipart/form-data; boundary=---BOUNDARY

-----BOUNDARY
Content-Disposition: form-data; name="image[file]"; filename="image.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: base64

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIA
AhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEB
AAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AL+AD//Z
-----BOUNDARY--
Run Code Online (Sandbox Code Playgroud)

A curl重现同样的请求将是这样的:

curl -F "image[file]=@file.jpg" http://localhost/images
Run Code Online (Sandbox Code Playgroud)

apiary.io apiblueprint

24
推荐指数
1
解决办法
8303
查看次数

如何从具有不同参数的单个端点获得多个响应?

我们正在考虑使用API​​蓝图.在某些情况下,我们希望一个请求返回正确的响应,另一个请求返回"错误"响应,例如,400 bad request以便其他开发人员可以在apiary.io上使用两种类型的响应来处理模拟API并处理它他们的应用.

我在下面创建了一个完全随意的例子,

## Thing [/thing/{id}]
Gets a thing but the thing id must be a prime number!


+ Parameters
    + id (string) ... ID of the thing, a prime number!

+ Model (application/json)

    The thing itself.

    + Body

            {
                "description": "It is green"
            }

### Retrieve a Single Gist [GET]
+ Response 200

    [Gist][]
Run Code Online (Sandbox Code Playgroud)

现在我想以某种方式添加回复 /thing/40

+ Response 400
    {  "error" : "Invalid request" }
Run Code Online (Sandbox Code Playgroud)

但我不确定如何使用API​​ Blueprint执行此操作.这可以在apiary.io的"旧"风格下实现,但我们想继续使用新的语法

apiary.io apiblueprint

22
推荐指数
1
解决办法
7372
查看次数

是否可以将表格置于降价文件中?

我有一张桌子:

    | This | Is | A | Table |
    | :--- | -- | - | ----: |
    | foo  | ba | r | elbaT |
Run Code Online (Sandbox Code Playgroud)

我希望表格显示在我的Markdown文件的中心而不是左对齐.我不是要对齐文本,而是整个表本身.我是否需要求助于HTML/CSS来实现我想要的目标?

这是一个Apiary.io项目.

markdown github-flavored-markdown apiary.io apiblueprint

21
推荐指数
5
解决办法
3万
查看次数

使用API​​ Blueprint记录查询参数

我正在尝试在API Blueprint中记录查询参数,但我不完全确定我是否已正确完成.资源如下所示:

DELETE http://baasar.apiary-mock.com/user/{appId}/{userId}
Run Code Online (Sandbox Code Playgroud)

该请求将停用用户,而以下将删除用户对象:

DELETE http://baasar.apiary-mock.com/user/{appId}/{userId}?force=true
Run Code Online (Sandbox Code Playgroud)

这是我对此的蓝图降价:

## User [/user/{appId}/{userId}]
Handle user objects

+ Parameters
    + appId (required, number, `1`) ... Application ID (`appId`)
    + userId (required, number, `1`) ... Numeric `userId` of the User object to manage

### Remove an User [DELETE]
+ Parameters
    + force (optional, boolean, `false`) ... Set to `true` to remove instead of deactivate

+ Response 204
Run Code Online (Sandbox Code Playgroud)

但是,当使用Apiary渲染时,我只force在参数列表中看到,但它现在显示在示例URL中.这只是我误解了GUI或者应该以另一种方式记录查询参数吗?

apiary.io apiblueprint

16
推荐指数
1
解决办法
2万
查看次数

良好的休息代码生成和文档工具

我一直在考虑一个文档工具,用于构建Web服务的后端,以便在多个客户端中使用OAuth以及多次修订的可能性.我已经知道了蜂房,但做了一些研究,我找到了其他相当好的解决方案,并且有利可图的承诺.

RAML似乎承诺良好的代码生成和api可重用性.但它似乎无法创建模拟服务器.我无法理解为什么apiblueprint不能用于生成REST API的客户端库和服务器端框架.

对我们来说最好的用例是基于api的文档,用于消费服务的客户端iOS/Android/wp/js库可以与节点快速/解析应用程序一起自动生成,该应用程序提供编写代码的框架.随着api测试和负载测试.

RAML/Swagger/Apiary中的哪种解决方案最适合这种情况?

rest swagger apiblueprint raml

15
推荐指数
3
解决办法
1万
查看次数

如何在Apiary文档中指定错误代码?

我想指定在进行API调用时必须返回的各种异常/错误.我如何通过Apiary实现这一目标.

apiblueprint

11
推荐指数
1
解决办法
3534
查看次数

尝试使用API​​蓝图中的数据结构描述请求和响应

我正在尝试使用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 apiary.io apiblueprint apiary mson

11
推荐指数
1
解决办法
4428
查看次数

Apiary.io - 具有不同参数的多个响应(200)

我试图通过不同的参数获得不同的响应,但有些东西不起作用.

这是我的API:

## Question [/questions/{question_id}]

A Question object has the following attributes:

+ Parameters
    + question_id: `1` (number, required) - ID of the Question in form of an integer

### View a Questions Detail [GET]

+ Request

+ Header

    X-Custom-Header : 1

+ Response 200 (application/json)

        {
            "id": "1",
            "name": "Marco"
        }


+ Request

+ Header

    X-Custom-Header : 2

+ Response 200 (application/json)

        {
            "id: "2",
            "name": "Lucas"
        }
Run Code Online (Sandbox Code Playgroud)

但是在调用/ questions/1或/ questions/2时,响应始终是相同的:

{
    "id": "1",
    "name": "Marco"
}
Run Code Online (Sandbox Code Playgroud)

怎么了?

谢谢

rest restful-architecture apiary.io apiblueprint apiary

11
推荐指数
1
解决办法
4934
查看次数

什么是Api Blueprint可以理解的二维键值格式?

我正在使用Api Blueprint为RESTful搜索API开发api文档.我希望能够将过滤器传递给API,以便我可以组装:

filter[filtername1]=filtervalue1
filter[filtername2]=filtervalue2
Run Code Online (Sandbox Code Playgroud)

根据这个问题,我使用了百分比编码的方括号,但与这个问题不同,我们不可能描述每个可能的键名:

创建Blueprint API doc时如何在URL中格式化基于哈希的参数?

我希望密钥名称是可变的,因为它可以是源数据中的任何字段.这有用吗?

## Key-Value-Test [/api/v1/keyvaluetest?term={term}&filter%5B{field_name}%5D={field_value}]

+ term
+ filter_field
+ filter_value
Run Code Online (Sandbox Code Playgroud)

这样的二维数组是否有推荐的格式?这似乎不适用于Dredd,因为+ filter_field它不匹配filter[filter_field]

rest url apiblueprint dredd

10
推荐指数
2
解决办法
606
查看次数

如何在Apiary.io中显示嵌套属性定义

我的数据结构定义如下:

# Data Structures

## PlayerRank (object)
Represents the minimum amount of data the the client needs to send to give rank information about a particular Player in a particular Played Game.
+ playerId (number, required) - NemeStats unique identifier for the Player.
+ gameRank (number, required) - The corresponding rank of the Player in this Played Game. A rank of 1 means the Player got first place, 2 means second place, and so on.
+ pointsScored (number, optional) - …
Run Code Online (Sandbox Code Playgroud)

apiary.io apiblueprint apiary

9
推荐指数
1
解决办法
2292
查看次数