(files: HttpImportFile[])
| 376 | } |
| 377 | |
| 378 | export function parsePostmanFiles(files: HttpImportFile[]): HttpImportResult { |
| 379 | const warnings: HttpImportWarning[] = [] |
| 380 | const collections: HttpImportCollection[] = [] |
| 381 | const environments: HttpImportEnvironment[] = [] |
| 382 | |
| 383 | for (const file of files) { |
| 384 | if (!isJsonFile(file)) |
| 385 | continue |
| 386 | |
| 387 | const raw = readJsonFile(file, warnings) |
| 388 | if (!raw) { |
| 389 | continue |
| 390 | } |
| 391 | |
| 392 | if (isPostmanCollection(raw)) { |
| 393 | collections.push(parseCollection(raw, file.name, warnings)) |
| 394 | |
| 395 | const variables = parseVariables(raw.variable, file.name, warnings) |
| 396 | if (Object.keys(variables).length > 0) { |
| 397 | const infoName = isRecord(raw.info) ? raw.info.name : undefined |
| 398 | environments.push({ |
| 399 | name: `${normalizeImportName(infoName, file.name.replace(/\.json$/i, ''))} Variables`, |
| 400 | variables, |
| 401 | }) |
| 402 | } |
| 403 | |
| 404 | continue |
| 405 | } |
| 406 | |
| 407 | if (isPostmanEnvironment(raw)) { |
| 408 | environments.push(parseEnvironment(raw, file.name, warnings)) |
| 409 | continue |
| 410 | } |
| 411 | |
| 412 | if (isOpenApiDocument(raw)) |
| 413 | continue |
| 414 | |
| 415 | addWarning(warnings, file.name, 'Unsupported import file skipped') |
| 416 | } |
| 417 | |
| 418 | return { collections, environments, warnings } |
| 419 | } |
no test coverage detected