@scalar/api-client
Version:
the open source API testing client
38 lines (37 loc) • 815 B
JavaScript
import { convert as r } from "@scalar/postman-to-openapi";
function e(n) {
try {
const o = JSON.parse(n);
return o.info?._postman_id !== void 0 && new URL(o.info?.schema).host === "schema.getpostman.com";
} catch {
return !1;
}
}
function i(n) {
try {
const o = JSON.parse(n), t = r(o);
return JSON.stringify(t, null, 2);
} catch {
throw new Error("Failed to convert Postman collection to OpenAPI");
}
}
function c(n) {
try {
if (e(n)) {
const o = JSON.parse(n);
return {
type: "json",
title: o.info?.name || "Postman Collection",
version: o.info?.version || "1.0"
};
}
return null;
} catch {
return null;
}
}
export {
i as convertPostmanToOpenApi,
c as getPostmanDocumentDetails,
e as isPostmanCollection
};