feat(opapi)!: generate transport-agnostic client code instead of axios#698
Merged
Conversation
The opapi client generator now emits a Client that takes any transport implementing a minimal generated HttpClient interface instead of an AxiosInstance. to-axios.ts becomes to-request.ts (toAxiosRequest -> toRequest, AxiosRequestConfig -> RequestConfig), and both the generated toApiError and the generated handler detect http errors structurally rather than via axios.isAxiosError, so axios-based transports keep working. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Greptile SummaryThis PR makes generated opapi clients independent of Axios. The main changes are:
Confidence Score: 4/5Consumer builds and fetch-based error handling can break on the new generated client path.
opapi/src/generators/client-node.ts and opapi/src/handler-generator/export-handler.ts Important Files Changed
Reviews (1): Last reviewed commit: "style(opapi): prettier formatting" | Re-trigger Greptile |
- import RequestConfig with an inline type modifier so generated code survives verbatimModuleSyntax consumers - document the HttpClient transport contract: implementations must reject on unsuccessful statuses with the error body under response.data (and fix the changelog example accordingly) - accept structural http errors in the generated handler even when the thrown value is not an Error instance (e.g. cross-realm errors) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Generated errors.ts now uses globalThis.crypto (browsers, web workers, node >= 19, edge runtimes) with a Math.random fallback instead of importing the node crypto module, so generated clients have no node builtin dependencies. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AugustDG
approved these changes
Jul 22, 2026
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.
What
Bumps
@bpinternal/opapito 2.0.0. Theopapiclient generator no longer emits axios-based code:Clientconstructor now takes any transport implementing a minimal generatedHttpClientinterface ({ request: <T>(config: RequestConfig) => Promise<{ data: T }> }) instead of anAxiosInstance, and stores it ashttpClient.to-axios.ts→to-request.ts:toAxiosRequest→toRequest, returning aRequestConfig({ method, url, headers, data }) instead of anAxiosRequestConfig. TheClientProps.toAxiosRequestoverride is nowClientProps.toRequest.toApiErrorand the generated request handler detect http errors structurally (any error carryingresponse.data) instead of viaaxios.isAxiosError, so axios-based transports keep working unchanged.The legacy
openapi-generatorpath (remotetypescript-axiostemplate) is untouched.Why
This lets
@botpress/client(and other generated clients) drop axios entirely in favor of a small fetch-based transport — smaller bundles and one less dependency to hoist. The botpress monorepo change consuming this is prepared separately; until@botpress/apiships with opapi 2.0.0 it post-processes the generated output into this exact shape.Testing
pnpm build,pnpm check:typepass.pnpm test: 25/26 pass; the one failure (server.test.tsbun-types/@types/node lib conflicts) is pre-existing and reproduces on master.🤖 Generated with Claude Code