Repository navigation
feat: add forge inspect methods, which prints the methods a document makes - #111
dimitropoulos wants to merge 2 commits into
Conversation
forge methods <spec> prints each method's group path and name, in kebab-case, with its HTTP method, path, hidden, deprecated and availability, as JSON. Other tools can compare the methods of two versions of a document without naming operations themselves, so they agree with forge on x-forge-group-name, x-forge-method-name and the operationId fallback.
There was a problem hiding this comment.
🟡 Changes recommended
The duplicate-name fixture in tests/cli.rs uses single-line operation objects instead of the existing one-member-per-line format.
1 open issue
What changed in this PR
Adds forge methods <spec> to expose Forge-resolved method names and metadata as JSON, helping tools compare API commands without duplicating Forge’s naming rules.
Changes:
- Registers the new CLI command and adds JSON serialization of method metadata.
- Adds tests for naming, metadata, skipped operations, and duplicate-name errors.
- Documents usage, normalization pipelines, output ordering, and error behavior.
| File | Description |
|---|---|
tests/cli.rs |
Adds method-listing and invalid-document integration tests. |
src/bin/forge/methods.rs |
Implements document reading and JSON method output. |
src/bin/forge/main.rs |
Registers and dispatches the command; tests argument parsing. |
packages/forge/README.md |
Documents method listing and its output format. |
Review effort: Balanced
| "get": {"operationId": "a.get", "responses": {"200": {"description": "ok"}}}, | ||
| "post": {"operationId": "a.get", "responses": {"200": {"description": "ok"}}} |
commit: |
|
Great feature.
So something like
|
forge inspect prints what forge reads in a document, as JSON, with methods as its first subcommand, so groups, models and the rest can follow under the same command.

Adds
forge inspect methods <spec>, which prints the methods a document makes as a JSON array. Each entry has the method's group path and name in kebab-case, plus its HTTP method, path,hidden,deprecatedandavailability.forge normalize openapi.json | forge inspect methods -[ { "group": ["dns", "records"], "name": "list", "method": "GET", "path": "/zones/{zone_id}/dns_records", "hidden": false, "deprecated": false, "availability": "generally-available" } ]Why
Tools that need to know which methods (and therefore which CLI commands) a document defines, such as CI that flags new or renamed commands on a spec change, otherwise have to reimplement forge's naming rules:
x-forge-group-namesplitting,x-forge-method-name,x-forge-skip, aliases, and theoperationIdfallback from #51. With this command, forge's own resolution is the source of truth and callers just diff the output.Notes
forge inspectis the parent command for printing what forge reads in a document.methodsis the first subcommand; groups, models, security schemes and so on can follow under it.Forge::groups()(depth first from the root), with methods sorted by name within each group, so the output is stable.x-forge-*keys. Runforge normalizefirst for Fern or Stainless keys.forge normalize. All of them parse, and each takes a few milliseconds.