MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / resolveSpecForInput

Function resolveSpecForInput

packages/plugins/openapi/src/sdk/plugin.ts:599–630  ·  view source on GitHub ↗
(
    config: Pick<OpenApiSpecConfig, "spec" | "specFormat" | "headers" | "queryParams" | "baseUrl">,
    httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,
  )

Source from the content-addressed store, hash-verified

597 OpenApiPluginOptions
598>((options?: OpenApiPluginOptions) => {
599 const resolveSpecForInput = (
600 config: Pick<OpenApiSpecConfig, "spec" | "specFormat" | "headers" | "queryParams" | "baseUrl">,
601 httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,
602 ): Effect.Effect<ConvertedSpec, OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError> =>
603 Effect.gen(function* () {
604 const adapter = yield* resolveSpecFormatAdapter(
605 options?.specFormats ?? [],
606 config.specFormat,
607 );
608 if (adapter) {
609 if (config.spec.kind !== "url") {
610 return yield* new OpenApiParseError({
611 message: "Spec format adapters require a URL spec input",
612 });
613 }
614 return yield* adapter.fetch({
615 urls: [config.spec.url],
616 credentials: {
617 ...(config.headers ? { headers: config.headers } : {}),
618 ...(config.queryParams ? { queryParams: config.queryParams } : {}),
619 },
620 httpClientLayer,
621 });
622 }
623 if (config.spec.kind === "url") {
624 const specText = yield* resolveSpecText(config.spec.url).pipe(
625 Effect.provide(httpClientLayer),
626 );
627 return { specText, specUrl: config.spec.url };
628 }
629 return { specText: config.spec.value };
630 });
631
632 return {
633 id: "openapi" as const,

Callers 3

addSpecFunction · 0.85
updateSpecFunction · 0.85
plugin.tsFile · 0.85

Calls 3

resolveSpecFormatAdapterFunction · 0.90
resolveSpecTextFunction · 0.90
fetchMethod · 0.65

Tested by

no test coverage detected