Api-blueprint: 如何在 Apiary 中重用 RESPONSE

创建于 2016-10-01  ·  4评论  ·  资料来源: apiaryio/api-blueprint

有没有办法在 Apiary 中重用响应? 我认为数据结构不是正确的方法,但我找不到其他任何东西......

最有用的评论

以下示例对您有用吗?

# A

## A [/a]

### Get A [GET]

+ Response 201 (application/json)

    + Attributes (GenericRes)


## B [/b]

### Get B [GET]

+ Response 201 (application/json)

    + Attributes (GenericRes)


# Data Structures

## GenericRes(object)
+ message (object)
    + id : MESSAGE_ID (string) - Message ID
    + recipient(object)
      + id : USER_ID (string)- User ID

所有4条评论

重用响应是什么意思?如果您只想指定一个响应,然后在某些方法中引用它,那么这是不可能的,因为它没有语法。如果您想在那里重用响应的内容,您可以使用您已经提到的数据结构。

@w-vi 感谢您的回答。 我想重用这部分:

+ Response 201 (application/json)

    + Body

            {
                "message": {
                    "id": "MESSAGE_ID"
                    "recipient" : {
                        "id": "USER_ID"
                    }
                }
            }

你能说出是否可以至少部分重复使用它吗?

以下示例对您有用吗?

# A

## A [/a]

### Get A [GET]

+ Response 201 (application/json)

    + Attributes (GenericRes)


## B [/b]

### Get B [GET]

+ Response 201 (application/json)

    + Attributes (GenericRes)


# Data Structures

## GenericRes(object)
+ message (object)
    + id : MESSAGE_ID (string) - Message ID
    + recipient(object)
      + id : USER_ID (string)- User ID

谢谢@w-vi,这正是我所需要的!

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

robbinjanssen picture robbinjanssen  ·  6评论

teja5429 picture teja5429  ·  9评论

Perni1984 picture Perni1984  ·  6评论

pete001 picture pete001  ·  6评论

rodriguise picture rodriguise  ·  11评论