Add support for HTTP QUERY verb (RFC 10008)#2844
Conversation
👷 Deploy request for openapi-ts pending review.Visit the deploys page to approve it
|
|
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
| File | Description |
|---|---|
| packages/openapi-typescript/test/yaml.test.ts | Snapshot update to include query?: never in generated output. |
| packages/openapi-typescript/test/transform/webhooks-object.test.ts | Snapshot update for webhook path-items to include query?: never. |
| packages/openapi-typescript/test/transform/schema-object/enum.test.ts | Snapshot updates to include query?: never in generated paths. |
| packages/openapi-typescript/test/transform/paths-object.test.ts | Snapshot updates to include query?: never across path transforms. |
| packages/openapi-typescript/test/transform/path-item-object.test.ts | Adds/validates a query operation transform and updates snapshots accordingly. |
| packages/openapi-typescript/test/transform/components-object.test.ts | Snapshot updates to include query?: never in component-derived paths. |
| packages/openapi-typescript/test/node-api.test.ts | Snapshot updates for Node API output to include query?: never. |
| packages/openapi-typescript/test/index.test.ts | Snapshot updates for main index generator output to include query?: never. |
| packages/openapi-typescript/test/discriminators.test.ts | Snapshot updates to include query?: never in discriminator fixture output. |
| packages/openapi-typescript/src/types.ts | Extends PathItemObject to define `query?: OperationObject |
| packages/openapi-typescript/src/transform/paths-object.ts | Ensures query is included when iterating operations for path-param extraction. |
| packages/openapi-typescript/src/transform/paths-enum.ts | Allows query operations to contribute to the generated API paths enum. |
| packages/openapi-typescript/src/transform/path-item-object.ts | Extends internal Method union and method iteration list to include query. |
| packages/openapi-typescript/scripts/schemas.ts | Adds simple-example to the schema list used by example generation scripts. |
| packages/openapi-typescript/examples/stripe-api.ts | Regenerated example output reflecting the new query?: never method slot. |
| packages/openapi-typescript/examples/simple-example.ts | Regenerated example output reflecting the new query?: never method slot. |
| packages/openapi-typescript/examples/octokit-ghes-3.6-diff-to-api.ts | Regenerated example output reflecting the new query?: never method slot. |
| packages/openapi-typescript/examples/digital-ocean-api.ts | Regenerated example output reflecting the new query?: never method slot. |
| packages/openapi-typescript-helpers/src/index.ts | Extends exported HttpMethod union with "query". |
| packages/openapi-react-query/test/fixtures/api.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/read-write-visibility/schemas/read-write.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/path-based-client/schemas/path-based-client.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/middleware/schemas/middleware.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/trace.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/put.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/post.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/patch.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/options.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/head.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/get.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/http-methods/schemas/delete.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/test/common/schemas/common.d.ts | Fixture update to include query?: never in paths. |
| packages/openapi-fetch/src/index.js | Adds runtime QUERY() method to the core client. |
| packages/openapi-fetch/src/index.d.ts | Adds typed QUERY: ClientMethod<..., "query", ...> to the client interface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ing it to schemas.ts breaks download-schemas.ts
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)