MCPcopy Index your code
hub / github.com/massCodeIO/massCode / parseOperation

Function parseOperation

src/main/http/import/openapi.ts:500–556  ·  view source on GitHub ↗
(
  root: UnknownRecord,
  collection: HttpImportCollection,
  foldersByTag: Map<string, string>,
  environmentVariables: Record<string, string>,
  path: string,
  pathItem: UnknownRecord,
  method: string,
  operation: UnknownRecord,
  warnings: HttpImportWarning[],
)

Source from the content-addressed store, hash-verified

498}
499
500function parseOperation(
501 root: UnknownRecord,
502 collection: HttpImportCollection,
503 foldersByTag: Map<string, string>,
504 environmentVariables: Record<string, string>,
505 path: string,
506 pathItem: UnknownRecord,
507 method: string,
508 operation: UnknownRecord,
509 warnings: HttpImportWarning[],
510): HttpImportRequest | null {
511 const source = `${collection.name}/${method.toUpperCase()} ${path}`
512 const normalizedMethod = normalizeHttpMethod(method, source, warnings)
513 if (!normalizedMethod)
514 return null
515
516 const parameters = parseParameters(
517 [...asArray(pathItem.parameters), ...asArray(operation.parameters)],
518 root,
519 )
520 Object.assign(environmentVariables, parameters.pathExamples)
521
522 const rawUrl = joinUrl(getServerUrl(root, pathItem, operation), path)
523 const parsedUrl = splitUrlAndQuery(rawUrl)
524 const security = parseSecurity(root, operation, source, warnings)
525 Object.assign(environmentVariables, security.variables)
526
527 const headers = normalizeEntries(
528 [...parameters.headers, ...security.headers],
529 source,
530 warnings,
531 )
532 const query = normalizeEntries(
533 [
534 ...mergeQueryEntries(parsedUrl.query, parameters.query),
535 ...security.query,
536 ],
537 source,
538 warnings,
539 )
540 const body = parseRequestBody(operation.requestBody, root, source, warnings)
541 const parts = createEmptyRequestParts()
542
543 return {
544 ...parts,
545 ...body,
546 auth: resolveAuthConflict(headers, security.auth, source, warnings),
547 description: getDescription(operation),
548 folderId: getFolderId(collection, foldersByTag, operation),
549 headers,
550 method: normalizedMethod,
551 name: getRequestName(operation, method, path),
552 query,
553 sourceId: asString(operation.operationId) || undefined,
554 url: parsedUrl.url,
555 }
556}
557

Callers 1

parseOpenApiFileFunction · 0.85

Calls 15

normalizeHttpMethodFunction · 0.90
splitUrlAndQueryFunction · 0.90
normalizeEntriesFunction · 0.90
createEmptyRequestPartsFunction · 0.90
resolveAuthConflictFunction · 0.90
parseParametersFunction · 0.85
joinUrlFunction · 0.85
getServerUrlFunction · 0.85
parseSecurityFunction · 0.85
parseRequestBodyFunction · 0.85
getFolderIdFunction · 0.85
getRequestNameFunction · 0.85

Tested by

no test coverage detected