Cover remaining OpenAPI 3.1 union test positions - #2530
Open
bendrucker wants to merge 2 commits into
Open
bendrucker wants to merge 2 commits into
bendrucker wants to merge 2 commits into
Conversation
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.
Contributor
Greptile SummaryThe PR expands OpenAPI 3.1 multi-type union conformance coverage without changing generator implementation.
Confidence Score: 5/5The 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.
|
| 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
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.
Adds conformance tests for the multi-type union positions the #2522 review found missing.
A union in array-items position lowers to a
[]anyalias and round-trips mixed member values. A union as a oneOf branch keeps the outer schema's union machinery with anany-typed accessor, soAs...never fails and branch discrimination falls to the caller. A union-typed response header exercises theTypeslist thatClientWithResponsespasses 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 generatechanges nothing outside the two openapi31 suites.