fix: correct OpenAPI generated commands#10
Draft
0xpolarzero wants to merge 1 commit into
Draft
Conversation
Owner
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
bd0622d to
82fdb10
Compare
82fdb10 to
566e631
Compare
52cec2a to
a0b2d92
Compare
566e631 to
5ba7b9e
Compare
This was referenced May 26, 2026
5ba7b9e to
0e7571b
Compare
be2d6c8 to
fa160fa
Compare
ab3e5d1 to
2518d21
Compare
fa160fa to
7dafb0a
Compare
2518d21 to
ef926cd
Compare
7dafb0a to
b1b7cd8
Compare
ef926cd to
0dc678e
Compare
b1b7cd8 to
3bc3c58
Compare
3bc3c58 to
4ea8a93
Compare
a0219ef to
cdcf15a
Compare
4ea8a93 to
35f0956
Compare
cdcf15a to
376d391
Compare
35f0956 to
a85e2fe
Compare
376d391 to
56fdb12
Compare
b845bdb to
97d2f44
Compare
56fdb12 to
15a1c55
Compare
97d2f44 to
7b4938d
Compare
15a1c55 to
4485b15
Compare
7b4938d to
f41724c
Compare
f41724c to
608fddd
Compare
d057ed3 to
118f835
Compare
3426a16 to
7060b71
Compare
ba9090d to
b441dc7
Compare
7060b71 to
06da51e
Compare
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.

Overview
Fix correctness bugs in commands generated from OpenAPI specs.
generateCommands()turns OpenAPI operations into incur commands: path parameters become positional args, query parameters and JSON object body properties become options, andrun()calls the provided fetch handler. Several edge cases did not preserve that contract.Issue
Generated commands could differ from the spec in these user-visible ways:
additionalOperationscommands were not generated;Tests failing before fix
Path-level parameters
src/Openapi.test.tsPath item metadata such as
parametersandsummaryshould not become commands, and the realgetoperation should inheritorgId.OpenAPI 3.2 additional operations
src/Openapi.test.tsOpenAPI 3.2 uses
additionalOperationsfor custom operation methods. The generated command should exist, inherit path-level parameters, preserve the custom method key, and build the request URL normally.Path parameter encoding
src/Openapi.test.tsPath parameter values are data, not path structure. A slash inside a parameter value must be encoded.
Path arg order
src/Openapi.test.tsUsers type positional path args in URL order. The parameter array order can differ from the path template, so generated args must follow the template.
Optional JSON object bodies
src/Openapi.test.tsIf the request body is optional, omitting every body field should be valid. But if any body field is provided, the body schema's required properties still apply.
src/Openapi.test.tsA defaulted property should not make an omitted optional body count as provided. Explicitly providing that property should still count as providing the body.
Required JSON object bodies with no provided fields
src/Openapi.test.tsIf the object body itself is required, the generated request still needs to send
{}when no body fields are provided.Strict OpenAPI booleans
src/Openapi.test.tsOpenAPI boolean parameters should accept only real booleans and the CLI strings
"true"and"false". They should not use JavaScript truthiness.Boolean enum parameters
src/Openapi.test.tsz.fromJSONSchema()represents boolean enums as a union of boolean literals, not asZodBoolean. The generator recognizes the common[true, false]enum as a normal strict boolean option.Regression guards
These tests cover behavior that could regress while fixing the bugs above:
src/Openapi.test.ts: OpenAPI 3.2queryoperations inherit path-level parameters.src/Openapi.test.ts: operation-level parameters override path-level parameters with the samein:name.src/Openapi.test.ts: query options do not make an optional request body count as provided.src/Openapi.test.ts: required body properties still fail validation when omitted from a required JSON object body.src/Openapi.test.ts: unsupported non-object request bodies do not get a fake{}body.src/Openapi.test.ts: a single-value boolean enum is not treated as a general boolean flag.src/Openapi.test.ts: mixed literal enums are not collapsed into booleans.src/Openapi.test.ts: transformed generated booleans render as flags in help.src/Openapi.test.ts: transformed generated booleans do not consume the next completion word.src/Openapi.test.ts: generated boolean schemas do not leak an internal metadata marker.src/Parser.test.ts,src/Help.test.ts, andsrc/Completions.test.ts: generated-style transformed booleans are classified without executing transforms during parser/help/completion introspection.src/Parser.test.ts,src/Help.test.ts, andsrc/Completions.test.ts: arbitrary boolean preprocessors are not treated as bare flags.src/Parser.test.ts,src/Help.test.ts, andsrc/Completions.test.ts: boolean-output schemas such asz.literal(false)andz.stringbool()are not treated as bare flags.Fix
generateCommands()now:queryandadditionalOperations;in:name;{}for required JSON object bodies when no body field is present;Generated OpenAPI booleans are represented as schemas that accept real booleans plus the CLI strings
"true"and"false", then output booleans. Parser/help/completions detect that public input/output shape instead of callingsafeParse(true)andsafeParse(false), so introspection does not execute user validation code.