Skip to content

Commit 14867a2

Browse files
authored
More query param examples (#97)
1 parent 6444873 commit 14867a2

5 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
yapi: v1
2+
url: https://api.github.com/search/repositories
3+
method: GET
4+
5+
query:
6+
q: "language:go stars:>1000"
7+
sort: stars
8+
order: desc
9+
per_page: 3
10+
11+
headers:
12+
Accept: application/vnd.github+json
13+
14+
jq_filter: "[.items[] | {name, stars: .stargazers_count, url: .html_url}]"
15+
16+
expect:
17+
status: 200
18+
assert:
19+
- . | length == 3
20+
- .[0].name != null
21+
- .[0].stars > 1000
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
yapi: v1
2+
url: https://hn.algolia.com/api/v1/search
3+
method: GET
4+
5+
query:
6+
tags: front_page
7+
hitsPerPage: 5
8+
9+
jq_filter: "[.hits[] | {title, points, url}]"
10+
11+
expect:
12+
status: 200
13+
assert:
14+
- . | length == 5
15+
- .[0].title != null
16+
- .[0].points != null
17+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
yapi: v1
2+
url: https://jsonplaceholder.typicode.com/posts
3+
method: GET
4+
5+
query:
6+
userId: 1
7+
_limit: 3
8+
9+
jq_filter: "[.[] | {id, title}]"
10+
11+
expect:
12+
status: 200
13+
assert:
14+
- . | length == 3
15+
- .[0].id != null
16+
- .[0].title != null
17+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
yapi: v1
2+
url: https://api.open-meteo.com/v1/forecast
3+
method: GET
4+
5+
query:
6+
latitude: 51.5074
7+
longitude: -0.1278
8+
current: temperature_2m,wind_speed_10m
9+
hourly: temperature_2m
10+
forecast_days: 1
11+
12+
jq_filter: "{location: \"London\", current: .current, hourly_temps: .hourly.temperature_2m[:6]}"
13+
14+
expect:
15+
status: 200
16+
assert:
17+
- .current.temperature_2m != null
18+
- .current.wind_speed_10m != null
19+
- .hourly_temps | length > 0
20+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
yapi: v1
2+
url: https://en.wikipedia.org/w/api.php
3+
method: GET
4+
5+
query:
6+
action: query
7+
list: search
8+
srsearch: "API design"
9+
srlimit: 5
10+
format: json
11+
origin: "*"
12+
13+
headers:
14+
Accept: application/json
15+
User-Agent: yapi-example/1.0
16+
17+
jq_filter: "[.query.search[] | {title, snippet}]"
18+
19+
expect:
20+
status: 200
21+
assert:
22+
- . | length == 5
23+
- .[0].title != null
24+
- .[0].snippet != null
25+

0 commit comments

Comments
 (0)