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

Function resolveSpecForInput

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

Source from the content-addressed store, hash-verified

644 });
645
646 const resolveSpecForInput = (
647 config: Pick<
648 OpenApiSpecConfig,
649 "spec" | "specFormat" | "specOverrides" | "headers" | "queryParams" | "baseUrl"
650 >,
651 httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,
652 ): Effect.Effect<
653 ResolvedSpec,
654 OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError | OpenApiSpecOverrideError
655 > =>
656 Effect.gen(function* () {
657 const adapter = yield* resolveSpecFormatAdapter(
658 options?.specFormats ?? [],
659 config.specFormat,
660 );
661 if (adapter) {
662 if (config.spec.kind !== "url") {
663 return yield* new OpenApiParseError({
664 message: "Spec format adapters require a URL spec input",
665 });
666 }
667 const resolved = yield* adapter.fetch({
668 urls: [config.spec.url],
669 credentials: {
670 ...(config.headers ? { headers: config.headers } : {}),
671 ...(config.queryParams ? { queryParams: config.queryParams } : {}),
672 },
673 httpClientLayer,
674 });
675 return yield* applyOverridesToResolvedSpec(resolved, config.specOverrides);
676 }
677 if (config.spec.kind === "url") {
678 const specText = yield* resolveSpecText(config.spec.url).pipe(
679 Effect.provide(httpClientLayer),
680 );
681 return yield* applyOverridesToResolvedSpec(
682 { specText, specUrl: config.spec.url },
683 config.specOverrides,
684 );
685 }
686 return yield* applyOverridesToResolvedSpec(
687 { specText: config.spec.value },
688 config.specOverrides,
689 );
690 });
691
692 return {
693 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