Conversation
Registering Method QUERY no longer panics in AddOperation; the operation is stored under PathItem.Query (OpenAPI 3.2), with a huma.Query convenience wrapper and humatest Query helpers.
Contributor
|
Let's wait for golang/go#80134. |
This branch has not been deployed
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.
Fixes #1123
Summary
Adds first-class support for the HTTP
QUERYmethod (RFC 10008): a safe, idempotent method that carries a request body, sitting betweenGETandPOST.huma.Registerno longer panics withunknown method QUERY; the operation is stored underPathItem.Query(OpenAPI 3.2).huma.Queryconvenience wrapper, mirroringhuma.Get/Post/....humatestgainsQuery/QueryCtxhelpers for parity with the other verbs.MethodQueryis defined in Huma (nothttp.MethodQuery) because the stdlib constant is only on Go master (CL 822384), not in any release. It is a plain"QUERY"string, so callers can keep using the raw literal too.Known limitation: OpenAPI version
Huma emits
openapi: 3.1.0, but thequerypath item is only defined in OpenAPI 3.2. The key is emitted whenever a QUERY operation exists; tools validating strictly against the 3.1 schema may reject or ignore it (and it also passes throughDowngrade()to 3.0.3). Happy to gate it or bump the emitted version if you prefer a different trade-off — kept the change minimal here.Notes
MethodQueryis a local constant becausehttp.MethodQueryis not in a Go release yet (only on master, CL 822384). Once it ships, we can drop the local constant (and the raw"QUERY"literal) and usehttp.MethodQuery.net/httpalready routes the raw method, so no stdlib change is required to use this.golang/go#80488).