feat: add operationId, tag rules, and envelope-aware response splitting#51
Merged
Conversation
…elope test(integration): add end-to-end test for operationId, tags, and envelope
…ex under --strict
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 three backwards-compatible features to
generate:1.
operationIdgeneration (--operation-id-strategy)Derives stable camelCase operationIds from HTTP method + path template so openapi-generator-cli produces readable Rust method names:
Flags:
--operation-id-strategy {none,path,template},--operation-id-overrides <yaml>,--operation-id-template <tmpl>2. Regex-based tag rules (
--tag-rules)Assigns one tag per operation via a YAML rules file (first-match-wins). Tags are used by openapi-generator to split operations into separate source files:
Flags:
--tag-strategy {legacy,none,path-segment,rules},--tag-rules <yaml>,--tag-segment-index <N>3. Envelope-aware response splitting (
--envelope-discriminator)MEXC and similar exchange APIs always return HTTP 200 with a
successboolean discriminator. This flag splits captured bodies into per-operation{OperationId}Successschemas and a sharedcomponents/schemas/ApiError, connected viaoneOf+ discriminator annotation:Flags:
--envelope-discriminator <field>,--envelope-error-shape <yaml>,--envelope-success-component-suffix <string>4. Deterministic output
Sorts all paths and component schemas alphabetically before serialization so diffs are byte-stable across runs.
Backwards Compatibility
All new flags default to the v0.6.0 behaviour — snapshot test
tests/snapshot_compat.rsenforces byte-identical output when no new flags are passed.Tests
tag_rules+ 17operation_id+ 8envelopetests)cargo clippy --all-targets -- -D warningscleanNew files
src/tag_rules.rs— regex-based tag matching modulesrc/operation_id.rs— camelCase operationId derivation + collision resolutionsrc/envelope.rs— discriminator-based response splitting