【发布时间】:2018-05-23 08:11:21
【问题描述】:
我对设计simple RAML 有以下要求。我是RAML 编码的新手,所以想知道我的代码是否符合要求
要求:
- 至少有 1 个带有 GET 和 POST 方法的端点。
- 包括 API 的描述属性
- 包括方法的描述属性
- GET 请求采用“mulesoft”查询参数
- 使用包含至少一个字符串和 整数数据类型
- 包括一个 200 响应代码的示例,它与 上面定义的响应对象
我的代码:
#%RAML 1.0
title: Coding_Champions
version: 1.0.development
baseUri: http://localhost:8004/api
description: This API displays and adds Organisation with details
types:
Org:
type: object
properties:
name: string
address: string
pincode: integer
/details:
displayName: Company Details
description: Coding challenge which takes query parameter of "mulesoft"
get:
description: Retrieve a list of all the Orgs
queryParameters:
mulesoft:
description: Specify the Org name that you want to retrieve
type: boolean
required: true
responses:
200:
body:
application/json:
type: Org
examples:
MuleSoft:
name: MuleSoft
address: 77 Geary Street, Suite 400
pincode: 94108
post:
description: Add a Org to list
body:
application/json:
type: Org
examples:
Cognizant:
name: Cognizant
address: DLF
pincode: 9771
responses:
201:
body:
application/json:
example: |
{
"message":"New Org updated but not really"
}
我更关心需求中的一点
"The GET request takes a query parameter of “mulesoft”
这是否意味着我应该在我的url 中动态地将mulesoft 作为参数传递,如果是,那么除了mulesoft 作为参数传递之外,它应该会引发错误?
(或)
这是否意味着我需要像现在一样在我的RAML 代码中硬编码“mulesoft”?
你能澄清一下吗?
【问题讨论】:
-
查询参数 mulesoft 的描述显示“指定要检索的组织名称”但类型为“布尔”。名称如何为布尔值?
-
感谢您的回复..描述部分可以忽略..我写完了一些东西...