Skip to content

Commit 0911c07

Browse files
authored
feat: redocly respect support for testing arazzo files (#9)
1 parent 4c1c273 commit 0911c07

File tree

17 files changed

+342
-235
lines changed

17 files changed

+342
-235
lines changed

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"redocly-bundle": "./dist/bin/redocly/bundle.js",
2525
"redocly-lint": "./dist/bin/redocly/lint.js",
2626
"redocly-build-docs": "./dist/bin/redocly/build-docs.js",
27-
"redocly-generate-arazzo": "./dist/bin/redocly/generate-arazzo.js"
27+
"redocly-generate-arazzo": "./dist/bin/redocly/generate-arazzo.js",
28+
"redocly-respect": "./dist/bin/redocly/respect.js"
2829
},
2930
"scripts": {
3031
"build": "tsc",

src/bin/redocly/respect.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
import { respect } from "../../lib/redocly/respect.js";
4+
5+
respect();

src/lib/redocly/respect.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { execSync } from "child_process";
2+
3+
export interface RespectOptions {
4+
files: string;
5+
verbose: boolean;
6+
harOutput?: string;
7+
jsonOutput?: string;
8+
}
9+
10+
export function getOptions(): RespectOptions {
11+
return {
12+
files: process.env.ARAZZO_INPUT || "arazzo/*.arazzo.yaml",
13+
verbose: process.env.ARAZZO_VERBOSE === "true",
14+
harOutput: process.env.ARAZZO_HAR_OUTPUT,
15+
jsonOutput: process.env.ARAZZO_JSON_OUTPUT,
16+
};
17+
}
18+
19+
export function respect(): void {
20+
const options = getOptions();
21+
22+
console.log(`🧪 Running Arazzo workflows...`);
23+
console.log(` Files: ${options.files}`);
24+
25+
let command = `npx --no @redocly/cli respect ${options.files}`;
26+
27+
if (options.verbose) {
28+
command += ` --verbose`;
29+
}
30+
31+
if (options.harOutput) {
32+
command += ` --har-output ${options.harOutput}`;
33+
console.log(` HAR Output: ${options.harOutput}`);
34+
}
35+
36+
if (options.jsonOutput) {
37+
command += ` --json-output ${options.jsonOutput}`;
38+
console.log(` JSON Output: ${options.jsonOutput}`);
39+
}
40+
41+
try {
42+
execSync(command, { stdio: "inherit" });
43+
console.log(`✅ Arazzo workflows executed successfully.`);
44+
} catch (error) {
45+
console.error(`❌ Arazzo workflows failed!`);
46+
console.error(`${error instanceof Error ? error.message : String(error)}`);
47+
process.exit(1);
48+
}
49+
}

test/__snapshots__/bundle.integration.test.ts.snap

Lines changed: 0 additions & 217 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Invalid Workflow
4+
5+
workflows:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Simple Test API
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: openapi
7+
type: openapi
8+
url: ../test/fixtures/valid/simple-spec/openapi.yaml
9+
workflows:
10+
- workflowId: get-test-workflow
11+
inputs:
12+
$ref: "#/components/inputs/BearerToken"
13+
parameters:
14+
- name: Authorization
15+
value: Bearer {$inputs.BearerToken}
16+
in: header
17+
steps:
18+
- stepId: get-test-step
19+
operationId: $sourceDescriptions.openapi.getTest
20+
successCriteria:
21+
- condition: $statusCode == 200
22+
components:
23+
inputs:
24+
BearerToken:
25+
type: object
26+
properties:
27+
BearerToken:
28+
type: string
29+
description: JWT Authentication token for ${name}
30+
format: password
File renamed without changes.
File renamed without changes.

test/fixtures/valid/spec-with-refs/components/schemas.yaml renamed to test/fixtures/openapi/valid/spec-with-refs/components/schemas.yaml

File renamed without changes.

0 commit comments

Comments
 (0)