首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Apiary中重用响应

如何在Apiary中重用响应
EN

Stack Overflow用户
提问于 2016-10-01 16:16:18
回答 1查看 161关注 0票数 0

有没有办法在Apiary中重用响应?我认为Data Structures不是正确的方法,但我找不到其他的方法。

EN

回答 1

Stack Overflow用户

发布于 2016-10-01 17:43:19

数据结构--正如你可能已经注意到的,一开始看起来有点夸大其词,但这正是你正在寻找的答案。如果您对如何在“高级模式”中使用它们更感兴趣,请查看https://github.com/apiaryio/api-blueprint/blob/master/Advanced%20Tutorial.md#data-structures上的教程

另一种选择是使用资源模型:

代码语言:javascript
复制
## My Message [/message]

+ Model (application/vnd.siren+json)

    This is the `application/vnd.siren+json` message resource representation.

    + Headers

            Location: http://api.acme.com/message

    + Body

            {
              "class": [ "message" ],
              "properties": {
                    "message": "Hello World!"
              },
              "links": [
                    { "rel": "self" , "href": "/message" }
              ]
            }

另一个选项是使用普通属性(https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md#resource-attributes-description)

代码语言:javascript
复制
# Blog Post [/posts/{id}]
Resource representing **ACME Blog** posts.

+ Attributes
    + id (number)
    + message (string) - The blog post article
    + author: john@appleseed.com (string) - Author of the blog post

及以后的引用^“资产”,如下所示:

代码语言:javascript
复制
+ Attributes (Blog Post)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39804438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档