Skip to content

Commit e626b04

Browse files
committed
chore: add outputs in path parameters test
1 parent ffa4ccc commit e626b04

3 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`should resolve step outputs in path parameters 1`] = `
4+
"────────────────────────────────────────────────────────────────────────────────
5+
6+
Running workflow outputs-in-path-parameters.arazzo.yaml / photo-by-menu-item-id
7+
8+
✓ GET /menu - step search-menu-by-id
9+
10+
    Request URL: https://api.cafe.redocly.com/menu?search=prd_0000000000seedtrams0000000
11+
    Request Headers:
12+
      accept: application/json, application/problem+json
13+
14+
15+
    Response status code: 200
16+
    Response time: <test> ms
17+
    Response Headers: <response headers test>
18+
    Response Size: <test> bytes
19+
    Response Body:
20+
      {
21+
       "object": "list",
22+
       "page": {
23+
       "startCursor": null,
24+
       "endCursor": null,
25+
       "hasNextPage": false,
26+
       "hasPrevPage": false,
27+
       "limit": 10,
28+
       "total": 0
29+
       },
30+
       "items": []
31+
      }
32+
33+
    ✓ success criteria check - $statusCode == 200
34+
    ✓ status code check - $statusCode in [200, 400, 500]
35+
    ✓ content-type check
36+
    ✓ schema check
37+
38+
✓ GET /menu-item-images/{menuItemId} - step get-menu-item-photo
39+
40+
    Request URL: https://api.cafe.redocly.com/menu-item-images/prd_0000000000seedtrams0000000
41+
    Request Headers:
42+
      accept: text/plain
43+
44+
45+
    Response status code: 200
46+
    Response time: <test> ms
47+
    Response Headers: <response headers test>
48+
    Response Size: <test> bytes
49+
    Response Body:
50+
      A classic Italian tiramisu layered with mascarpone and espresso
51+
52+
    ✓ success criteria check - $statusCode == 200
53+
    ✓ success criteria check - $response.body == 'A classic Italian tiramisu laye...
54+
    ✓ status code check - $statusCode in [200, 404, 500]
55+
    ✓ content-type check
56+
    ✓ schema check
57+
58+
59+
  Summary for outputs-in-path-parameters.arazzo.yaml
60+
  
61+
  Workflows: 1 passed, 1 total
62+
  Steps: 2 passed, 2 total
63+
  Checks: 9 passed, 9 total
64+
  Time: <test>ms
65+
66+
67+
┌────────────────────────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────┬──────────┐
68+
│ Filename │ Workflows │ Passed │ Failed │ Warnings │
69+
├────────────────────────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────┼──────────┤
70+
│ ✓ outputs-in-path-parameters.arazzo.yaml │ 1 │ 1 │ - │ - │
71+
└────────────────────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┘
72+
73+
74+
"
75+
`;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Test resolved path parameter rendering in verbose output
4+
description: >-
5+
Chains a step output into a path parameter and renders the resolved request URL
6+
in verbose output.
7+
The id is taken from the request query so every printed response body stays deterministic.
8+
version: 1.0.0
9+
10+
sourceDescriptions:
11+
- name: cafe-api
12+
type: openapi
13+
url: ../cafe-api.yaml
14+
15+
workflows:
16+
- workflowId: photo-by-menu-item-id
17+
description: >-
18+
This workflow demonstrates how a step output resolves inside a path parameter.
19+
steps:
20+
- stepId: search-menu-by-id
21+
description: >-
22+
Search the menu by a menu item id and capture the id from the request query.
23+
operationId: cafe-api.listMenuItems
24+
parameters:
25+
- in: query
26+
name: search
27+
value: prd_0000000000seedtrams0000000
28+
successCriteria:
29+
- condition: $statusCode == 200
30+
outputs:
31+
menuItemId: $request.query.search
32+
- stepId: get-menu-item-photo
33+
description: >-
34+
Retrieve the photo text description using the menu item id from the previous step.
35+
operationId: cafe-api.getMenuItemPhoto
36+
parameters:
37+
- in: path
38+
name: menuItemId
39+
value: $steps.search-menu-by-id.outputs.menuItemId
40+
- in: header
41+
name: Accept
42+
value: text/plain
43+
successCriteria:
44+
- condition: $statusCode == 200
45+
- condition: $response.body == 'A classic Italian tiramisu layered with mascarpone and espresso'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
4+
import { getCommandOutput, getParams } from '../../helpers.js';
5+
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
8+
test('should resolve step outputs in path parameters', () => {
9+
const indexEntryPoint = join(process.cwd(), 'packages/cli/lib/index.js');
10+
const fixturesPath = join(__dirname, 'outputs-in-path-parameters.arazzo.yaml');
11+
const args = getParams(indexEntryPoint, ['respect', fixturesPath, '--verbose']);
12+
13+
const result = getCommandOutput(args);
14+
expect(result).toMatchSnapshot();
15+
}, 60_000);

0 commit comments

Comments
 (0)