UNPKG

@scalar/api-client

Version:

the open source API testing client

41 lines (40 loc) 902 B
import * as t from "monaco-editor/esm/vs/editor/editor.api.js"; import { configureMonacoYaml as r } from "monaco-yaml"; import n from "../schemas/openapi-3.1-schema.json.js"; const s = "inmemory://model/scalar/openapi-json-schema", m = (e) => { const o = t.languages.json.jsonDefaults, a = o.diagnosticsOptions, c = [ ...(a.schemas ?? []).filter((i) => i.uri !== s), { uri: s, fileMatch: [e], schema: n } ]; o.setDiagnosticsOptions({ ...a, validate: !0, enableSchemaRequest: !1, schemas: c }); }, u = (e) => { r(t, { enableSchemaRequest: !1, validate: !0, format: !0, completion: !0, hover: !0, schemas: [ { // If YAML file is opened matching this glob fileMatch: [e], schema: n, uri: s } ] }); }, p = (e) => { m(e), u(e); }; export { p as configureLanguageSupport };