【发布时间】:2018-07-11 09:53:13
【问题描述】:
我有一个关于 RAML 发送不同响应的问题。在下面的 RAML 中,我想根据查询参数发送响应。如果我的查询参数 (flightId) 是“F001”,我应该只得到数据 F001 的响应。但是我得到了响应中指定的所有数据的响应。我可以知道如何过滤不需要的数据。
#%RAML 1.0
baseUri: https://mocksvc.mulesoft.com/mocks/9b7a0390-ecf4-4ff4-b307-0b7d87ed9495 # baseUri: https://mocksvc.mulesoft.com/mocks/b133e2e4-f0e3-49a0-b224-8f36358e04ca #
title: FlightApi-Rajesh
version: 1.0.1
/{flightId}:
description: Flight Id
get:
queryParameters:
flightId:
displayName: flightId
type: string
required: true
description: Flight name with its ID
example: F0001
description: Get the flight with `flightId = {flightId}`
responses:
200:
body:
application/json:
example: |
{
"F001":{
"flightName": "Ingido",
"Location": "Mumbai",
"flightId": "F001",
"Destination":"Delhi",
"timing":"19:55 HRS"
},
"F002":{
"flightName": "SpiceJet",
"Location": "Pune",
"flightId": "PNQ012",
"Destination":"Chennai",
"timing":"15:00 HRS"
}
}
404:
body:
application/json:
example: |
{"message": "Flight not found"}
【问题讨论】: