【问题标题】:Describing URI parameters in RAML在 RAML 中描述 URI 参数
【发布时间】:2014-11-17 20:06:34
【问题描述】:

我在 RAML 中声明一个 REST 服务 API 存根。我的web应用提供了设备,可以列出,可以通过id或者code获取。当我想要整个列表时,我不指定任何 URI 参数,但是,为了获得具体的设备,我会这样做。这是它的当前状态:

/equipment:
    get:
      body:
        application/json:
        application/xml:
    description:
      List all the equipment
    /id/{equipmentId}:
      get:
         body:
          application/json:
          application/xml:
      description:
        Get an equipment by id 
    /code/{code}:
        get:
          body:
            application/json:
            application/xml:
        description: 
              Get an equipment by code

在这里,在description 字段中,我写下了当前调用的执行情况。但是,我想为 URI 本身中传递的参数添加说明(id 或 code)。有没有办法实现?

【问题讨论】:

    标签: api rest raml


    【解决方案1】:

    您缺少描述equipmentId 和code 参数的uriParameters 部分。在这样的部分,你可以指定通常的:type,description...

    请参阅规范中的模板 URI 和 URI 参数部分:https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md#template-uris-and-uri-parameters

    【讨论】:

    • uriParameters 部分是可选的
    猜你喜欢
    • 2015-12-10
    • 2017-01-22
    • 1970-01-01
    • 2014-03-06
    • 1970-01-01
    • 2021-11-02
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    相关资源
    最近更新 更多