name = JSON Response Capture Examples
description = Demonstrates direct, nested, defaulted, and dependency-based JSON response captures using Lorem API.
$ BASE = https://lorem-api.com/api
---
Get Article
GET {{ BASE }}/article/foo
? format = json
& body.slug -> $ARTICLE_SLUG
& body.title -> $ARTICLE_TITLE
& body.author.id -> $AUTHOR_ID
& body.author.name -> $AUTHOR_NAME
& body.author.email -> $AUTHOR_EMAIL
& body.author.company -> $AUTHOR_COMPANY := unknown
# Article request succeeds
^ & status == 200
# Captures the article slug
^ $ARTICLE_SLUG == 'foo'
# Captures the article title
^ $ARTICLE_TITLE != ''
# Captures the author id
^ $AUTHOR_ID ~= /[A-Fa-f0-9-]+/
# Captures the author name
^ $AUTHOR_NAME != ''
# Captures the author email
^ $AUTHOR_EMAIL ~= /@/
# Uses the default company value
^ $AUTHOR_COMPANY == 'unknown'
---
Get Author Profile
> requires: Get Article
GET {{ BASE }}/user/{{ AUTHOR_ID }}
& body.name -> $PROFILE_NAME
& body.avatar -> $PROFILE_AVATAR
&[Get Article].body.author.email -> $UPSTREAM_AUTHOR_EMAIL
&[Get Article].body.title -> $UPSTREAM_ARTICLE_TITLE
# Profile request succeeds
^ & status == 200
# Loads the captured author id
^ & body.id == $AUTHOR_ID
# Captures the profile name
^ $PROFILE_NAME != ''
# Captures the profile avatar
^ $PROFILE_AVATAR ~= /https?:\/\//
# Reuses the upstream author email
^ $UPSTREAM_AUTHOR_EMAIL == $AUTHOR_EMAIL
# Reuses the upstream article title
^ $UPSTREAM_ARTICLE_TITLE == $ARTICLE_TITLE