api - 用 RAML 描述 URI 参数

标签 api rest raml

我在 RAML 中声明 REST 服务 API stub 。我的Web应用程序提供了设备,可以通过id或代码列出、获取设备。当我想要整个列表时,我不会指定任何 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 本身中传递的参数添加描述(idcode)。有办法实现吗?

最佳答案

您缺少描述 equipmentIdcode 参数的 uriParameters 部分。在此类部分中,您可以指定常用的:typedescription...

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

关于api - 用 RAML 描述 URI 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25998115/

相关文章:

javascript - Backbone REST API推荐/跨域

java - 将 Retrofit 与 Imgur 的 API 结合使用

api - 需要有关使用自管理用户数据库的 Kong 和 OAuth 的帮助

java - 通过 REST API 控制 Jenkins

android - HTTP 状态 405 - 方法不允许(jax-rs 服务)

json - 将 Swagger JSON 转换为 RAML/YAML

机器可读格式的 Facebook API

ios - json 解析不正确

php - Bootstrap 3.3.1 : Btn-group with RESTful Delete and Patch Buttons not connecting smoothly

api - 在许多文件中拆分 swagger 定义