(
spec: OpenApiSpecInput,
httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,
)
| 567 | |
| 568 | export const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => { |
| 569 | const resolveSpecForInput = ( |
| 570 | spec: OpenApiSpecInput, |
| 571 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, |
| 572 | ): Effect.Effect< |
| 573 | { |
| 574 | readonly specText: string; |
| 575 | }, |
| 576 | OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError |
| 577 | > => |
| 578 | Effect.gen(function* () { |
| 579 | if (spec.kind === "url") { |
| 580 | const specText = yield* resolveSpecText(spec.url).pipe(Effect.provide(httpClientLayer)); |
| 581 | return { specText }; |
| 582 | } |
| 583 | return { specText: spec.value }; |
| 584 | }); |
| 585 | |
| 586 | return { |
| 587 | id: "openapi" as const, |
no test coverage detected