【问题标题】:Different request on same action with parameters具有参数的相同操作的不同请求
【发布时间】:2014-10-02 12:36:22
【问题描述】:

我想根据“名称”或“状态”搜索(比如说)“accounts”。

所以我想要两个动作:

  • GET /persons/?q=name==Jea*
  • GET /persons/?q=status==locked

我怎样才能记录下来?

我尝试了Action 进行多次交易:

### GET /accounts{?q}

+ Request by name
    +Parameters
        +q (required, FIQLQuery)
        **Only name is supported**

+ Request by status
    +Parameters
        +q (required, FIQLQuery)
        **Only status is supported**

但是养蜂场编辑抱怨是因为:

  1. 我必须为我的 GET 请求提供消息正文:

    消息体资产应该是一个预先格式化的代码块,它的每一行都缩进了 8 个空格或 2 个制表符。

  2. + Parameters 块无法识别:

    忽略无法识别的块

非常感谢

【问题讨论】:

    标签: apiblueprint apiary.io


    【解决方案1】:

    我可以制定适合我的解决方案。

    试试这个 API 蓝图:

    FORMAT: 1A
    
    # requestByname
    
    ## Accounts [/accounts/?{q,type}]
    
    ### GET
    
    + Parameters
        + q (required, FIQLQuery)
        + type (string, `name` or `status`)
    
    + Request Name (application/json)
    
    + Response 200
    
            {"name": "test"}
    
    + Request Status (application/json)
    
    + Response 200
    
            {"status": 200}
    

    【讨论】:

    • 当然,有很多替代解决方案。但我不想使用额外的参数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-31
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多