@scalar/api-reference 1.30.0 → 1.31.1

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.
Files changed (167) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/browser/standalone.js +6690 -6569
  3. package/dist/browser/webpack-stats.json +1 -1
  4. package/dist/components/ApiReferenceLayout.vue.d.ts.map +1 -1
  5. package/dist/components/ApiReferenceLayout.vue.js +1 -1
  6. package/dist/components/ApiReferenceLayout.vue2.js +164 -181
  7. package/dist/components/Content/ClientLibraries/ClientLibraries.vue.d.ts.map +1 -1
  8. package/dist/components/Content/ClientLibraries/ClientLibraries.vue.js +2 -2
  9. package/dist/components/Content/ClientLibraries/ClientLibraries.vue2.js +56 -51
  10. package/dist/components/Content/Content.vue.d.ts.map +1 -1
  11. package/dist/components/Content/Content.vue.js +1 -1
  12. package/dist/components/Content/Content.vue2.js +5 -5
  13. package/dist/components/Content/Introduction/Introduction.vue.d.ts +2 -2
  14. package/dist/components/Content/Introduction/Introduction.vue.d.ts.map +1 -1
  15. package/dist/components/Content/Introduction/Introduction.vue.js +2 -2
  16. package/dist/components/Content/Introduction/Introduction.vue2.js +57 -63
  17. package/dist/components/Content/Lazy/Loading.vue.d.ts.map +1 -1
  18. package/dist/components/Content/Lazy/Loading.vue.js +46 -46
  19. package/dist/components/Content/Models/Models.vue.d.ts +2 -2
  20. package/dist/components/Content/Models/Models.vue.d.ts.map +1 -1
  21. package/dist/components/Content/Models/Models.vue.js +2 -2
  22. package/dist/components/Content/Models/Models.vue2.js +9 -7
  23. package/dist/components/Content/Models/ModelsAccordion.vue.d.ts +2 -2
  24. package/dist/components/Content/Models/ModelsAccordion.vue.d.ts.map +1 -1
  25. package/dist/components/Content/Models/ModelsAccordion.vue.js +2 -2
  26. package/dist/components/Content/Schema/Schema.preview.d.ts +294 -84
  27. package/dist/components/Content/Schema/Schema.preview.d.ts.map +1 -1
  28. package/dist/components/Content/Schema/Schema.vue.d.ts +21 -4
  29. package/dist/components/Content/Schema/Schema.vue.d.ts.map +1 -1
  30. package/dist/components/Content/Schema/Schema.vue.js +2 -2
  31. package/dist/components/Content/Schema/Schema.vue2.js +158 -131
  32. package/dist/components/Content/Schema/SchemaComposition.vue.d.ts +2 -2
  33. package/dist/components/Content/Schema/SchemaComposition.vue.d.ts.map +1 -1
  34. package/dist/components/Content/Schema/SchemaComposition.vue.js +57 -53
  35. package/dist/components/Content/Schema/SchemaDiscriminator.vue.d.ts +2 -3
  36. package/dist/components/Content/Schema/SchemaDiscriminator.vue.d.ts.map +1 -1
  37. package/dist/components/Content/Schema/SchemaDiscriminator.vue.js +29 -29
  38. package/dist/components/Content/Schema/SchemaHeading.vue.d.ts +2 -2
  39. package/dist/components/Content/Schema/SchemaHeading.vue.d.ts.map +1 -1
  40. package/dist/components/Content/Schema/SchemaHeading.vue.js +1 -1
  41. package/dist/components/Content/Schema/SchemaProperty.vue.d.ts +12 -3
  42. package/dist/components/Content/Schema/SchemaProperty.vue.d.ts.map +1 -1
  43. package/dist/components/Content/Schema/SchemaProperty.vue.js +1 -1
  44. package/dist/components/Content/Schema/SchemaProperty.vue2.js +133 -103
  45. package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts +3 -2
  46. package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
  47. package/dist/components/Content/Schema/SchemaPropertyHeading.vue.js +2 -2
  48. package/dist/components/Content/Schema/SchemaPropertyHeading.vue2.js +133 -126
  49. package/dist/components/Content/Schema/helpers/merge-all-of-schemas.d.ts +2 -2
  50. package/dist/components/Content/Schema/helpers/merge-all-of-schemas.d.ts.map +1 -1
  51. package/dist/components/Content/Tag/TagList.vue.d.ts +2 -2
  52. package/dist/components/Content/Tag/TagList.vue.d.ts.map +1 -1
  53. package/dist/components/DocumentSelector/DocumentSelector.vue.js +3 -3
  54. package/dist/components/Layouts/ClassicLayout.vue.d.ts.map +1 -1
  55. package/dist/components/Layouts/ClassicLayout.vue.js +19 -17
  56. package/dist/components/Layouts/Layouts.vue.js +11 -9
  57. package/dist/components/Layouts/ModernLayout.vue2.js +22 -20
  58. package/dist/components/Section/SectionAccordion.vue.d.ts.map +1 -1
  59. package/dist/components/Section/SectionAccordion.vue.js +2 -2
  60. package/dist/components/Section/SectionAccordion.vue2.js +1 -1
  61. package/dist/components/Section/SectionContainerAccordion.vue.d.ts.map +1 -1
  62. package/dist/components/Section/SectionContainerAccordion.vue.js +2 -2
  63. package/dist/components/Section/SectionContainerAccordion.vue2.js +4 -4
  64. package/dist/components/Section/SectionHeader.vue.d.ts.map +1 -1
  65. package/dist/components/Section/SectionHeader.vue.js +2 -2
  66. package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
  67. package/dist/components/Sidebar/Sidebar.vue.js +2 -2
  68. package/dist/components/Sidebar/Sidebar.vue2.js +56 -56
  69. package/dist/components/SingleApiReference.vue.d.ts.map +1 -1
  70. package/dist/components/SingleApiReference.vue.js +27 -33
  71. package/dist/esm.d.ts.map +1 -1
  72. package/dist/features/ApiClientModal/ApiClientModal.vue.d.ts +2 -2
  73. package/dist/features/ApiClientModal/ApiClientModal.vue.d.ts.map +1 -1
  74. package/dist/features/ApiClientModal/ApiClientModal.vue.js +49 -50
  75. package/dist/features/ApiClientModal/useApiClient.d.ts +196 -196
  76. package/dist/features/ApiClientModal/useApiClient.d.ts.map +1 -1
  77. package/dist/features/DocumentSource/hooks/useDocumentFetcher.d.ts +11 -0
  78. package/dist/features/DocumentSource/hooks/useDocumentFetcher.d.ts.map +1 -0
  79. package/dist/features/DocumentSource/hooks/useDocumentFetcher.js +38 -0
  80. package/dist/features/DocumentSource/hooks/useDocumentSource.d.ts +21 -0
  81. package/dist/features/DocumentSource/hooks/useDocumentSource.d.ts.map +1 -0
  82. package/dist/features/DocumentSource/hooks/useDocumentSource.js +94 -0
  83. package/dist/features/DocumentSource/index.d.ts +2 -0
  84. package/dist/features/DocumentSource/index.d.ts.map +1 -0
  85. package/dist/features/DownloadLink/DownloadLink.vue.d.ts +1 -1
  86. package/dist/features/DownloadLink/DownloadLink.vue.d.ts.map +1 -1
  87. package/dist/features/DownloadLink/DownloadLink.vue.js +1 -1
  88. package/dist/features/DownloadLink/DownloadLink.vue2.js +18 -17
  89. package/dist/features/DownloadLink/index.d.ts +1 -0
  90. package/dist/features/DownloadLink/index.d.ts.map +1 -1
  91. package/dist/features/DownloadLink/openapi-version-symbol.d.ts +2 -0
  92. package/dist/features/DownloadLink/openapi-version-symbol.d.ts.map +1 -0
  93. package/dist/features/DownloadLink/openapi-version-symbol.js +4 -0
  94. package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts +2 -0
  95. package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts.map +1 -1
  96. package/dist/features/ExampleRequest/ExampleRequest.vue.js +2 -2
  97. package/dist/features/ExampleRequest/ExampleRequest.vue2.js +178 -127
  98. package/dist/features/Operation/Operation.vue.d.ts +2 -2
  99. package/dist/features/Operation/Operation.vue.d.ts.map +1 -1
  100. package/dist/features/Operation/Operation.vue.js +29 -23
  101. package/dist/features/Operation/components/OperationParameters.vue.d.ts +7 -3
  102. package/dist/features/Operation/components/OperationParameters.vue.d.ts.map +1 -1
  103. package/dist/features/Operation/components/OperationParameters.vue.js +28 -24
  104. package/dist/features/Operation/components/OperationResponses.vue.d.ts +2 -2
  105. package/dist/features/Operation/components/OperationResponses.vue.d.ts.map +1 -1
  106. package/dist/features/Operation/components/ParameterHeaders.vue.d.ts +2 -2
  107. package/dist/features/Operation/components/ParameterHeaders.vue.d.ts.map +1 -1
  108. package/dist/features/Operation/components/ParameterHeaders.vue.js +2 -2
  109. package/dist/features/Operation/components/ParameterList.vue.d.ts +2 -2
  110. package/dist/features/Operation/components/ParameterList.vue.d.ts.map +1 -1
  111. package/dist/features/Operation/components/ParameterList.vue.js +2 -2
  112. package/dist/features/Operation/components/ParameterListItem.vue.d.ts +2 -2
  113. package/dist/features/Operation/components/ParameterListItem.vue.d.ts.map +1 -1
  114. package/dist/features/Operation/components/ParameterListItem.vue.js +3 -3
  115. package/dist/features/Operation/components/ParameterListItem.vue2.js +6 -6
  116. package/dist/features/Operation/components/RequestBody.vue.d.ts +7 -3
  117. package/dist/features/Operation/components/RequestBody.vue.d.ts.map +1 -1
  118. package/dist/features/Operation/components/RequestBody.vue.js +2 -2
  119. package/dist/features/Operation/components/RequestBody.vue2.js +41 -36
  120. package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts +7 -3
  121. package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts.map +1 -1
  122. package/dist/features/Operation/layouts/ClassicLayout.vue.js +2 -2
  123. package/dist/features/Operation/layouts/ClassicLayout.vue2.js +84 -79
  124. package/dist/features/Operation/layouts/ModernLayout.vue.d.ts +5 -1
  125. package/dist/features/Operation/layouts/ModernLayout.vue.d.ts.map +1 -1
  126. package/dist/features/Operation/layouts/ModernLayout.vue.js +2 -2
  127. package/dist/features/Operation/layouts/ModernLayout.vue2.js +66 -57
  128. package/dist/features/Operation/types/schemas.d.ts +2 -2
  129. package/dist/features/Operation/types/schemas.d.ts.map +1 -1
  130. package/dist/features/Search/SearchButton.vue.js +2 -2
  131. package/dist/helpers/local-storage.d.ts +8 -0
  132. package/dist/helpers/local-storage.d.ts.map +1 -0
  133. package/dist/helpers/local-storage.js +6 -0
  134. package/dist/helpers/measure.d.ts +21 -0
  135. package/dist/helpers/measure.d.ts.map +1 -0
  136. package/dist/helpers/measure.js +7 -0
  137. package/dist/helpers/parse.d.ts +3 -5
  138. package/dist/helpers/parse.d.ts.map +1 -1
  139. package/dist/helpers/parse.js +64 -86
  140. package/dist/helpers/scroll-to-id.d.ts.map +1 -1
  141. package/dist/helpers/scroll-to-id.js +18 -4
  142. package/dist/hooks/useDiscriminator.d.ts +53 -0
  143. package/dist/hooks/useDiscriminator.d.ts.map +1 -0
  144. package/dist/hooks/useDiscriminator.js +149 -0
  145. package/dist/hooks/useOperationDiscriminator.d.ts +8 -0
  146. package/dist/hooks/useOperationDiscriminator.d.ts.map +1 -0
  147. package/dist/hooks/useOperationDiscriminator.js +57 -0
  148. package/dist/index.d.ts +0 -1
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +33 -35
  151. package/dist/libs/openapi.d.ts +3 -3
  152. package/dist/libs/openapi.d.ts.map +1 -1
  153. package/dist/libs/openapi.js +35 -42
  154. package/dist/standalone/lib/html-api.d.ts.map +1 -1
  155. package/dist/standalone/lib/html-api.js +15 -15
  156. package/dist/stores/useHttpClientStore.d.ts.map +1 -1
  157. package/dist/stores/useHttpClientStore.js +19 -18
  158. package/dist/style.css +1 -1
  159. package/dist/types.d.ts +27 -3
  160. package/dist/types.d.ts.map +1 -1
  161. package/package.json +15 -16
  162. package/dist/components/Content/Schema/helpers/schema-discriminator.d.ts +0 -12
  163. package/dist/components/Content/Schema/helpers/schema-discriminator.d.ts.map +0 -1
  164. package/dist/components/Content/Schema/helpers/schema-discriminator.js +0 -45
  165. package/dist/hooks/useReactiveSpec.d.ts +0 -448
  166. package/dist/hooks/useReactiveSpec.d.ts.map +0 -1
  167. package/dist/hooks/useReactiveSpec.js +0 -59
@@ -1,119 +1,97 @@
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
- import { createEmptySpecification as O } from "../libs/openapi.js";
5
- import { normalizeRequestMethod as j } from "../legacy/helpers/normalizeRequestMethod.js";
6
- import { validRequestMethods as C } from "../legacy/fixtures/httpRequestMethods.js";
7
- const G = (m, {
8
- proxyUrl: e
9
- } = {}) => new Promise(async (n, b) => {
10
- var h;
1
+ import { shouldIgnoreEntity as u } from "@scalar/oas-utils/helpers";
2
+ import { createEmptySpecification as w } from "../libs/openapi.js";
3
+ import { normalizeRequestMethod as R } from "../legacy/helpers/normalizeRequestMethod.js";
4
+ import { validRequestMethods as q } from "../legacy/fixtures/httpRequestMethods.js";
5
+ const C = (c) => new Promise(async (t, p) => {
11
6
  try {
12
- if (!m)
13
- return n(I(O()));
14
- const f = performance.now(), { filesystem: s } = await M(m, {
15
- plugins: [
16
- D({
17
- fetch: (o) => fetch(e ? R(e, o) : o)
18
- })
19
- ]
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(
22
- `Please open an issue on https://github.com/scalar/scalar
23
- `,
24
- `Scalar OpenAPI Parser Warning:
25
- `,
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);
7
+ return t(b(c || w()));
8
+ } catch (l) {
9
+ console.error("[@scalar/api-reference]", "Failed to parse the OpenAPI document. It might be invalid?"), console.error(l), p(l);
30
10
  }
31
- return n(I(O()));
32
- }), I = (m) => {
33
- var h, f;
34
- let e = {};
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 = {});
36
- const n = {};
37
- return Object.keys(e.webhooks ?? {}).forEach((s) => {
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];
42
- if (!(!t || u(t))) {
43
- if (Array.isArray(t.tags)) {
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);
11
+ return t(b(w()));
12
+ }), b = (c) => {
13
+ var E, O;
14
+ let t = {};
15
+ c && typeof c == "object" ? t = c : t = w(), t.tags || (t.tags = []), t.paths || (t.paths = {}), t.components || (t.components = {}), t.webhooks || (t.webhooks = {}), t.servers || (t.servers = []), t.security || (t.security = []);
16
+ const p = {};
17
+ return Object.keys(t.webhooks ?? {}).forEach((s) => {
18
+ var d;
19
+ Object.keys(((d = t.webhooks) == null ? void 0 : d[s]) ?? {}).forEach((r) => {
20
+ var n, m, h, g;
21
+ const e = (n = t.webhooks) == null ? void 0 : n[s][r];
22
+ if (!(!e || u(e))) {
23
+ if (Array.isArray(e.tags)) {
24
+ const o = (m = e.tags) == null ? void 0 : m.map(
25
+ (a) => {
26
+ var y;
27
+ return (y = t.tags) == null ? void 0 : y.find((i) => i.name === a);
48
28
  }
49
29
  );
50
- if (t.tags = i == null ? void 0 : i.filter((c) => !u(c)), i != null && i.some((c) => u(c)))
30
+ if (e.tags = o == null ? void 0 : o.filter((a) => !u(a)), o != null && o.some((a) => u(a)))
51
31
  return;
52
32
  }
53
- n[s] === void 0 && (n[s] = {}), n[s][r] = {
33
+ p[s] === void 0 && (p[s] = {}), p[s][r] = {
54
34
  // Transformed data
55
- httpVerb: j(r),
35
+ httpVerb: R(r),
56
36
  path: s,
57
- operationId: (t == null ? void 0 : t.operationId) || s,
58
- name: (t == null ? void 0 : t.summary) || s || "",
59
- description: (t == null ? void 0 : t.description) || "",
60
- pathParameters: (y = (g = e.paths) == null ? void 0 : g[s]) == null ? void 0 : y.parameters,
37
+ operationId: (e == null ? void 0 : e.operationId) || s,
38
+ name: (e == null ? void 0 : e.summary) || s || "",
39
+ description: (e == null ? void 0 : e.description) || "",
40
+ pathParameters: (g = (h = t.paths) == null ? void 0 : h[s]) == null ? void 0 : g.parameters,
61
41
  // Original webhook
62
42
  information: {
63
- ...t
43
+ ...e
64
44
  }
65
45
  };
66
46
  }
67
47
  });
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]);
71
- }), Object.keys(e.paths).forEach((s) => {
72
- Object.keys(e.paths[s]).filter(
73
- (r) => C.includes(r.toUpperCase())
48
+ }), Object.keys(((E = t.components) == null ? void 0 : E.schemas) ?? {}).forEach((s) => {
49
+ var d, r, e, n;
50
+ u((r = (d = t.components) == null ? void 0 : d.schemas) == null ? void 0 : r[s]) && ((n = (e = t.components) == null ? void 0 : e.schemas) == null || delete n[s]);
51
+ }), Object.keys(t.paths).forEach((s) => {
52
+ Object.keys(t.paths[s]).filter(
53
+ (r) => q.includes(r.toUpperCase())
74
54
  ).forEach((r) => {
75
- var l, g, y, i, c, w;
76
- const t = e.paths[s][r];
77
- if (t === void 0 || u(t))
55
+ var m, h, g, o, a, y;
56
+ const e = t.paths[s][r];
57
+ if (e === void 0 || u(e))
78
58
  return;
79
- const o = {
80
- httpVerb: j(r),
59
+ const n = {
60
+ httpVerb: R(r),
81
61
  path: s,
82
- operationId: t.operationId || s,
83
- name: t.summary || s || "",
84
- description: t.description || "",
62
+ operationId: e.operationId || s,
63
+ name: e.summary || s || "",
64
+ description: e.description || "",
85
65
  information: {
86
- ...t
66
+ ...e
87
67
  },
88
- pathParameters: (g = (l = e.paths) == null ? void 0 : l[s]) == null ? void 0 : g.parameters
68
+ pathParameters: (h = (m = t.paths) == null ? void 0 : m[s]) == null ? void 0 : h.parameters
89
69
  };
90
- if (!t.tags || t.tags.length === 0) {
91
- (y = e.tags) != null && y.find((d) => d.name === "default") || (i = e.tags) == null || i.push({
70
+ if (!e.tags || e.tags.length === 0) {
71
+ (g = t.tags) != null && g.find((f) => f.name === "default") || (o = t.tags) == null || o.push({
92
72
  name: "default",
93
73
  description: "",
94
74
  operations: []
95
75
  });
96
- const p = (c = e.tags) == null ? void 0 : c.findIndex(
97
- (d) => d.name === "default"
98
- );
99
- p >= 0 && ((w = e.tags[p]) == null || w.operations.push(o));
76
+ const i = (a = t.tags) == null ? void 0 : a.findIndex((f) => f.name === "default");
77
+ i >= 0 && ((y = t.tags[i]) == null || y.operations.push(n));
100
78
  } else
101
- t.tags.forEach((p) => {
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({
105
- name: p,
79
+ e.tags.forEach((i) => {
80
+ var k, x, j;
81
+ const f = (k = t.tags) == null ? void 0 : k.findIndex((P) => P.name === i);
82
+ f === -1 && ((x = t.tags) == null || x.push({
83
+ name: i,
106
84
  description: ""
107
85
  }));
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);
86
+ const I = f !== -1 ? f : t.tags.length - 1;
87
+ typeof ((j = t.tags[I]) == null ? void 0 : j.operations) > "u" && (t.tags[I].operations = []), t.tags[I].operations.push(n);
110
88
  });
111
89
  });
112
- }), e.tags = (f = e.tags) == null ? void 0 : f.filter((s) => !u(s)), {
113
- ...e,
114
- webhooks: n
90
+ }), t.tags = (O = t.tags) == null ? void 0 : O.filter((s) => !u(s)), {
91
+ ...t,
92
+ webhooks: p
115
93
  };
116
94
  };
117
95
  export {
118
- G as parse
96
+ C as parse
119
97
  };
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-id.d.ts","sourceRoot":"","sources":["../../src/helpers/scroll-to-id.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,OAAc,MAAM,UAAU,OAAO,kBAS3D,CAAA"}
1
+ {"version":3,"file":"scroll-to-id.d.ts","sourceRoot":"","sources":["../../src/helpers/scroll-to-id.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,OAAc,MAAM,UAAU,OAAO,kBAkC3D,CAAA"}
@@ -1,7 +1,21 @@
1
- const c = async (e, t) => {
2
- const o = document.getElementById(e);
3
- o && (o.scrollIntoView(), t && o.focus());
1
+ const l = async (t, r) => {
2
+ const n = (e) => {
3
+ e.scrollIntoView(), r && e.focus();
4
+ }, o = document.getElementById(t);
5
+ if (o) {
6
+ n(o);
7
+ return;
8
+ }
9
+ const s = Date.now() + 1e3, c = () => {
10
+ const e = document.getElementById(t);
11
+ if (e) {
12
+ n(e);
13
+ return;
14
+ }
15
+ Date.now() < s && requestAnimationFrame(c);
16
+ };
17
+ requestAnimationFrame(c);
4
18
  };
5
19
  export {
6
- c as scrollToId
20
+ l as scrollToId
7
21
  };
@@ -0,0 +1,53 @@
1
+ import type { Schemas } from '../features/Operation/types/schemas';
2
+ import type { OpenAPIV3_1 } from '@scalar/openapi-types';
3
+ import { type InjectionKey, type ComputedRef } from 'vue';
4
+ /** Discriminator context type */
5
+ export type DiscriminatorContext = {
6
+ selectedType: string | undefined;
7
+ discriminatorMapping: Record<string, string>;
8
+ discriminatorPropertyName: string;
9
+ hasDiscriminator: boolean;
10
+ mergedSchema: OpenAPIV3_1.SchemaObject | undefined;
11
+ };
12
+ /** Example context type */
13
+ export type ExampleContext = {
14
+ generateExampleValue: (isArray?: boolean) => any;
15
+ };
16
+ /** Injection keys */
17
+ export declare const DISCRIMINATOR_CONTEXT: InjectionKey<ComputedRef<DiscriminatorContext | null>>;
18
+ export declare const EXAMPLE_CONTEXT: InjectionKey<ExampleContext>;
19
+ /** Discriminator mapping */
20
+ export type DiscriminatorMapping = NonNullable<OpenAPIV3_1.DiscriminatorObject['mapping']>;
21
+ /** Discriminator property name */
22
+ export type DiscriminatorPropertyName = OpenAPIV3_1.DiscriminatorObject['propertyName'];
23
+ /** Use discriminator options */
24
+ export type UseDiscriminatorOptions = {
25
+ schema: OpenAPIV3_1.SchemaObject | undefined;
26
+ schemas?: Schemas;
27
+ onSchemaChange?: (newSchema: OpenAPIV3_1.SchemaObject) => void;
28
+ };
29
+ /** Get discriminator mapping from schema */
30
+ export declare function getDiscriminatorMapping(schema: OpenAPIV3_1.SchemaObject | undefined): DiscriminatorMapping | undefined;
31
+ /** Get discriminator property name from schema */
32
+ export declare function getDiscriminatorPropertyName(schema: OpenAPIV3_1.SchemaObject | undefined): DiscriminatorPropertyName | undefined;
33
+ /** Check if schema has a discriminator */
34
+ export declare function hasDiscriminator(schema: OpenAPIV3_1.SchemaObject | undefined): boolean;
35
+ /** Get base discriminator schema name by matching discriminator property */
36
+ export declare function getBaseDiscriminatorSchemaName(discriminatorPropertyName: string, schemas?: Schemas): string | null;
37
+ /** Get base discriminator schema name for array items that might reference a discriminator schema */
38
+ export declare function getDiscriminatorSchemaName(itemsSchema: OpenAPIV3_1.SchemaObject | undefined, schemas?: Schemas): string | null;
39
+ /** Merge discriminator schemas */
40
+ export declare function mergeDiscriminatorSchemas(baseSchema: OpenAPIV3_1.SchemaObject, selectedType: string, schemas: Record<string, OpenAPIV3_1.SchemaObject>): OpenAPIV3_1.SchemaObject | undefined;
41
+ /** Use discriminator hook */
42
+ export declare function useDiscriminator({ schema, schemas, onSchemaChange }: UseDiscriminatorOptions): {
43
+ selectedType: import("vue").Ref<string, string>;
44
+ discriminatorMapping: ComputedRef<{
45
+ [value: string]: string;
46
+ } | undefined>;
47
+ defaultType: ComputedRef<string>;
48
+ discriminatorPropertyName: ComputedRef<string | undefined>;
49
+ hasDiscriminator: ComputedRef<boolean>;
50
+ mergedSchema: ComputedRef<OpenAPIV3_1.SchemaObject | undefined>;
51
+ generateExampleValue: (isArray?: boolean) => any;
52
+ };
53
+ //# sourceMappingURL=useDiscriminator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDiscriminator.d.ts","sourceRoot":"","sources":["../../src/hooks/useDiscriminator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAA;AAE/E,iCAAiC;AACjC,MAAM,MAAM,oBAAoB,G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,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,GAAG,OAAO,CAEtF;AAED,4EAA4E;AAC5E,wBAAgB,8BAA8B,CAAC,yBAAyB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiBlH;AAED,qGAAqG;AACrG,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,EACjD,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,GAAG,IAAI,CAsBf;AAgBD,kCAAkC;AAClC,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,WAAW,CAAC,YAAY,EACpC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,GAChD,WAAW,CAAC,YAAY,GAAG,SAAS,CA6EtC;AAED,6BAA6B;AAC7B,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,uBAAuB;;;;;;;;;;EAuI5F"}
@@ -0,0 +1,149 @@
1
+ import { computed as c, ref as q, watch as O } from "vue";
2
+ const V = Symbol("discriminator-context"), w = Symbol("example-context");
3
+ function j(r) {
4
+ var e;
5
+ if ((e = r == null ? void 0 : r.discriminator) != null && e.mapping)
6
+ return r.discriminator.mapping;
7
+ }
8
+ function E(r) {
9
+ var e;
10
+ return (e = r == null ? void 0 : r.discriminator) == null ? void 0 : e.propertyName;
11
+ }
12
+ function D(r) {
13
+ return (r == null ? void 0 : r.discriminator) !== void 0;
14
+ }
15
+ function I(r, e) {
16
+ var o;
17
+ if (!r || !e || r.type !== "object" || !r.properties)
18
+ return null;
19
+ for (const [p, i] of Object.entries(e))
20
+ if (typeof i == "object" && i !== null && "discriminator" in i && ((o = i.discriminator) != null && o.propertyName)) {
21
+ const n = i.discriminator.propertyName;
22
+ if (r.properties[n])
23
+ return p;
24
+ }
25
+ return null;
26
+ }
27
+ function x(r) {
28
+ if (r)
29
+ return r.type === "array" && r.items && typeof r.items == "object" && !("$ref" in r.items) ? r.items : r;
30
+ }
31
+ function T(r, e, o) {
32
+ var l;
33
+ if (!((l = r.discriminator) != null && l.mapping) || !e)
34
+ return;
35
+ const p = r.discriminator.mapping[e];
36
+ if (!p)
37
+ return;
38
+ const i = p.split("/").pop();
39
+ if (!i || !o[i])
40
+ return;
41
+ const n = o[i];
42
+ if (n.allOf) {
43
+ const d = {
44
+ type: n.type || "object",
45
+ properties: {},
46
+ required: [],
47
+ ...r.title ? { title: r.title } : {},
48
+ ...r.name ? { name: r.name } : {}
49
+ }, y = {}, a = /* @__PURE__ */ new Set();
50
+ r.required && r.required.forEach((u) => a.add(u));
51
+ for (const u of n.allOf)
52
+ if ("$ref" in u) {
53
+ const s = u.$ref.split("/").pop();
54
+ if (s && o[s]) {
55
+ const t = o[s];
56
+ t.properties && Object.assign(y, t.properties), t.required && t.required.forEach((f) => a.add(f));
57
+ }
58
+ } else "properties" in u && (Object.assign(y, u.properties), "required" in u && Array.isArray(u.required) && u.required.forEach((s) => a.add(s)));
59
+ return d.properties = y, d.required = Array.from(a), d;
60
+ }
61
+ return {
62
+ type: n.type || r.type,
63
+ properties: {
64
+ ...r.properties || {},
65
+ ...n.properties || {}
66
+ },
67
+ required: [...r.required || [], ...n.required || []],
68
+ // Preserve discriminator
69
+ discriminator: r.discriminator,
70
+ // Preserve title and name from base schema
71
+ ...r.title ? { title: r.title } : {},
72
+ ...r.name ? { name: r.name } : {}
73
+ };
74
+ }
75
+ function X({ schema: r, schemas: e, onSchemaChange: o }) {
76
+ const p = c(() => x(r)), i = c(() => j(p.value)), n = c(() => i.value && Object.keys(i.value)[0] || ""), l = q(n.value);
77
+ O(
78
+ n,
79
+ (t) => {
80
+ t && !l.value && (l.value = t);
81
+ },
82
+ { immediate: !0 }
83
+ );
84
+ const d = c(() => E(p.value)), y = c(() => D(p.value)), a = c(() => {
85
+ if (!p.value || !e || !l.value)
86
+ return r;
87
+ const t = T(
88
+ p.value,
89
+ l.value,
90
+ e
91
+ );
92
+ if (!t)
93
+ return r;
94
+ const f = (r == null ? void 0 : r.type) === "array" ? {
95
+ type: "array",
96
+ items: t,
97
+ ...r.title ? { title: r.title } : {},
98
+ ...r.name ? { name: r.name } : {}
99
+ } : t;
100
+ return o == null || o(f), f;
101
+ }), u = (t) => {
102
+ if ("default" in t)
103
+ return t.default;
104
+ if ("example" in t)
105
+ return t.example;
106
+ switch (t.type) {
107
+ case "string":
108
+ return "";
109
+ case "integer":
110
+ case "number":
111
+ return t.nullable ? null : 0;
112
+ case "boolean":
113
+ return !1;
114
+ case "array":
115
+ return [];
116
+ case "object":
117
+ return {};
118
+ default:
119
+ return null;
120
+ }
121
+ };
122
+ return {
123
+ selectedType: l,
124
+ discriminatorMapping: i,
125
+ defaultType: n,
126
+ discriminatorPropertyName: d,
127
+ hasDiscriminator: y,
128
+ mergedSchema: a,
129
+ generateExampleValue: (t = !1) => {
130
+ if (!a.value)
131
+ return t ? [] : {};
132
+ const f = {}, v = a.value.type === "array" ? a.value.items : a.value;
133
+ return "properties" in v && v.properties && Object.entries(v.properties).forEach(([g, N]) => {
134
+ const m = N;
135
+ m !== null && (f[g] = u(m));
136
+ }), d.value && l.value && (f[d.value] = l.value), JSON.parse(JSON.stringify(t ? [f] : f));
137
+ }
138
+ };
139
+ }
140
+ export {
141
+ V as DISCRIMINATOR_CONTEXT,
142
+ w as EXAMPLE_CONTEXT,
143
+ j as getDiscriminatorMapping,
144
+ E as getDiscriminatorPropertyName,
145
+ I as getDiscriminatorSchemaName,
146
+ D as hasDiscriminator,
147
+ T as mergeDiscriminatorSchemas,
148
+ X as useDiscriminator
149
+ };
@@ -0,0 +1,8 @@
1
+ import type { TransformedOperation } from '@scalar/types/legacy';
2
+ import type { Schemas } from '../features/Operation/types/schemas';
3
+ /** Handling discriminator logic in operations */
4
+ export declare function useOperationDiscriminator(transformedOperation: TransformedOperation, schemas?: Schemas): {
5
+ hasSchemaDiscriminator: import("vue").ComputedRef<boolean>;
6
+ handleDiscriminatorChange: (type: string) => void;
7
+ };
8
+ //# sourceMappingURL=useOperationDiscriminator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOperationDiscriminator.d.ts","sourceRoot":"","sources":["../../src/hooks/useOperationDiscriminator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAsBjE,iDAAiD;AACjD,wBAAgB,yBAAyB,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,OAAO;;sCA6D5D,MAAM;EAahD"}
@@ -0,0 +1,57 @@
1
+ import { computed as i, ref as E, provide as t } from "vue";
2
+ import { useDiscriminator as N, DISCRIMINATOR_CONTEXT as f, EXAMPLE_CONTEXT as h } from "./useDiscriminator.js";
3
+ function x(e) {
4
+ return e ? !!(e.discriminator || e.type === "array" && e.items && typeof e.items == "object" && "discriminator" in e.items) : !1;
5
+ }
6
+ function B(e, y) {
7
+ var s, c, m, u;
8
+ const n = (u = (m = (c = (s = e.information) == null ? void 0 : s.requestBody) == null ? void 0 : c.content) == null ? void 0 : m["application/json"]) == null ? void 0 : u.schema, a = i(() => x(n)), g = a.value ? N({
9
+ schema: n,
10
+ schemas: y,
11
+ onSchemaChange: (r) => {
12
+ var l, p, d;
13
+ (d = (p = (l = e.information) == null ? void 0 : l.requestBody) == null ? void 0 : p.content) != null && d["application/json"] && (e.information.requestBody.content["application/json"].schema = r);
14
+ }
15
+ }) : {
16
+ selectedType: E(""),
17
+ discriminatorMapping: i(() => ({})),
18
+ discriminatorPropertyName: i(() => ""),
19
+ hasDiscriminator: i(() => !1),
20
+ mergedSchema: i(() => n),
21
+ generateExampleValue: () => ({})
22
+ }, {
23
+ selectedType: o,
24
+ discriminatorMapping: v,
25
+ discriminatorPropertyName: D,
26
+ hasDiscriminator: S,
27
+ mergedSchema: T,
28
+ generateExampleValue: C
29
+ } = g;
30
+ if (a.value) {
31
+ const r = i(() => ({
32
+ selectedType: o.value || void 0,
33
+ discriminatorMapping: v.value || {},
34
+ discriminatorPropertyName: D.value || "",
35
+ hasDiscriminator: S.value,
36
+ mergedSchema: T.value
37
+ }));
38
+ t(f, r), t(h, {
39
+ generateExampleValue: C
40
+ });
41
+ } else
42
+ t(
43
+ f,
44
+ i(() => null)
45
+ ), t(h, {
46
+ generateExampleValue: () => ({})
47
+ });
48
+ return {
49
+ hasSchemaDiscriminator: a,
50
+ handleDiscriminatorChange: (r) => {
51
+ a.value && (o.value = r);
52
+ }
53
+ };
54
+ }
55
+ export {
56
+ B as useOperationDiscriminator
57
+ };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ export { default as ApiReferenceLayout } from './components/ApiReferenceLayout.v
4
4
  export { default as ModernLayout } from './components/Layouts/ModernLayout.vue.js';
5
5
  export { SearchButton, SearchModal } from './features/Search';
6
6
  export { default as GettingStarted } from './components/GettingStarted.vue.js';
7
- export { useReactiveSpec } from './hooks/useReactiveSpec.js';
8
7
  export { createApiReference } from './standalone/lib/html-api.js';
9
8
  export { Sidebar } from './components/Sidebar';
10
9
  export { Card, CardHeader, CardContent, CardFooter, CardTabHeader, CardTab } from './components/Card';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAC/E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE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