Repository navigation
feat: support OpenAPI 3.2 QUERY and additionalOperations - #2645
Merged
Merged
Conversation
OpenAPI 3.2 adds the fixed `query` operation (HTTP QUERY) and an `additionalOperations` map of arbitrary HTTP methods to the Path Item. kin-openapi v0.152.0 already surfaces both through PathItem.Operations(), so the generator picked them up everywhere except route registration, where the per-method router shortcuts (router.Get, router.GET, ...) do not exist for these methods. Route registration now falls back to each router's string-method API for any non-standard method: chi.MethodFunc, echo Add, gin Handle, fiber Add (v2 single method, v3 slice), iris Handle. net/http, gorilla/mux and the client already took the method as a string. The echo EchoRouter interface gains an Add method only when the spec uses a custom method, so existing specs keep the same interface. gin's CONNECT and TRACE also go through Handle now; gin has no shortcut for them and the previous output did not compile. Routers that only accept methods they have been told about (chi via chi.RegisterMethod, fiber via Config.RequestMethods) are deliberately not set up by the generated code: that state is process-wide, and one process commonly hosts several generated packages. The README and the per-router docs describe the one-time startup step instead; iris is documented as needing nothing. A new conformance fixture generates a 3.2 spec with GET, QUERY and a custom PURGE for every server framework plus the client, and its test drives real QUERY/PURGE requests through each router. Regenerating the repo leaves all pre-existing generated files byte-identical. Closes oapi-codegen#2436 Co-Authored-By: Claude Fable 5.1 <[email protected]>
mromaszewicz
force-pushed
the
feat/issue-2436
branch
from
October 31, 2026 20:14
ff9c13d to
539de94
Compare
Contributor
[Medium impact] The change affects generated routing for OpenAPI 3.2 methods across supported server frameworks. The PR appears safe to merge, with a non-blocking fix recommended for repeated test runs. Findings
Fix with agent prompt### Issue 1
internal/test/servers/routers/methods/methods_test.go:115-120
`TestChi` fails when repeated in the same process, such as with `go test -count=2 ./servers/routers/methods` from `internal/test`. The first run registers `QUERY` and `PURGE` process-wide. On the second run, `chiapi.Handler` no longer panics, so the opening `assert.Panics` fails even though routing works. Run the unregistered-method check in a fresh subprocess so it does not depend on shared state.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds route registration for OpenAPI 3.2
Acknowledged intentional choices from Reviews (1) · Last reviewed commit: "feat: support OpenAPI 3.2 QUERY and addi..." · Reviewed by 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.
Closes #2436
What
OpenAPI 3.2 adds the fixed
queryoperation (HTTPQUERY) and anadditionalOperationsmap of arbitrary HTTP methods to the Path Item. kin-openapi v0.152.0 (already our dependency) surfaces both throughPathItem.Operations(), so gathering, pruning, filtering, models and the client already handled them. Route registration did not: every router's per-method shortcut (router.Get,router.GET, ...) has no equivalent for these methods.Generated code
Non-standard methods now register through each router's string-method API:
r.MethodFunc("QUERY", ...)router.Add("QUERY", ...);EchoRoutergainsAddonly when the spec uses a custom methodrouter.Handle("QUERY", ...)router.Add("QUERY", ...)/router.Add([]string{"QUERY"}, ...)router.Handle("QUERY", ...)gin's CONNECT and TRACE also go through
Handlenow. gin has no shortcut for either, so the previous output did not compile.Application-side setup (notable)
chi (
chi.RegisterMethod) and fiber (Config.RequestMethods) only accept methods they have been told about. The generated code deliberately does not do that setup: it is process-wide state and one process commonly hosts several generated packages. The README section anddocs/{chi,fiber,fiber-v3,iris}-server.mddescribe the one-time step inmain(). iris routes custom methods without setup;iris.RegisterMethodsis documented as optional forAny()coverage.Compatibility
Specs that use only standard methods produce byte-identical output; a full
make generatechanges no pre-existing generated file. The only shape change for affected specs is theAddmethod on echo'sEchoRouterinterface, which*echo.Echoand*echo.Groupalready satisfy.Testing
New fixture
internal/test/servers/routers/methods/generates a 3.2 spec (GET, QUERY with body, PURGE with path + query params) for all nine server targets plus the client. The test sends real QUERY and PURGE requests through each router and checks parameter binding, and asserts that chi and fiber panic without the documented setup.make tidy && make test && make generate && make lintall clean.🤖 Generated with Claude Code