feat: response headers - #16
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for OpenAPI-declared response headers in the axum server generator, lowering them into IR and emitting them as fields on response enum variants that are written into the HeaderMap during IntoResponse.
Changes:
- Lower declared response headers into IR (
ResponseCase.headers/ResponseHeader) and validate supported shapes. - Emit response variants with named header fields and best-effort header insertion in
IntoResponse. - Add fixtures + snapshot/compile tests and document the feature/unsupported cases in the README.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents response-header support and unsupported header shapes/refs. |
| crates/oapi-codegen/src/ir.rs | Extends response IR with ResponseHeader and per-case headers. |
| crates/oapi-codegen/src/lower/paths.rs | Lowers response headers, adds header-name validation helper, and threads headers into response cases. |
| crates/oapi-codegen/src/emit/axum.rs | Emits header-bearing response variants and inserts headers into the response HeaderMap. |
| crates/oapi-codegen/tests/fixtures/server_response_headers.yaml | Adds a supported fixture exercising required/optional response headers. |
| crates/oapi-codegen/tests/generated/server_response_headers.rs | Snapshot of newly generated server output for response headers. |
| crates/oapi-codegen/tests/generated_compiles.rs | Includes the new generated module and adds a compile-time behavior test for header writing. |
| crates/oapi-codegen/tests/fixtures/server_unsupported_object_response_header.yaml | Adds an unsupported fixture for object-typed response headers. |
| crates/oapi-codegen/tests/fixtures/server_unsupported_bytes_response_header.yaml | Adds an unsupported fixture for byte/binary response headers. |
| crates/oapi-codegen/tests/coverage.rs | Registers the new supported/unsupported fixtures in coverage enforcement. |
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.