UNPKG

@scalar/api-client

Version:

the open source API testing client

21 lines (20 loc) 570 B
import { parse as t } from "yaml"; import { isDocument as n } from "./is-document.js"; function a(e) { if (!n(e)) return !1; try { const r = JSON.parse(e ?? ""); return typeof r?.openapi == "string" ? `OpenAPI ${r.openapi} JSON` : typeof r?.swagger == "string" ? `Swagger ${r.swagger} JSON` : !1; } catch { } try { const r = t(e ?? ""); return typeof r?.openapi == "string" ? `OpenAPI ${r.openapi} YAML` : typeof r?.swagger == "string" ? `Swagger ${r.swagger} YAML` : !1; } catch { } return !1; } export { a as getOpenApiVersion };