Fix enum collision names, multipart JSON parts, and operation deprecation - #98
Merged
Merged
Conversation
Enum values whose names collide once converted to an identifier were numbered with an underscore: `"amber-strict"` and `"amber+strict"` were `AmberStrict` and `AmberStrict_2`. rustc's `non_camel_case_types` lint accepts an underscore only between two characters without case, so every such variant warned. Schema and parameter enums now share `numbered_variant_name`, which appends the number directly (`AmberStrict2`) and keeps the underscore only after a digit, where dropping it would run two numbers together (`"v1"` and `"V1"` are `V1` and `V1_2`). The corpus moves for 11 specs, by renames only: no public item appears or disappears. Fixes #89
A multipart field that wasn't binary or a scalar made the generated method return `HttpError::Config` before sending anything, so any operation with an object field couldn't be called. Cloudflare's KV write with metadata, Images upload and Pages deployments are among them. Following OpenAPI's encoding defaults, a field that is an object, a union of objects or arbitrary JSON is now one part, serialized with serde_json and typed `application/json`. `encoding.<field>.contentType` is now carried into the analysis. When it names a single media type, that is the part's type, whatever the field holds: `image/png` on a binary field, `text/plain; charset=utf-8` on a string, another JSON type on an object. A comma-separated list, or a range such as `image/*`, is the set the server accepts, so the part gets none. Parts with neither a filename nor a content type are emitted as before. Arrays, including arrays of files, are still rejected. They are the second half of #87. Across the corpus, the generated methods that return this error go from 64 to 36, all of them array fields. Refs #87
`Operation.deprecated` was parsed and then dropped: `OperationInfo` had no field for it, so `generate_operation_doc_comment`'s promise to mark the method `#[deprecated]` was never kept, and T13's acceptance criterion stayed open. `OperationInfo.deprecated` carries it now, and every client method generated for a deprecated operation is `#[deprecated]`, its transport variants and builder entry point included. A builder's `send` calls the method on the caller's behalf, who was warned at the entry point, so it allows the deprecation rather than warning in the generated code. The corpus moves for the 24 specs with deprecated operations, by 735 `#[deprecated]` lines and nothing else. Fixes #95
… integrated corpus
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Combine the reviewed enum naming, multipart JSON encoding, and operation deprecation changes from #93, #94, and #97. Colliding enum variants use camel-case numbered names, multipart object fields are sent as JSON parts with declared content types, and deprecated client operations warn their callers.
The deprecation regression test now passes
--color=neverto its child Cargo command. CI setsCARGO_TERM_COLOR=always, which previously inserted ANSI escapes into the diagnostics and caused the test to count zero deprecation errors despite the expected two being present.The branch preserves the original PR commits, reconciles the changelog, and regenerates the combined corpus manifest. #96 is excluded pending its nullable file-array and helper/model naming fixes, documented in #96 (comment).
Validation:
CARGO_TERM_COLOR=always cargo nextest run --profile ci --all-featurespasses all 718 tests (6 skipped), including generated multipart clients/servers and WebAssembly compilation. Formatting, Clippy with warnings denied, 7 doctests (3 ignored), and documentation with warnings denied pass. The corpus manifest was regenerated across all 56 pinned specifications (224 generated files); GitHub's corpus-diff gate also passes. The unchanged deprecation test failed with CI color enabled, and the one-line child-Cargo color override fixes it.