MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / replacePathParamName

Function replacePathParamName

packages/server/src/openapi/transforms.ts:288–309  ·  view source on GitHub ↗
(
  container: Record<string, unknown>,
  from: string,
  to: string,
)

Source from the content-addressed store, hash-verified

286}
287
288function replacePathParamName(
289 container: Record<string, unknown>,
290 from: string,
291 to: string,
292): void {
293 const params = container['parameters'];
294 if (Array.isArray(params)) {
295 for (const param of params) {
296 const record = asRecord(param);
297 if (record?.['in'] === 'path' && record['name'] === from) {
298 record['name'] = to;
299 }
300 }
301 }
302
303 for (const method of ['get', 'post', 'put', 'patch', 'delete']) {
304 const operation = asRecord(container[method]);
305 if (operation !== undefined) {
306 replacePathParamName(operation, from, to);
307 }
308 }
309}
310
311function cloneRecord(value: Record<string, unknown>): Record<string, unknown> {
312 return structuredClone(value);

Callers 1

patchSessionActionsFunction · 0.85

Calls 1

asRecordFunction · 0.70

Tested by

no test coverage detected