@har-sdk/core
Version:
The base package can be used to import specification files (i.e. HAR, OAS and Postman Collection) and detect their type.
28 lines • 1.16 kB
JavaScript
import { BaseImporter } from './BaseImporter';
import { ImporterType } from './ImporterType';
export class PostmanImporter extends BaseImporter {
constructor() {
super();
this.POSTMAN_SCHEMAS = new Set([
'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
'https://schema.getpostman.com/json/collection/v2.1.0/collection.json'
]);
}
get type() {
return ImporterType.POSTMAN;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
isSupported(spec) {
var _a;
const schemaId = (_a = spec === null || spec === void 0 ? void 0 : spec.info) === null || _a === void 0 ? void 0 : _a.schema;
return (typeof schemaId === 'string' &&
this.POSTMAN_SCHEMAS.has(schemaId.trim().toLowerCase()));
}
fileName({ doc, format }) {
var _a;
return typeof ((_a = doc === null || doc === void 0 ? void 0 : doc.info) === null || _a === void 0 ? void 0 : _a.name) === 'string'
? `${doc.info.name.trim()}.${format}`
: undefined;
}
}
//# sourceMappingURL=PostmanImporter.js.map