UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

43 lines (42 loc) 1.8 kB
import { defineComponent as c, computed as i, createBlock as s, createElementBlock as u, openBlock as n, unref as l } from "vue"; import { ScalarCodeBlock as a, ScalarVirtualText as p } from "@scalar/components"; import { prettyPrintJson as f } from "@scalar/oas-utils/helpers"; import { getExampleFromSchema as d } from "@scalar/oas-utils/spec-getters"; import { getResolvedRef as g } from "@scalar/workspace-store/helpers/get-resolved-ref"; import { getResolvedRefDeep as h } from "./helpers/get-resolved-ref-deep.js"; const v = { key: 3, class: "empty-state" }, m = 3e4, C = /* @__PURE__ */ c({ __name: "ExampleResponse", props: { response: {}, example: {} }, setup(o) { const r = (e) => typeof e == "string" ? e.length > m : typeof e == "object" && e !== null ? JSON.stringify(e).length > m : !1, t = i(() => o.example !== void 0 ? h(o.example)?.value ?? "" : o.response?.schema ? d(g(o.response.schema), { emptyString: "string", mode: "read" }) : ""); return (e, x) => e.example !== void 0 && !r(t.value) ? (n(), s(l(a), { key: 0, class: "bg-b-2 -outline-offset-2", content: t.value, lang: "json" }, null, 8, ["content"])) : e.response?.schema && !r(t.value) ? (n(), s(l(a), { key: 1, class: "bg-b-2 -outline-offset-2", content: t.value, lang: "json" }, null, 8, ["content"])) : (e.example !== void 0 || e.response?.schema) && r(t.value) ? (n(), s(l(p), { key: 2, containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen", contentClass: "language-plaintext whitespace-pre font-code text-base", lineHeight: 20, text: l(f)(t.value) }, null, 8, ["text"])) : (n(), u("div", v, " No Body ")); } }); export { C as default };