(
config: Pick<OpenApiSpecConfig, "spec" | "specFormat" | "headers" | "queryParams" | "baseUrl">,
httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,
)
| 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, |
no test coverage detected