Skip to content
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
76aa567
docs: add graph command design spec
kanoru3101 Jun 11, 2026
4901e9d
docs: add graph command implementation plan
kanoru3101 Jun 11, 2026
159d367
feat: add dependency graph builder for graph command
kanoru3101 Jun 11, 2026
ec61bfc
docs: sync graph plan with review fixes (slash, ResolveError, typeche…
kanoru3101 Jun 11, 2026
66e168e
feat: add affected-files filter for graph command
kanoru3101 Jun 11, 2026
f0f6022
feat: add graph command output renderers
kanoru3101 Jun 11, 2026
32421fc
docs: reconcile mermaid label escaping in graph spec with implementation
kanoru3101 Jun 11, 2026
f5d3fe3
feat: register graph command in CLI
kanoru3101 Jun 11, 2026
0db7f34
docs: document repeated --affected-by flag syntax in graph spec and plan
kanoru3101 Jun 11, 2026
0bd9972
test: add graph command e2e tests
kanoru3101 Jun 11, 2026
fd71521
docs: document graph command and add changeset
kanoru3101 Jun 11, 2026
fa6d868
docs: align spec warning wording with implementation
kanoru3101 Jun 11, 2026
cb940b7
docs: add tree command rework spec and plan
kanoru3101 Jun 12, 2026
873b7b7
refactor: rename graph command to tree
kanoru3101 Jun 12, 2026
759df76
feat: add pointer-to-node mapping for the tree structure view
kanoru3101 Jun 12, 2026
38a12d4
feat: add internal-structure builder for the tree command
kanoru3101 Jun 12, 2026
9e7c47d
refactor: make stylish summary and empty message caller-provided
kanoru3101 Jun 12, 2026
5013774
feat: match affected-by inputs against tree nodes
kanoru3101 Jun 12, 2026
b20163b
feat: make document structure the default tree view behind --files fa…
kanoru3101 Jun 12, 2026
bcdebfa
test: cover tree structure mode end to end
kanoru3101 Jun 12, 2026
0fb8560
docs: document the tree command and update the changeset
kanoru3101 Jun 12, 2026
8f2e055
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 12, 2026
dcf6a67
fix: hoist entity test imports to avoid per-test transform timeout
kanoru3101 Jun 12, 2026
ff3ad50
docs: unbreak documentation tests for the tree command
kanoru3101 Jun 15, 2026
2b0b60d
refactor(tree): share toNodeId/byString/OPERATION_METHODS via node-id
kanoru3101 Jun 15, 2026
e12ebba
fix: improvments
kanoru3101 Jun 15, 2026
a71529c
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 17, 2026
d925da9
refactor: tidy tree renderer sort and trim a restating comment
kanoru3101 Jun 17, 2026
6607ffc
test: drop redundant tree tests (runtime round-trip, path.resolve var…
kanoru3101 Jun 17, 2026
755baa3
docs: clarify --affected-by per mode and JSON field scope in tree docs
kanoru3101 Jun 17, 2026
f87eb4d
test: cover multi-API rejection in default view and multi-API --files…
kanoru3101 Jun 17, 2026
6348a8e
fix: tidy tree command — share mode context, dedupe location mapping,…
kanoru3101 Jun 17, 2026
b46857f
Merge remote-tracking branch 'origin/main' into feat/graph-command
kanoru3101 Jun 17, 2026
7efffd9
fix: remove comments
kanoru3101 Jun 17, 2026
655dc5e
Merge remote-tracking branch 'origin/main' into feat/graph-command
kanoru3101 Jun 22, 2026
3e690f6
fix: refactoring
kanoru3101 Jun 22, 2026
e411931
fix: resolve bug with splitted files
kanoru3101 Jun 22, 2026
3273609
fix: update tests
kanoru3101 Jun 22, 2026
d6e78f8
Apply suggestions from code review
JLekawa Jun 23, 2026
fb2f569
Update tree.md
JLekawa Jun 23, 2026
7aa745b
Update docs/@v2/commands/tree.md
JLekawa Jun 23, 2026
94256c8
docs(cli): fix issues in file
JLekawa Jun 23, 2026
9c02500
Apply suggestion from @JLekawa
JLekawa Jun 23, 2026
c460414
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 23, 2026
f8f3f83
fix: add spaces in the options-table separator
kanoru3101 Jun 23, 2026
1df3366
fix: refactoring and update snapshots
kanoru3101 Jun 24, 2026
3738f2a
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 24, 2026
820d75e
fix: update docs
kanoru3101 Jun 24, 2026
8917cf0
Merge branches 'feat/graph-command' and 'feat/graph-command' of githu…
kanoru3101 Jun 24, 2026
1f161b5
fix: resolve cursor bugs
kanoru3101 Jun 24, 2026
e111d75
fix: update docs
kanoru3101 Jun 24, 2026
8bef8af
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 25, 2026
dce5f2f
chore: small fixes
kanoru3101 Jun 26, 2026
4cdd016
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 1, 2026
64fb2dd
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 2, 2026
dda77cf
feat: add level flag
kanoru3101 Jul 13, 2026
96a6cbf
test: add snapshot
kanoru3101 Jul 13, 2026
a5bfe1f
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 13, 2026
40ea0d7
feat(tree): show operationId on operation nodes
kanoru3101 Jul 16, 2026
d7c39f7
docs(tree): fix options table having a stray fourth column
kanoru3101 Jul 17, 2026
2bfcd8c
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 17, 2026
71bbe5e
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 27, 2026
b9a4953
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 28, 2026
562b9cf
refactor(tree): move the engine to core and walk resolved files with …
kanoru3101 Aug 3, 2026
0ff91b5
Merge branch 'main' into feat/graph-command
kanoru3101 Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/graph-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@redocly/cli': minor
---

Added the `graph` command that prints the file-level `$ref` dependency graph of API descriptions as a tree (`stylish`), `json`, or `mermaid` output. The `--affected-by` option filters the graph to the files impacted by changes to the given files.
86 changes: 86 additions & 0 deletions docs/@v2/commands/graph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# `graph`

## Introduction

The `graph` command prints the file-level dependency graph of an API description: which files reference which other files through `$ref`. It works with multi-file OpenAPI, AsyncAPI, and Arazzo descriptions.

Use it to:

- get a quick `tree`-style overview of a multi-file API description;
- find out which files are affected by a change to a shared file (`--affected-by`) — for example, in CI or automated code review;
- feed exact file relationships to tooling as JSON or render them as a Mermaid diagram.

## Usage

```bash
redocly graph
redocly graph <apis...>
redocly graph <apis...> [--format=<value>] [--affected-by=<file>] [--config=<path>]
```

If you don't pass any API to the command, it processes all APIs defined in your Redocly configuration file and prints them as a single graph with shared files deduplicated — one tree per API root in the default view.

## Options

| Option | Type | Description |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| apis | [string] | Paths to API description files. Defaults to all APIs from the Redocly configuration file. |
| --affected-by | [string] | Show only the part of the graph affected by changes to the given files: the files themselves plus everything that references them. Repeat the option to pass several files: `--affected-by a.yaml --affected-by b.yaml`. |
| --config | string | Specify the path to the [Redocly configuration file](../configuration/index.md). |
| --format | string | Output format: `stylish` (default, tree view), `json`, or `mermaid`. |
| --help | boolean | Show help. |
| --lint-config | string | Specify the severity level for the configuration file. <br/> **Possible values:** `warn`, `error`, `off`. Default value is `warn`. |
| --version | boolean | Show version number. |

## Examples

### Print the dependency tree

```bash
redocly graph openapi.yaml
```

```

Check failure on line 43 in docs/@v2/commands/graph.md

View workflow job for this annotation

GitHub Actions / markdownlint

Fenced code blocks should have a language specified

docs/@v2/commands/graph.md:43 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md040.md
openapi.yaml
├── paths/pets.yaml
│ └── components/schemas/Pet.yaml
└── paths/users.yaml
└── components/schemas/User.yaml
├── components/schemas/Address.yaml
└── components/schemas/Pet.yaml ↺
```

The `↺` marker means the file was already expanded earlier in the tree, so its references are not repeated. Files that cannot be resolved are marked with `✗ not found`, and references to URLs are marked with `(external)`.

### Find files affected by a change

Pass a changed file to `--affected-by` to see only the impacted part of the graph — useful in CI and automated review to decide what needs attention without reading every file. Repeat the option to pass several changed files at once.

```bash
redocly graph openapi.yaml --affected-by components/schemas/Address.yaml
```

```

Check failure on line 63 in docs/@v2/commands/graph.md

View workflow job for this annotation

GitHub Actions / markdownlint

Fenced code blocks should have a language specified

docs/@v2/commands/graph.md:63 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md040.md
openapi.yaml
└── paths/users.yaml
└── components/schemas/User.yaml
└── components/schemas/Address.yaml ← changed

4 of 6 files affected · affected roots: openapi.yaml
```

If a file passed to `--affected-by` is not referenced by any processed API, the command prints a warning to stderr and exits with code `0` — "nothing depends on this file" is a valid answer.

### Machine-readable output

```bash
redocly graph openapi.yaml --format=json
```

Prints the graph as JSON with `roots`, `nodes` (including `resolved` and `external` flags), and `edges` (including the exact `$ref` strings). Only the JSON is written to stdout, so the output is safe to pipe.

```bash
redocly graph openapi.yaml --format=mermaid
```

Prints a [Mermaid](https://mermaid.js.org/) `flowchart` definition. GitHub renders Mermaid code blocks in Markdown automatically, so you can paste the output into a pull request comment or documentation page to get a diagram.
1 change: 1 addition & 0 deletions docs/@v2/commands/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Documentation commands:
API management commands:

- [`bundle`](bundle.md) Bundle API description.
- [`graph`](graph.md) Show the `$ref` dependency graph of API description files.
- [`join`](join.md) Join API descriptions [experimental feature].
- [`score`](score.md) Score an API for integration simplicity and AI agent readiness.
- [`split`](split.md) Split API description into a multi-file structure.
Expand Down
2 changes: 2 additions & 0 deletions docs/@v2/v2.sidebars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
page: commands/eject.md
- label: generate-arazzo
page: commands/generate-arazzo.md
- label: graph
page: commands/graph.md
- label: join
page: commands/join.md
- label: lint
Expand Down
Loading
Loading