-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequest.yaml
61 lines (61 loc) · 1.94 KB
/
request.yaml
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
59
60
61
# example to execute this request:
# apix exec request
apiVersion: apix.io/v1
metadata:
name: request
annotations:
apix.io/convert-body-string-to-json: "true"
kind: Request
spec:
parameters:
- name: todo
required: true
schema:
type: integer
default: 1
- name: email
required: true
schema:
type: string
format: email
default: ecyrbe@gmail.com
- name: content
required: true
schema:
type: object
default:
title: "My todo"
description: "My todo description"
done: false
context:
# you can create new variables in the context
url: https://jsonplaceholder.typicode.com/todos
# you can use variables from parameters in the context
next: "{{ parameters.todo + 1 }}"
# you can use variables from introspection in the context
annotation: '{{ manifest.metadata.annotations["apix.io/convert-body-string-to-json"] }}'
# you cannot use variables created in the context
# error: "{{ next + 1 }}" # variable next is not defined in context itself
request:
method: post
# you can use variables from the context
url: "{{ context.url }}"
headers:
accept: application/json
# you can use variables from the process environnement
# you can use variables from the context
# you can use variables from the parameters
# you can use variables from the introspection
# you can use variables from the tera only in scoped content (ie: variable declared in url can't be used in body)
# you can use filters to transform the variable
body: |-
{% set my_var = "test" %}
{
"user": "{{ env.USERNAME }}",
"todo": {{ parameters.todo }},
"next": {{ context.next }},
"hello": "{{ parameters.email }}",
"annotation": "{{ context.annotation }}",
"content": {{ parameters.content | json_encode }},
"test": "{{ my_var }}"
}