63 lines
1.3 KiB
YAML
63 lines
1.3 KiB
YAML
#!api-testing-mock
|
|
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-mock-schema.json
|
|
objects:
|
|
- name: user
|
|
fields:
|
|
- name: username
|
|
kind: string
|
|
- name: repo
|
|
fields:
|
|
- name: name
|
|
kind: string
|
|
- name: url
|
|
kind: string
|
|
- name: team
|
|
sample: |
|
|
{
|
|
"name": "someone"
|
|
}
|
|
- name: projects
|
|
initCount: 3
|
|
sample: |
|
|
{
|
|
"name": "api-testing",
|
|
"color": "{{ randEnum "blue" "read" "pink" }}"
|
|
}
|
|
items:
|
|
- name: base64
|
|
request:
|
|
path: /v1/base64
|
|
response:
|
|
body: aGVsbG8=
|
|
encoder: base64
|
|
- name: prList
|
|
request:
|
|
path: /v1/repos/{repo}/prs
|
|
header:
|
|
name: rick
|
|
response:
|
|
header:
|
|
server: mock
|
|
body: |
|
|
{
|
|
"count": 1,
|
|
"items": [{
|
|
"title": "fix: there is a bug on page {{ randEnum "one" }}",
|
|
"number": 123,
|
|
"message": "{{.Response.Header.server}}",
|
|
"author": "someone",
|
|
"status": "success"
|
|
}]
|
|
}
|
|
proxies:
|
|
- path: /v1/myProjects
|
|
target: http://localhost:{{.GetPort}}
|
|
- path: /v1/invalid-template
|
|
target: http://localhost:{{.GetPort}
|
|
webhooks:
|
|
- timer: 1m
|
|
name: baidu
|
|
request:
|
|
method: GET
|
|
path: http://localhost:{{.GetPort}}/projects
|