-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdog-api.yaml
More file actions
318 lines (307 loc) · 9.09 KB
/
Copy pathdog-api.yaml
File metadata and controls
318 lines (307 loc) · 9.09 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# =============================================================================
# Dog API Browser
# =============================================================================
# Browse dog breeds and facts using the free DogAPI.dog service.
# No authentication required - perfect for demos and learning!
#
# Usage: cargo run -- examples/dog-api.yaml
#
# This example demonstrates:
# - HTTP adapter for REST API calls
# - JSON:API format handling ($.data[*] extraction)
# - Multi-page navigation with context passing
# - Conditional styling based on values
# - Action shortcuts for quick navigation
# - Detailed views for individual items
#
# API: https://dogapi.dog/docs/api-v2
#
# Fun fact: There are over 200 dog breeds recognized worldwide.
# This API knows about most of them. Your terminal is about to get adorable.
# =============================================================================
version: v1
app:
name: "Dog Breeds Browser"
description: "Explore dog breeds and facts"
theme: "default"
globals:
api_base: "https://dogapi.dog/api/v2"
start: breeds
pages:
# --------------------------------------------------------------------------
# Breeds List - Main landing page
# --------------------------------------------------------------------------
# Shows all dog breeds in a beautiful table.
# Press Enter to see breed details, or use actions for quick navigation.
breeds:
title: "Dog Breeds"
data:
adapter: http
url: "{{ api_base }}/breeds"
method: GET
headers:
Accept: "application/json"
items: "$.data[*]"
refresh_interval: "10m"
view:
type: table
columns:
- path: "$.attributes.name"
display: "Breed"
width: 30
style:
- default: true
color: cyan
bold: true
- path: "$.attributes.life.min"
display: "Min Life"
width: 10
style:
- default: true
color: green
- path: "$.attributes.life.max"
display: "Max Life"
width: 10
style:
- default: true
color: green
- path: "$.attributes.male_weight.min"
display: "Male Wt (kg)"
width: 12
style:
- default: true
color: blue
- path: "$.attributes.female_weight.min"
display: "Female Wt (kg)"
width: 14
style:
- default: true
color: magenta
- path: "$.attributes.hypoallergenic"
display: "Hypo"
width: 6
style:
- condition: "{{ value == 'true' }}"
color: yellow
bold: true
- default: true
color: gray
sort:
column: "$.attributes.name"
order: asc
next:
page: breed_detail
context:
breed_id: "$.id"
breed_name: "$.attributes.name"
actions:
- key: "ctrl+f"
name: "View Facts"
description: "View random dog facts"
page: "facts"
- key: "ctrl+g"
name: "View Groups"
description: "View breed groups"
page: "groups"
# --------------------------------------------------------------------------
# Breed Detail - Single breed information
# --------------------------------------------------------------------------
# Detailed view of a specific breed including weight ranges and description.
# Context: breed_id and breed_name passed from breeds page.
breed_detail:
title: "{{ breed_name }}"
data:
adapter: http
url: "{{ api_base }}/breeds/{{ breed_id }}"
method: GET
headers:
Accept: "application/json"
items: "$.data"
view:
type: table
columns:
- path: "$.attributes.name"
display: "Name"
width: 30
style:
- default: true
color: cyan
bold: true
- path: "$.attributes.description"
display: "Description"
width: 80
- path: "$.attributes.life.min"
display: "Min Life (yrs)"
width: 15
style:
- default: true
color: green
- path: "$.attributes.life.max"
display: "Max Life (yrs)"
width: 15
style:
- default: true
color: green
- path: "$.attributes.male_weight.min"
display: "Male Min (kg)"
width: 14
style:
- default: true
color: blue
- path: "$.attributes.male_weight.max"
display: "Male Max (kg)"
width: 14
style:
- default: true
color: blue
- path: "$.attributes.female_weight.min"
display: "Female Min (kg)"
width: 16
style:
- default: true
color: magenta
- path: "$.attributes.female_weight.max"
display: "Female Max (kg)"
width: 16
style:
- default: true
color: magenta
- path: "$.attributes.hypoallergenic"
display: "Hypoallergenic"
width: 15
style:
- condition: "{{ value == 'true' }}"
color: yellow
bold: true
- default: true
color: gray
actions:
- key: "ctrl+f"
name: "View Facts"
description: "View random dog facts"
page: "facts"
- key: "ctrl+y"
name: "View as YAML"
description: "View full JSON response"
page: "breed_yaml"
# --------------------------------------------------------------------------
# Breed YAML View - Raw API response
# --------------------------------------------------------------------------
# Shows the full JSON response formatted as YAML.
# Great for debugging or seeing the complete data structure.
breed_yaml:
title: "{{ breed_name }} (YAML)"
data:
adapter: http
url: "{{ api_base }}/breeds/{{ breed_id }}"
method: GET
headers:
Accept: "application/json"
view:
type: text
syntax: yaml
# --------------------------------------------------------------------------
# Dog Facts - Random fun facts about dogs
# --------------------------------------------------------------------------
# Did you know dogs can smell emotions? Neither did we until this API.
facts:
title: "Dog Facts"
data:
adapter: http
url: "{{ api_base }}/facts"
method: GET
headers:
Accept: "application/json"
items: "$.data[*]"
view:
type: table
columns:
- path: "$.attributes.body"
display: "Fact"
width: 100
style:
- default: true
color: yellow
next:
page: fact_detail
context:
fact_id: "$.id"
fact_body: "$.attributes.body"
# --------------------------------------------------------------------------
# Fact Detail - Single fact view
# --------------------------------------------------------------------------
fact_detail:
title: "Dog Fact"
data:
adapter: http
url: "{{ api_base }}/facts/{{ fact_id }}"
method: GET
headers:
Accept: "application/json"
view:
type: text
syntax: yaml
# --------------------------------------------------------------------------
# Breed Groups - Categories of dog breeds
# --------------------------------------------------------------------------
# Breeds are organized into groups like Herding, Sporting, Toy, etc.
groups:
title: "Breed Groups"
data:
adapter: http
url: "{{ api_base }}/groups"
method: GET
headers:
Accept: "application/json"
items: "$.data[*]"
view:
type: table
columns:
- path: "$.attributes.name"
display: "Group Name"
width: 50
style:
- default: true
color: cyan
bold: true
next:
page: group_detail
context:
group_id: "$.id"
group_name: "$.attributes.name"
# --------------------------------------------------------------------------
# Group Detail - Breeds in a specific group
# --------------------------------------------------------------------------
# Shows details about a breed group including how many breeds it contains.
group_detail:
title: "{{ group_name }}"
data:
adapter: http
url: "{{ api_base }}/groups/{{ group_id }}"
method: GET
headers:
Accept: "application/json"
items: "$.data"
view:
type: table
columns:
- path: "$.id"
display: "Group ID"
width: 40
style:
- default: true
color: blue
- path: "$.attributes.name"
display: "Group Name"
width: 40
style:
- default: true
color: cyan
bold: true
- path: "$.relationships.breeds.data"
display: "Breeds Count"
width: 15
transform: "{{ value | length }}"
style:
- default: true
color: green