( group: GroupRenderModel, endpointMiddlewares: ReadonlyMap<string, ReadonlyArray<string>> )
| 139 | } |
| 140 | |
| 141 | const 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 | |
| 173 | const renderEndpoint = ( |
| 174 | operation: ParsedOperation, |
no test coverage detected