@scalar/api-client
Version:
the open source API testing client
21 lines (20 loc) • 658 B
JavaScript
import { parse as n } from "yaml";
import { isDocument as t } from "./is-document.js";
function o(e) {
if (!t(e))
return !1;
try {
const r = JSON.parse(e ?? "");
return typeof (r == null ? void 0 : r.openapi) == "string" ? `OpenAPI ${r.openapi} JSON` : typeof (r == null ? void 0 : r.swagger) == "string" ? `Swagger ${r.swagger} JSON` : !1;
} catch {
}
try {
const r = n(e ?? "");
return typeof (r == null ? void 0 : r.openapi) == "string" ? `OpenAPI ${r.openapi} YAML` : typeof (r == null ? void 0 : r.swagger) == "string" ? `Swagger ${r.swagger} YAML` : !1;
} catch {
}
return !1;
}
export {
o as getOpenApiVersion
};