MCPcopy
hub / github.com/Effect-TS/effect / middlewareOpenApi

Function middlewareOpenApi

packages/platform/src/HttpApiBuilder.ts:983–1000  ·  view source on GitHub ↗
(
  options?: {
    readonly path?: HttpApiEndpoint.PathSegment | undefined
    readonly additionalPropertiesStrategy?: OpenApi.AdditionalPropertiesStrategy | undefined
  } | undefined
)

Source from the content-addressed store, hash-verified

981 * @category middleware
982 */
983export const middlewareOpenApi = (
984 options?: {
985 readonly path?: HttpApiEndpoint.PathSegment | undefined
986 readonly additionalPropertiesStrategy?: OpenApi.AdditionalPropertiesStrategy | undefined
987 } | undefined
988): Layer.Layer<never, never, HttpApi.Api> =>
989 Router.use((router) =>
990 Effect.gen(function*() {
991 const { api } = yield* HttpApi.Api
992 const spec = OpenApi.fromApi(api, {
993 additionalPropertiesStrategy: options?.additionalPropertiesStrategy
994 })
995 const response = yield* HttpServerResponse.json(spec).pipe(
996 Effect.orDie
997 )
998 yield* router.get(options?.path ?? "/openapi.json", Effect.succeed(response))
999 })
1000 )
1001
1002const bearerLen = `Bearer `.length
1003const basicLen = `Basic `.length

Callers

nothing calls this directly

Calls 3

pipeMethod · 0.65
getMethod · 0.65
jsonMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…