【问题标题】:How do I get Apiary model details from the rendered documentation?如何从渲染的文档中获取 Apiary 模型详细信息?
【发布时间】:2014-06-23 05:22:22
【问题描述】:

我在 Apiary 中定义了一个 API 契约,并且我使用 Resource model 语法来启用有效负载的重用。

虽然 Apiary 呈现的文档仅显示模型名称(例如 Response 200 返回 [Foo][]) - 没有任何关于 Foo 是什么的进一步详细信息,也没有任何链接可查看 Foo 模型中的属性。

给定一个模型,我如何在渲染的文档中看到它的属性?

更新
合同相关部分如下:

### Manipulating a specific Organisation [/organisations/{id}]
Operations to retrieve and update a specific Organisation.

+ Parameters

    + id (required, guid, `F339ADA5-E836-40FE-8E90-BEF06892762E`) ... The guid Organisation `id`.

+ Model (application/json)

    + Headers

            Link : <http://foobar.com/organisations/F339ADA5-E836-40FE-8E90-BEF06892762E>;rel="self"

    + Body

            {
                "id" : "F339ADA5-E836-40FE-8E90-BEF06892762E",
                "name" : "joe's gardening supplies"
            }

### Retrieve an Organisation [GET]

+ Response 200

        [Organisation][]

### Update an Organisation [PATCH]

+ Request

        [Organisation][]

+ Response 204

【问题讨论】:

    标签: apiblueprint apiary.io


    【解决方案1】:

    除非您提供示例,否则这只是猜测,但我的第一个猜测是错误的缩进级别。示例蓝图的样子:

    FORMAT: 1A
    HOST: http://www.google.com
    
    # Model Example
    Notes API is a *short texts saving* service similar to its physical paper presence on your table.
    
    # Group Notes
    Notes related resources of the **Notes API**
    
    ## Note [/notes/{id}]
    A single Note object with all its details
    
    + Parameters
        + id (required, number, `1`) ... Numeric `id` of the Note to perform action with. Has example value.
    
    + Model
    
        + Header
    
                X-My-Header: The Value
    
        + Body
    
                { "id": 2, "title": "Pick-up posters from post-office" }
    
    ### Retrieve a Note [GET]
    + Response 200 (application/json)
    
        [Note][]
    
    ### Remove a Note [DELETE]
    + Response 204
    

    上面的代码生成this documentation,其中模型被正确地合并到它被引用的地方(以及支持这种引用的地方 - 即有效载荷的定义)。

    有时阅读raw version of Apiary's docs on GitHub 会有所帮助,因为这样更容易找到正确、准确的格式。

    【讨论】:

    • 干杯 - 我已经用我的例子更新了这个问题。它看起来与您的示例非常相似,所以我不确定为什么它不起作用。
    【解决方案2】:

    好的,通过比较两个示例,我已经得出了结论。

    在我的合同中,模型参考

    [Organisation][]
    

    缩进了两个制表符而不是一个制表符。 :S

    这是一个非常容易犯的错误 - 如果 Apiary 为模型参考标记了不正确的缩进级别,将会很有帮助。

    【讨论】:

    • 是的,这是计划中的github.com/apiaryio/snowcrash/issues/38,对此感到抱歉。技术细节:两个选项卡使它成为一个代码块——一个不透明的资产——解析器将其作为消息有效负载主体
    猜你喜欢
    • 2018-01-19
    • 2020-10-28
    • 1970-01-01
    • 2014-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 2022-08-19
    相关资源
    最近更新 更多