GeezerVison is showing github.com — Cover remaining OpenAPI 3.1 union test positions by bendrucker · Pull Request #2530 · oapi-codegen/oapi-codegen
Conversation
bendrucker
commented
Aug 19, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Adds conformance tests for the multi-type union positions the #2522 review found missing.
A union in array-items position lowers to a []any alias and round-trips mixed member values. A union as a oneOf branch keeps the outer schema's union machinery with an any-typed accessor, so As... never fails and branch discrimination falls to the caller. A union-typed response header exercises the Types list that ClientWithResponses passes when binding declared headers, which had no test. The allOf position is skipped because #2526 already covers both member orderings.
Test-only. Repo-wide make generate changes nothing outside the two openapi31 suites.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
greptile-apps[bot] reacted with thumbs up emoji
The review of oapi-codegen#2522 asked for the untested union positions to be
committed. Three surfaces had no conformance coverage:
- array items: a named array component whose items are a union lowers to
a []any alias and round-trips mixed member values
- a union as a oneOf branch: the outer schema keeps the standard union
machinery with the branch accessor typed any, whose As... conversion
can never fail, so branch discrimination falls to the caller
- response headers: ResponseHeaderDefinition.SchemaTypes() feeds the
Types list the generated ClientWithResponses passes when binding
declared response headers, previously exercised by no test
The allOf position is already pinned by the spec added in oapi-codegen#2526 (both
member orderings), so it is deliberately not duplicated here.
Greptile Summary
The PR expands OpenAPI 3.1 multi-type union conformance coverage without changing generator implementation.
- Adds array-item and oneOf-branch union fixtures and generated models.
- Verifies union-typed response headers preserve member-order parsing through
ClientWithResponses.
- Documents the intentionally permissive behavior of an
any-typed oneOf branch.
Confidence Score: 5/5
The test-only PR appears safe to merge, with no concrete correctness or generated-API failures identified.
The added specifications, generated fixtures, and tests consistently exercise the intended OpenAPI 3.1 union behavior, and the generated diffs contain no unrelated API drift.
Important Files Changed
| Filename |
Overview |
| internal/test/openapi31/spec.yaml |
Adds representative array-item and oneOf-branch multi-type union schemas consistent with the generated fixtures. |
| internal/test/openapi31/openapi31_test.go |
Tests the intended []any lowering and explicitly pins the permissive oneOf branch-accessor behavior. |
| internal/test/openapi31/openapi31.gen.go |
Generated output contains the expected array alias and standard oneOf union machinery without unrelated drift. |
| internal/test/openapi31params/spec.yaml |
Declares an integer-or-string response header on the existing HTTP 200 response. |
| internal/test/openapi31params/openapi31params_test.go |
Exercises generated response-header parsing for both integer and string members through the real client/server path. |
| internal/test/openapi31params/openapi31params.gen.go |
Generated response parsing correctly passes the ordered schema types to the runtime styled-parameter binder. |
Reviews (1): Last reviewed commit: "Cover remaining OpenAPI 3.1 union positi..." | Re-trigger Greptile
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.