MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromApiWith

Function fromApiWith

packages/effect/src/unstable/httpapi/OpenApi.ts:286–705  ·  view source on GitHub ↗
(
  api: HttpApi.HttpApi<Id, Groups>,
  cache: WeakMap<HttpApi.Constraint, OpenAPISpec>,
  compileSchemas: CompileSchemas
)

Source from the content-addressed store, hash-verified

284}
285
286function fromApiWith<Id extends string, Groups extends HttpApiGroup.Constraint>(
287 api: HttpApi.HttpApi<Id, Groups>,
288 cache: WeakMap<HttpApi.Constraint, OpenAPISpec>,
289 compileSchemas: CompileSchemas
290): OpenAPISpec {
291 const cached = cache.get(api)
292 if (cached !== undefined) {
293 return cloneOpenAPISpec(cached)
294 }
295 let spec: OpenAPISpec = {
296 openapi: "3.1.0",
297 info: {
298 title: "Api",
299 version: "0.0.1"
300 },
301 paths: {},
302 components: {
303 schemas: {},
304 securitySchemes: {}
305 },
306 security: [],
307 tags: []
308 }
309
310 const pathOps: Array<
311 {
312 readonly _tag: "schema"
313 readonly ast: SchemaAST.AST
314 readonly path: ReadonlyArray<string>
315 } | {
316 readonly _tag: "parameter"
317 readonly ast: SchemaAST.AST
318 readonly path: ReadonlyArray<string>
319 }
320 > = []
321 const pathOperations = new Set<string>()
322 const operationIds = new Set<string>()
323
324 processAnnotation(api.annotations, Title, (title) => {
325 spec.info.title = title
326 })
327 processAnnotation(api.annotations, Version, (version) => {
328 spec.info.version = version
329 })
330 processAnnotation(api.annotations, Description, (description) => {
331 spec.info.description = description
332 })
333 processAnnotation(api.annotations, License, (license) => {
334 spec.info.license = license
335 })
336 processAnnotation(api.annotations, Summary, (summary) => {
337 spec.info.summary = summary
338 })
339 processAnnotation(api.annotations, Servers, (servers) => {
340 spec.servers = [...servers]
341 })
342
343 HttpApi.reflect(api, {

Callers 1

fromApiFunction · 0.85

Calls 9

cloneOpenAPISpecFunction · 0.85
processAnnotationFunction · 0.85
compileSchemasFunction · 0.85
escapePathFunction · 0.85
pushMethod · 0.80
getMethod · 0.65
forEachMethod · 0.65
setMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected