Add support for HTTP QUERY verb (RFC 10008) - #2844
Conversation
|
There was a problem hiding this comment.
Pull request overview
Adds first-class support for the HTTP QUERY method across the OpenAPI type generator (openapi-typescript) and the runtime client (openapi-fetch), so OpenAPI 3.2 query operations are no longer silently dropped and can be called via typed client APIs.
Changes:
- Extend OpenAPI/HTTP method unions and path-item typing to include
query, and iterate/validate it through the transform pipeline. - Add
QUERY()to theopenapi-fetchclient surface (runtime + type declarations). - Update fixtures/snapshots and generated example outputs to include
query?: neverwhere appropriate.
Reviewed changes
Copilot reviewed 19 out of 42 changed files in this pull request and generated 3 comments.
Show a summary per file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ing it to schemas.ts breaks download-schemas.ts
QUERY is a safe, idempotent HTTP method that carries a request body, filling the gap between GET (no body) and POST (neither safe nor idempotent). OpenAPI 3.2 recognises `query` as a Path Item verb, but openapi-typescript treated it as an unknown property and dropped it, so no types were generated and openapi-fetch had no way to call it. - openapi-typescript-helpers: add "query" to `HttpMethod` - openapi-typescript: emit a `query` operation for Path Items that declare one, and include it in path-param extraction and the paths enum. Path Items without a `query` operation are left untouched, so no existing generated output changes. - openapi-fetch: add `client.QUERY()` and `QUERY` on the path-based client Follow-up to openapi-ts#2844, which took the same approach but emitted `query?: never` on every Path Item of every document — churning ~4,400 lines of examples and fixtures, the concern its author raised for review. Emitting `query` only where it is declared keeps generated output byte-identical for documents that don't use it. Co-authored-by: Jonty Sewell <jonty@vallaton.co.uk> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Changes
This PR adds support for the HTTP QUERY method (RFC 10008) to openapi-typescript and openapi-fetch.
The QUERY method is a safe, idempotent HTTP method that carries a request body, filling the gap between GET (no body) and POST/PUT (non-idempotent). OpenAPI 3.2 recognises
queryas a valid HTTP method verb, and it passes through YAML->JSON conversion correctly, but openapi-typescript's code generator treated it as an unknown property and silently dropped it, so no TypeScript types were produced.This change adds "query" to the
HttpMethodunion type and the internalMethodtype, includes it in all method iteration and validation arrays across the transformer pipeline, addsQUERY()to the openapi-fetch client, and updates all test snapshots and fixtures accordingly.References:
How to Review
My principal concern in adding this feature is that all output types will be modified, even if they do not make use of
queryanywhere - which could confuse downstream consumers when all their fixtures suddenly change.OpenAPI 3.2 also adds support for other custom HTTP methods through the
additionalOperationsparameter, but adding support for that would be a much wider impact; as thequerymethod is listed as a first-class method under the RFC, I considered it worth adding in its own changeset.One small change I made that might be incorrect/intentionally different: I noted that the
simple-example.tsexample schema is not regenerated along with the rest, due to it not being present inschemas.ts. I added it so it is regenerated automatically withupdate-examples.tsfrom the local schema file, rather than modifying the generated file by hand to get the tests to pass.Checklist
docs/updated (if necessary)pnpm run update:examplesrun (only applicable for openapi-typescript)