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

Function renderGroup

packages/tools/openapi-generator/src/HttpApiTransformer.ts:141–171  ·  view source on GitHub ↗
(
  group: GroupRenderModel,
  endpointMiddlewares: ReadonlyMap<string, ReadonlyArray<string>>
)

Source from the content-addressed store, hash-verified

139}
140
141const renderGroup = (
142 group: GroupRenderModel,
143 endpointMiddlewares: ReadonlyMap<string, ReadonlyArray<string>>
144): string => {
145 let source = `class ${group.constName} extends HttpApiGroup.make(${JSON.stringify(group.identifier)}${
146 group.topLevel ? ", { topLevel: true }" : ""
147 })`
148
149 const allocateEndpointName = makeNameAllocator()
150 const endpointSources = group.operations.map((operation) =>
151 renderEndpoint(
152 operation,
153 allocateEndpointName(operation.id),
154 endpointMiddlewares.get(toOperationKey(operation)) ?? []
155 )
156 )
157 if (endpointSources.length > 0) {
158 source += `\n .add(${endpointSources.join(", \n ")})`
159 }
160
161 if (group.metadata?.description !== undefined) {
162 source += `\n .annotate(OpenApi.Description, ${JSON.stringify(group.metadata.description)})`
163 }
164 if (group.metadata?.externalDocs !== undefined) {
165 source += `\n .annotate(OpenApi.ExternalDocs, ${JSON.stringify(group.metadata.externalDocs)})`
166 }
167
168 source += ` {}`
169
170 return source
171}
172
173const renderEndpoint = (
174 operation: ParsedOperation,

Callers 1

toImplementationFunction · 0.85

Calls 6

makeNameAllocatorFunction · 0.85
renderEndpointFunction · 0.85
toOperationKeyFunction · 0.85
joinMethod · 0.80
getMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected