feat: header parameters - #8
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for OpenAPI in: header parameters in the axum server generator, lowering them into a typed per-operation headers struct extracted via a generated FromRequestParts implementation.
Changes:
- Extend the server IR and lowering pipeline to collect header parameters (with reserved header-name filtering and explicit unsupported-case rejection).
- Emit per-operation
<Op>Headersstructs plusFromRequestPartsextractors and plumb them through generated handlers andApitrait method signatures. - Add fixtures + compile tests for header parameters and update the bookstore example + README to exercise/document the feature.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents header-parameter support, behavior, and limitations. |
| examples/bookstore/tests/smoke.rs | Updates example Api impl to accept generated CreateBookHeaders. |
| examples/bookstore/openapi.yaml | Adds required Idempotency-Key header parameter to createBook. |
| examples/bookstore/generated/restapi.rs | Regenerates example server code to include header extractor and updated trait/handler signature. |
| crates/oapi-codegen/tests/generated/server_header_params.rs | Adds generated-code fixture demonstrating header struct + extractor output. |
| crates/oapi-codegen/tests/generated_compiles.rs | Adds a compile test that ensures generated header extraction integrates with axum. |
| crates/oapi-codegen/tests/fixtures/server_unsupported_array_header_param.yaml | Adds an unsupported-case fixture for array-typed header params. |
| crates/oapi-codegen/tests/fixtures/server_header_params.yaml | Adds a supported header-params fixture including reserved header filtering. |
| crates/oapi-codegen/tests/coverage.rs | Registers new fixtures in supported/unsupported coverage sets. |
| crates/oapi-codegen/src/paths.rs | Lowers header params into IR with override/ignore rules and scalar-only validation. |
| crates/oapi-codegen/src/ir.rs | Introduces IR types for per-operation headers and header parameters. |
| crates/oapi-codegen/src/emit.rs | Emits header structs + FromRequestParts impls and wires them into trait/handlers. |
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.