我在 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 本身中传递的参数添加描述(id
或 code
)。有办法实现吗?
最佳答案
您缺少描述 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
关于api - 用 RAML 描述 URI 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25998115/