feat: extensions - #23
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the schema/model lowering + model emitter pipeline to recognize and apply several vendor extensions (e.g. renaming, ordering, serde skipping/omitempty, and deprecation notes), and adds fixture/snapshot coverage to lock the behavior in.
Changes:
- Add support for multiple vendor extensions in model lowering (
x-rust-name,x-order,x-rust-serde-skip,x-omitempty,x-deprecated-reason,x-enum-varnames/x-enumNames). - Extend the IR + model emitter to carry and render
#[deprecated(...)]and updated serde attributes for fields. - Add a dedicated fixture + generated snapshot, and register it in compile + coverage harnesses.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| examples/bookstore/schemas/catalog.yaml | Adds x-order on fields to demonstrate/drive ordering behavior. |
| examples/bookstore/generated/apimodel/catalog.rs | Snapshot update showing reordered fields due to x-order. |
| crates/oapi-codegen/tests/generated/ext_vendor_extensions.rs | New snapshot covering supported vendor extensions end-to-end. |
| crates/oapi-codegen/tests/generated_compiles.rs | Ensures the new generated snapshot is included in the compile test harness. |
| crates/oapi-codegen/tests/fixtures/ext_vendor_extensions.yaml | New fixture exercising vendor extensions (rename/order/deprecation/serde behaviors). |
| crates/oapi-codegen/tests/coverage.rs | Marks new extension features as supported and adds the new fixture to the generated test table. |
| crates/oapi-codegen/src/lower/schema.rs | Implements vendor extension extraction and applies them during schema lowering (including ordering and deprecation). |
| crates/oapi-codegen/src/lower/rename.rs | New pass to rewrite RustType::Named references to honor x-rust-name type renames across the lowered IR. |
| crates/oapi-codegen/src/lower/paths.rs | Updates service/param lowering struct/field construction for new IR fields. |
| crates/oapi-codegen/src/lower/mod.rs | Exposes the new rename rewrite helpers from lower. |
| crates/oapi-codegen/src/lib.rs | Applies the rename rewrite pass to lowered services before pruning/emission. |
| crates/oapi-codegen/src/ir.rs | Extends the IR to carry deprecation + serde omit/skip controls, plus a helper to detect Option. |
| crates/oapi-codegen/src/emit/models.rs | Emits #[deprecated] and updated #[serde(...)] attributes based on the extended IR. |
Contributor
|
🎉 This PR is included in version 1.0.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Contributor
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
No description provided.