feat(openapi): add --schema flag to inspect request body shapes#66
Merged
Conversation
Every generated command that takes a request body now accepts --schema, which prints the body's resolved JSON schema (types, descriptions, enums, formats, required fields) plus a filled-in example, then exits without making an API call or requiring a token. This closes the discovery gap where --help told an agent a body was required but said nothing about its shape. The schema is derived entirely from the embedded spec, so it covers all body operations (including the ~56 without a hand-written shorthand) with no per-endpoint maintenance. allOf members are merged into a single object; nesting is depth-capped and $ref cycles are guarded so deeply nested or self-referential bodies can't blow up the output. The example skeleton includes only required fields, filled from the spec's field-level examples, then defaults, first enum value, or a typed placeholder. The flag short-circuits before positional-arg validation, body assembly, auth, and the HTTP call, so `omni <cmd> --schema` works with no args and no token. Normal runs (arg validation, shorthands, --body/stdin) are unchanged. Discovery is wired into per-command --help and agent-help. go.yaml.in/yaml/v4 (already a transitive dep via libopenapi) is promoted to a direct dependency for decoding schema example/default/enum nodes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Egqycqj1GcK81yyLxNeg4
The --schema dump described map-typed fields by their `properties` and
`items` only, so fields that carry their value shape in
`additionalProperties` — e.g. documents v2-create's
`queryPresentations.data`, a tile object keyed by tab ID — rendered as a
bare `{type: object}` with the value schema dropped. The data was in the
spec (QueryPresentationPatchExternal) but never reached the output.
simplifySchema now expands additionalProperties (mirroring the Items
handling), and synthExample renders one representative `<key>` entry for
pure map types so the example shows the value shape. Recursion/depth
guards still bound the output.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H8ndoDtArqEjtDRjzjEJGE
Deeply nested bodies (notably documents v2-create) produce a ~400KB
--schema dump that's unwieldy to read. Two flags make it navigable:
--field <dotpath> drill to a sub-schema, e.g. queryPresentations.data.query.
The path auto-descends through array items and map
(additionalProperties) values, so a caller can name a leaf
without knowing the container shape. Unknown segments error
with the fields available at that level — which doubles as
discovery.
--depth N cap expansion depth; --schema --depth 1 gives a compact
top-level overview (428KB -> ~1.7KB on v2-create).
Both scope the body and the synthesized example, and compose. The recursive
describers move onto a small describer{maxDepth} value so --depth threads
through without a global. Schema errors silence cobra's usage block so only the
helpful message prints. agent-help documents the new flags.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H8ndoDtArqEjtDRjzjEJGE
dspangen
force-pushed
the
feat/body-schema-flag
branch
from
June 26, 2026 01:28
dc60f08 to
9c2abbe
Compare
n8agrin
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--schemato every command that takes a request body. It prints the body's resolved JSON schema (types, descriptions, enums, formats, required) plus a filled-in example, then exits — no API call, no token. Closes the discovery gap:--helpsays a body is required but nothing about its shape, so agents guess and eat 400s.For deeply nested bodies (e.g.
documents v2-create, ~400KB) two flags narrow the output:--depth N— cap expansion;--schema --depth 1is a ~3KB top-level overview.--field <dotpath>— drill to a sub-schema, e.g.queryPresentations.data.query. Auto-descends arrays and maps, so you name a leaf without knowing the container shape. Unknown segments error with the available fields (doubles as discovery).Map-typed fields (
additionalProperties, e.g.queryPresentations.data) now expand their value schema instead of dropping it.🤖 Generated with Claude Code