openapi-codegen: support components.headers - #5476
Open
magdzikk wants to merge 8 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds first-class support for components.headers in the OpenAPI model layer, including parsing, merging, reference resolution, and endpoint generation coverage.
Changes:
- Extend
OpenapiComponentto includeheadersand parse them from OpenAPI components. - Resolve
OpenapiHeaderRefagainstcomponents.headers(with fallback tocomponents.parameters) and merge headers inOpenApiMerger. - Add tests for parsing, ref resolution, merging behavior, and endpoint generation for referenced headers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openapi-codegen/core/src/main/scala/sttp/tapir/codegen/openapi/models/OpenapiComponent.scala | Adds headers to OpenapiComponent and parses/re-keys components.headers entries. |
| openapi-codegen/core/src/main/scala/sttp/tapir/codegen/openapi/models/OpenapiModels.scala | Updates header ref resolution to check components.headers before components.parameters. |
| openapi-codegen/core/src/main/scala/sttp/tapir/codegen/OpenApiMerger.scala | Merges components.headers across documents with left-biased conflict resolution. |
| openapi-codegen/core/src/test/scala/sttp/tapir/codegen/models/ModelParserSpec.scala | Adds parser and resolution tests for components.headers and header refs. |
| openapi-codegen/core/src/test/scala/sttp/tapir/codegen/PackageReuseSpec.scala | Adds merger test coverage for components.headers. |
| openapi-codegen/core/src/test/scala/sttp/tapir/codegen/EndpointGeneratorSpec.scala | Adds generator test verifying response header generation from components.headers refs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
magdzikk
marked this pull request as ready for review
August 18, 2026 13:07
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.
Add support for
$refpointing tocomponents.headers(previously it supported only parameters).A response header written as
$ref: '#/components/headers/Foo'passed ref validation and then failed at generation withIllegalStateException: Response component #/components/headers/Foo is referenced but not found.Fixing this now, as it will happen more often when we add support for reusable headers (#1411, #5478).
Documents that do not use
components.headersare unaffected.