Repository navigation
Type createApiFetcher() endpoints from OpenAPI schemas - #119
Merged
Merged
Conversation
OpenApiEndpoint<paths, Path, Method> takes the types of an endpoint from an OpenAPI schema generated by openapi-typescript: the data of its successful responses, its request body, its query parameters and its path parameters. Responses without content and operations without a request body, query or path parameters are typed as undefined. Path parameters can now be written as {id} too, like in OpenAPI paths, so the paths of a schema can be used as endpoint URLs as they are.
Core bundles 7.75 KB -> 8.75 KB, dist/react/index.mjs 10.75 KB -> 11.75 KB and dist/react/index.js 11.75 KB -> 12.75 KB. The limits fit this and the other PRs opened alongside it (abort signal fix, ETag revalidation, retry jitter and methods, onDownloadProgress, responseType, focusThrottleInterval, initialData and typed OpenAPI endpoints), which add about 1 KB together, so that they can be merged in any order.
size-limit report 📦
|
red-game-dev
approved these changes
Sep 27, 2026
red-game-dev
approved these changes
Sep 27, 2026
Merged
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.
This pull request adds
OpenApiEndpoint, which types the endpoints ofcreateApiFetcher()from an OpenAPI schema generated by openapi-typescript, so that requests and responses are checked against the schema.✨ Features & Improvements
OpenApiEndpoint<paths, Path, Method>type: it takes the data of the successful (2XX) responses, the request body, the query parameters and the path parameters of an operation from the schema, e.g.getUser: OpenApiEndpoint<paths, '/users/{id}', 'get'>. Responses without content and operations without a request body, query or path parameters are typed asundefined.{param}path placeholders: path parameters can now be written as{id}, like in OpenAPI paths, as well as:id, so the paths of a schema can be used as endpoint URLs as they are. Unknown placeholders are kept as they are.🧪 Tests
@ts-expect-error), and responses without content.{param}placeholders, mixed with:paramones, and keeping unknown ones.📦 Bundle Size
The types add nothing to the bundles, and the
{param}placeholders add a few bytes. The size limits are raised to fit this and the other pull requests opened alongside it, so that they can be merged in any order.Generated by Claude Code