@scalar/api-reference 1.28.20 → 1.28.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,68 +1,63 @@
1
- import { redirectToProxy as A, shouldIgnoreEntity as u } from "@scalar/oas-utils/helpers";
2
- import { load as M, dereference as R } from "@scalar/openapi-parser";
3
- import { fetchUrls as q } from "@scalar/openapi-parser/plugins/fetch-urls";
1
+ import { redirectToProxy as R, shouldIgnoreEntity as u } from "@scalar/oas-utils/helpers";
2
+ import { load as M, dereference as q } from "@scalar/openapi-parser";
3
+ import { fetchUrls as D } from "@scalar/openapi-parser/plugins/fetch-urls";
4
4
  import { createEmptySpecification as O } from "./createEmptySpecification.js";
5
- import { normalizeRequestMethod as $ } from "../legacy/helpers/normalizeRequestMethod.js";
6
- import { validRequestMethods as D } from "../legacy/fixtures/httpRequestMethods.js";
5
+ import { normalizeRequestMethod as j } from "../legacy/helpers/normalizeRequestMethod.js";
6
+ import { validRequestMethods as C } from "../legacy/fixtures/httpRequestMethods.js";
7
7
  const G = (m, {
8
- proxyUrl: e,
9
- source: h
10
- } = {}) => new Promise(async (l, g) => {
11
- var y;
8
+ proxyUrl: e
9
+ } = {}) => new Promise(async (n, b) => {
10
+ var h;
12
11
  try {
13
12
  if (!m)
14
- return l(x(O()));
15
- const s = performance.now(), { filesystem: c } = await M(m, {
16
- source: h,
13
+ return n(I(O()));
14
+ const f = performance.now(), { filesystem: s } = await M(m, {
17
15
  plugins: [
18
- q({
19
- fetch: async (a) => {
20
- const n = await fetch(e ? A(e, a) : a);
21
- return n.ok ? console.info(`fetch($ref): ${a} (${Math.round((await n.clone().text()).length / 1024)} kB)`) : console.error(`fetch($ref): ${a} (${n.status} ${n.statusText})`), n;
22
- }
16
+ D({
17
+ fetch: (o) => fetch(e ? R(e, o) : o)
23
18
  })
24
19
  ]
25
- }), { schema: o, errors: t } = await R(c), r = performance.now();
26
- return console.info(`dereference: ${Math.round(r - s)} ms`), t != null && t.length && console.warn(
20
+ }), { schema: a, errors: r } = await q(s), t = performance.now();
21
+ return console.log(`dereference: ${Math.round(t - f)} ms`), r != null && r.length && console.warn(
27
22
  `Please open an issue on https://github.com/scalar/scalar
28
23
  `,
29
24
  `Scalar OpenAPI Parser Warning:
30
25
  `,
31
- t
32
- ), o === void 0 ? (g(((y = t == null ? void 0 : t[0]) == null ? void 0 : y.message) ?? "Failed to parse the OpenAPI file."), l(x(O()))) : l(x(o));
33
- } catch (s) {
34
- console.error("[@scalar/api-reference]", "Failed to parse the OpenAPI document. It might be invalid?"), console.error(s), g(s);
26
+ r
27
+ ), a === void 0 ? (b(((h = r == null ? void 0 : r[0]) == null ? void 0 : h.message) ?? "Failed to parse the OpenAPI file."), n(I(O()))) : n(I(a));
28
+ } catch (f) {
29
+ console.error("[@scalar/api-reference]", "Failed to parse the OpenAPI document. It might be invalid?"), console.error(f), b(f);
35
30
  }
36
- return l(x(O()));
37
- }), x = (m) => {
38
- var g, y;
31
+ return n(I(O()));
32
+ }), I = (m) => {
33
+ var h, f;
39
34
  let e = {};
40
35
  m && typeof m == "object" ? e = structuredClone(m) : e = O(), e.tags || (e.tags = []), e.paths || (e.paths = {}), e.components || (e.components = {}), e.webhooks || (e.webhooks = {}), e.servers || (e.servers = []), e.security || (e.security = []), e.externalDocs || (e.externalDocs = {});
41
- const h = {};
36
+ const n = {};
42
37
  return Object.keys(e.webhooks ?? {}).forEach((s) => {
43
- var c;
44
- Object.keys(((c = e.webhooks) == null ? void 0 : c[s]) ?? {}).forEach((o) => {
45
- var r, a, n, w;
46
- const t = (r = e.webhooks) == null ? void 0 : r[s][o];
38
+ var a;
39
+ Object.keys(((a = e.webhooks) == null ? void 0 : a[s]) ?? {}).forEach((r) => {
40
+ var o, l, g, y;
41
+ const t = (o = e.webhooks) == null ? void 0 : o[s][r];
47
42
  if (!(!t || u(t))) {
48
43
  if (Array.isArray(t.tags)) {
49
- const i = (a = t.tags) == null ? void 0 : a.map(
50
- (f) => {
51
- var I;
52
- return (I = e.tags) == null ? void 0 : I.find((p) => p.name === f);
44
+ const i = (l = t.tags) == null ? void 0 : l.map(
45
+ (c) => {
46
+ var w;
47
+ return (w = e.tags) == null ? void 0 : w.find((p) => p.name === c);
53
48
  }
54
49
  );
55
- if (t.tags = i == null ? void 0 : i.filter((f) => !u(f)), i != null && i.some((f) => u(f)))
50
+ if (t.tags = i == null ? void 0 : i.filter((c) => !u(c)), i != null && i.some((c) => u(c)))
56
51
  return;
57
52
  }
58
- h[s] === void 0 && (h[s] = {}), h[s][o] = {
53
+ n[s] === void 0 && (n[s] = {}), n[s][r] = {
59
54
  // Transformed data
60
- httpVerb: $(o),
55
+ httpVerb: j(r),
61
56
  path: s,
62
57
  operationId: (t == null ? void 0 : t.operationId) || s,
63
58
  name: (t == null ? void 0 : t.summary) || s || "",
64
59
  description: (t == null ? void 0 : t.description) || "",
65
- pathParameters: (w = (n = e.paths) == null ? void 0 : n[s]) == null ? void 0 : w.parameters,
60
+ pathParameters: (y = (g = e.paths) == null ? void 0 : g[s]) == null ? void 0 : y.parameters,
66
61
  // Original webhook
67
62
  information: {
68
63
  ...t
@@ -70,19 +65,19 @@ const G = (m, {
70
65
  };
71
66
  }
72
67
  });
73
- }), Object.keys(((g = e.components) == null ? void 0 : g.schemas) ?? {}).forEach((s) => {
74
- var c, o, t, r;
75
- u((o = (c = e.components) == null ? void 0 : c.schemas) == null ? void 0 : o[s]) && ((r = (t = e.components) == null ? void 0 : t.schemas) == null || delete r[s]);
68
+ }), Object.keys(((h = e.components) == null ? void 0 : h.schemas) ?? {}).forEach((s) => {
69
+ var a, r, t, o;
70
+ u((r = (a = e.components) == null ? void 0 : a.schemas) == null ? void 0 : r[s]) && ((o = (t = e.components) == null ? void 0 : t.schemas) == null || delete o[s]);
76
71
  }), Object.keys(e.paths).forEach((s) => {
77
72
  Object.keys(e.paths[s]).filter(
78
- (o) => D.includes(o.toUpperCase())
79
- ).forEach((o) => {
80
- var a, n, w, i, f, I;
81
- const t = e.paths[s][o];
73
+ (r) => C.includes(r.toUpperCase())
74
+ ).forEach((r) => {
75
+ var l, g, y, i, c, w;
76
+ const t = e.paths[s][r];
82
77
  if (t === void 0 || u(t))
83
78
  return;
84
- const r = {
85
- httpVerb: $(o),
79
+ const o = {
80
+ httpVerb: j(r),
86
81
  path: s,
87
82
  operationId: t.operationId || s,
88
83
  name: t.summary || s || "",
@@ -90,33 +85,33 @@ const G = (m, {
90
85
  information: {
91
86
  ...t
92
87
  },
93
- pathParameters: (n = (a = e.paths) == null ? void 0 : a[s]) == null ? void 0 : n.parameters
88
+ pathParameters: (g = (l = e.paths) == null ? void 0 : l[s]) == null ? void 0 : g.parameters
94
89
  };
95
90
  if (!t.tags || t.tags.length === 0) {
96
- (w = e.tags) != null && w.find((d) => d.name === "default") || (i = e.tags) == null || i.push({
91
+ (y = e.tags) != null && y.find((d) => d.name === "default") || (i = e.tags) == null || i.push({
97
92
  name: "default",
98
93
  description: "",
99
94
  operations: []
100
95
  });
101
- const p = (f = e.tags) == null ? void 0 : f.findIndex(
96
+ const p = (c = e.tags) == null ? void 0 : c.findIndex(
102
97
  (d) => d.name === "default"
103
98
  );
104
- p >= 0 && ((I = e.tags[p]) == null || I.operations.push(r));
99
+ p >= 0 && ((w = e.tags[p]) == null || w.operations.push(o));
105
100
  } else
106
101
  t.tags.forEach((p) => {
107
- var k, E, P;
108
- const d = (k = e.tags) == null ? void 0 : k.findIndex((j) => j.name === p);
109
- d === -1 && ((E = e.tags) == null || E.push({
102
+ var E, P, k;
103
+ const d = (E = e.tags) == null ? void 0 : E.findIndex((A) => A.name === p);
104
+ d === -1 && ((P = e.tags) == null || P.push({
110
105
  name: p,
111
106
  description: ""
112
107
  }));
113
- const b = d !== -1 ? d : e.tags.length - 1;
114
- typeof ((P = e.tags[b]) == null ? void 0 : P.operations) > "u" && (e.tags[b].operations = []), e.tags[b].operations.push(r);
108
+ const x = d !== -1 ? d : e.tags.length - 1;
109
+ typeof ((k = e.tags[x]) == null ? void 0 : k.operations) > "u" && (e.tags[x].operations = []), e.tags[x].operations.push(o);
115
110
  });
116
111
  });
117
- }), e.tags = (y = e.tags) == null ? void 0 : y.filter((s) => !u(s)), {
112
+ }), e.tags = (f = e.tags) == null ? void 0 : f.filter((s) => !u(s)), {
118
113
  ...e,
119
- webhooks: h
114
+ webhooks: n
120
115
  };
121
116
  };
122
117
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveSpec.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactiveSpec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,KAAK,CAAA;AAgDhE;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAA;IAChD,QAAQ,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyDA"}
1
+ {"version":3,"file":"useReactiveSpec.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactiveSpec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,KAAK,CAAA;AAgDhE;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAA;IAChD,QAAQ,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDA"}
@@ -1,15 +1,15 @@
1
1
  import { fetchDocument as l, prettyPrintJson as d } from "@scalar/oas-utils/helpers";
2
- import { ref as f, watch as p, toValue as u } from "vue";
2
+ import { ref as s, watch as u, toValue as f } from "vue";
3
3
  import { parse as h } from "../helpers/parse.js";
4
4
  import { createEmptySpecification as m } from "../helpers/createEmptySpecification.js";
5
- const v = async ({ url: r, content: e }, n) => {
6
- if (r) {
5
+ const v = async ({ url: a, content: e }, r) => {
6
+ if (a) {
7
7
  const i = performance.now();
8
8
  try {
9
- const c = await l(r, n), o = performance.now();
10
- return console.log(`fetch: ${Math.round(o - i)} ms (${r})`), console.log("size:", Math.round(c.length / 1024), "kB"), c;
11
- } catch (c) {
12
- console.error("Failed to fetch OpenAPI document from URL:", c);
9
+ const n = await l(a, r), o = performance.now();
10
+ return console.log(`fetch: ${Math.round(o - i)} ms (${a})`), console.log("size:", Math.round(n.length / 1024), "kB"), n;
11
+ } catch (n) {
12
+ console.error("Failed to fetch OpenAPI document from URL:", n);
13
13
  }
14
14
  }
15
15
  const t = typeof e == "function" ? e() : e;
@@ -18,44 +18,42 @@ const v = async ({ url: r, content: e }, n) => {
18
18
  if (typeof t == "object")
19
19
  return d(t);
20
20
  };
21
- function E({
22
- specConfig: r,
21
+ function C({
22
+ specConfig: a,
23
23
  proxyUrl: e
24
24
  }) {
25
- const n = f(""), t = f(m()), i = f(null);
26
- function c(o) {
27
- var s;
25
+ const r = s(""), t = s(m()), i = s(null);
26
+ function n(o) {
28
27
  if (!o) {
29
28
  t.value = m();
30
29
  return;
31
30
  }
32
31
  h(o, {
33
- proxyUrl: e ? u(e) : void 0,
34
- source: (s = u(r)) == null ? void 0 : s.url
35
- }).then((a) => {
36
- i.value = null, t.value = a;
37
- }).catch((a) => {
38
- i.value = a.toString();
32
+ proxyUrl: e ? f(e) : void 0
33
+ }).then((c) => {
34
+ i.value = null, t.value = c;
35
+ }).catch((c) => {
36
+ i.value = c.toString();
39
37
  });
40
38
  }
41
- return p(
42
- () => u(r),
39
+ return u(
40
+ () => f(a),
43
41
  async (o) => {
44
- var s;
42
+ var c;
45
43
  if (o) {
46
- const a = (s = await v(o, u(e))) == null ? void 0 : s.trim();
47
- typeof a == "string" && (n.value = a);
44
+ const p = (c = await v(o, f(e))) == null ? void 0 : c.trim();
45
+ typeof p == "string" && (r.value = p);
48
46
  }
49
47
  },
50
48
  { immediate: !0, deep: !0 }
51
- ), p(n, () => {
52
- c(n.value);
49
+ ), u(r, () => {
50
+ n(r.value);
53
51
  }), {
54
- rawSpec: n,
52
+ rawSpec: r,
55
53
  parsedSpec: t,
56
54
  specErrors: i
57
55
  };
58
56
  }
59
57
  export {
60
- E as useReactiveSpec
58
+ C as useReactiveSpec
61
59
  };