forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapis.yaml
More file actions
58 lines (55 loc) · 1.39 KB
/
apis.yaml
File metadata and controls
58 lines (55 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# yaml-language-server: $schema=https://www.membrane-api.io/v7.1.2.json
# JSON template with a variable
api:
port: 2000
method: GET
flow:
- request:
- template:
contentType: application/json
pretty: yes
src: |
{
"answer": ${params.answer?[0]}
}
- return:
status: 200
---
# JSON input is converted to XML and directed to logger, the response is then converted back to JSON and returned.
api:
port: 2000
method: POST
flow:
- request:
# Value of "city" field of the incoming JSON is inserted into XML
- template:
contentType: application/xml
src: <city>${json.city}</city>
# setProperty extracts the "city" from the XML.
# The extracted value is placed inside a JSON template.
# Note: Consider that the response flow is going from bottom to top.
- response:
- template:
contentType: application/json
src: |
{
"city": ${property.city.toString()}
}
# Is executed on the way back
- setProperty:
name: city
value: '${/city}'
language: xpath
# Calls logger API below
target:
host: localhost
port: 3000
---
api:
name: logger
port: 3000
flow:
- request:
- log: {}
- return:
status: 200