MCPcopy Create free account
hub / github.com/langgenius/dify / createOpenApiClient

Function createOpenApiClient

cli/src/http/orpc.ts:20–33  ·  view source on GitHub ↗
(http: HttpClient)

Source from the content-addressed store, hash-verified

18// oRPC to decode only 2xx responses;
19// - link wrapper: the one residual throw (a 2xx body oRPC can't decode) -> mapOrpcError.
20export function createOpenApiClient(http: HttpClient): OpenApiClient {
21 const link = new OpenAPILink(contract, {
22 url: http.baseURL,
23 fetch: async (req, init) => {
24 const res = await http.request(req, init)
25 if (!res.ok)
26 throw await classifyResponse(req, res)
27 return res
28 },
29 })
30 return createORPCClient<OpenApiClient>({
31 call: (path, input, options) => link.call(path, input, options).catch(mapOrpcError),
32 })
33}
34
35// Non-2xx and transport failures already arrive as BaseError (from the fetch wrapper / transport)
36// and re-throw unchanged; the only residual is a 2xx body oRPC failed to decode.

Callers 10

constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
orpcClientFunction · 0.85

Calls 4

classifyResponseFunction · 0.85
requestMethod · 0.45
catchMethod · 0.45
callMethod · 0.45

Tested by 1

orpcClientFunction · 0.68