@scalar/api-reference 1.25.76 → 1.25.78

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 (153) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/browser/standalone.js +24389 -23740
  3. package/dist/browser/webpack-stats.json +1 -1
  4. package/dist/components/ApiReference.vue.d.ts.map +1 -1
  5. package/dist/components/ApiReference.vue.js +41 -56
  6. package/dist/components/ApiReferenceLayout.vue.d.ts +2 -2
  7. package/dist/components/ApiReferenceLayout.vue.d.ts.map +1 -1
  8. package/dist/components/ApiReferenceLayout.vue.js +3 -3
  9. package/dist/components/ApiReferenceLayout.vue2.js +140 -123
  10. package/dist/components/Content/Content.vue.d.ts +0 -1
  11. package/dist/components/Content/Content.vue.d.ts.map +1 -1
  12. package/dist/components/Content/Content.vue.js +1 -1
  13. package/dist/components/Content/Content.vue2.js +67 -62
  14. package/dist/components/Content/Lazy/Loading.vue.d.ts.map +1 -1
  15. package/dist/components/Content/Lazy/Loading.vue.js +74 -69
  16. package/dist/components/Content/Tag/TagList.vue.d.ts.map +1 -1
  17. package/dist/components/Content/Tag/TagList.vue.js +37 -33
  18. package/dist/embeds/ExampleRequest/ExampleRequest.vue.d.ts +1 -1
  19. package/dist/embeds/ExampleRequest/ExampleRequest.vue.d.ts.map +1 -1
  20. package/dist/embeds/OpenApiDocument/OpenApiDocument.vue.d.ts +60 -60
  21. package/dist/embeds/OpenApiDocument/OpenApiDocument.vue.d.ts.map +1 -1
  22. package/dist/embeds/OpenApiDocument/types.d.ts +1 -1
  23. package/dist/embeds/OpenApiDocument/types.d.ts.map +1 -1
  24. package/dist/features/ApiClientModal/ApiClientModal.vue.d.ts.map +1 -1
  25. package/dist/features/ApiClientModal/ApiClientModal.vue.js +20 -18
  26. package/dist/features/ApiClientModal/useApiClient.d.ts +149 -138
  27. package/dist/features/ApiClientModal/useApiClient.d.ts.map +1 -1
  28. package/dist/features/ApiClientModal/useApiClient.js +6 -6
  29. package/dist/features/BaseUrl/ServerUrlSelect.vue.d.ts.map +1 -1
  30. package/dist/features/BaseUrl/ServerUrlSelect.vue.js +2 -2
  31. package/dist/features/BaseUrl/ServerVariablesSelect.vue.d.ts.map +1 -1
  32. package/dist/features/BaseUrl/ServerVariablesSelect.vue.js +3 -3
  33. package/dist/features/BaseUrl/ServerVariablesSelect.vue2.js +3 -3
  34. package/dist/features/BaseUrl/ServerVariablesTextbox.vue.d.ts.map +1 -1
  35. package/dist/features/BaseUrl/ServerVariablesTextbox.vue.js +2 -2
  36. package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts +3 -0
  37. package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts.map +1 -1
  38. package/dist/features/ExampleRequest/ExampleRequest.vue.js +1 -1
  39. package/dist/features/ExampleRequest/ExampleRequest.vue2.js +121 -147
  40. package/dist/features/Operation/Operation.vue.d.ts +6 -4
  41. package/dist/features/Operation/Operation.vue.d.ts.map +1 -1
  42. package/dist/features/Operation/Operation.vue.js +30 -13
  43. package/dist/features/Operation/hooks/useRequestExample.d.ts +17 -0
  44. package/dist/features/Operation/hooks/useRequestExample.d.ts.map +1 -0
  45. package/dist/features/Operation/hooks/useRequestExample.js +68 -0
  46. package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts +2 -0
  47. package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts.map +1 -1
  48. package/dist/features/Operation/layouts/ClassicLayout.vue.js +1 -1
  49. package/dist/features/Operation/layouts/ClassicLayout.vue2.js +47 -41
  50. package/dist/features/Operation/layouts/ModernLayout.vue.d.ts +2 -0
  51. package/dist/features/Operation/layouts/ModernLayout.vue.d.ts.map +1 -1
  52. package/dist/features/Operation/layouts/ModernLayout.vue.js +2 -2
  53. package/dist/features/Operation/layouts/ModernLayout.vue2.js +52 -48
  54. package/dist/helpers/convertRequestToHarRequest.d.ts +7 -0
  55. package/dist/helpers/convertRequestToHarRequest.d.ts.map +1 -0
  56. package/dist/helpers/convertRequestToHarRequest.js +64 -0
  57. package/dist/helpers/get-request.d.ts +40 -0
  58. package/dist/helpers/get-request.d.ts.map +1 -0
  59. package/dist/helpers/get-request.js +6 -0
  60. package/dist/helpers/getExampleCode.d.ts +2 -2
  61. package/dist/helpers/getExampleCode.d.ts.map +1 -1
  62. package/dist/helpers/getExampleCode.js +19 -16
  63. package/dist/helpers/index.d.ts +1 -3
  64. package/dist/helpers/index.d.ts.map +1 -1
  65. package/dist/helpers/provideSymbols.d.ts +0 -5
  66. package/dist/helpers/provideSymbols.d.ts.map +1 -1
  67. package/dist/helpers/provideSymbols.js +3 -4
  68. package/dist/hooks/useReactiveSpec.d.ts +1 -1
  69. package/dist/hooks/useSidebar.d.ts.map +1 -1
  70. package/dist/index.js +77 -85
  71. package/dist/legacy/helpers/getUrlFromServerState.js +8 -8
  72. package/dist/legacy/helpers/index.d.ts +0 -10
  73. package/dist/legacy/helpers/index.d.ts.map +1 -1
  74. package/dist/legacy/stores/index.d.ts +0 -3
  75. package/dist/legacy/stores/index.d.ts.map +1 -1
  76. package/dist/stores/index.d.ts +0 -1
  77. package/dist/stores/index.d.ts.map +1 -1
  78. package/dist/style.css +1 -1
  79. package/package.json +8 -8
  80. package/dist/components/Content/Authentication/Authentication.vue.d.ts +0 -8
  81. package/dist/components/Content/Authentication/Authentication.vue.d.ts.map +0 -1
  82. package/dist/components/Content/Authentication/Authentication.vue.js +0 -7
  83. package/dist/components/Content/Authentication/Authentication.vue2.js +0 -62
  84. package/dist/components/Content/Authentication/index.d.ts +0 -2
  85. package/dist/components/Content/Authentication/index.d.ts.map +0 -1
  86. package/dist/helpers/createRequest.d.ts +0 -6
  87. package/dist/helpers/createRequest.d.ts.map +0 -1
  88. package/dist/helpers/createRequest.js +0 -16
  89. package/dist/helpers/getApiClientRequest.d.ts +0 -13
  90. package/dist/helpers/getApiClientRequest.d.ts.map +0 -1
  91. package/dist/helpers/getApiClientRequest.js +0 -43
  92. package/dist/helpers/getHarRequest.d.ts +0 -4
  93. package/dist/helpers/getHarRequest.d.ts.map +0 -1
  94. package/dist/helpers/getHarRequest.js +0 -34
  95. package/dist/legacy/components/CardForm.vue.d.ts +0 -18
  96. package/dist/legacy/components/CardForm.vue.d.ts.map +0 -1
  97. package/dist/legacy/components/CardForm.vue.js +0 -13
  98. package/dist/legacy/components/CardFormButton.vue.d.ts +0 -22
  99. package/dist/legacy/components/CardFormButton.vue.d.ts.map +0 -1
  100. package/dist/legacy/components/CardFormButton.vue.js +0 -7
  101. package/dist/legacy/components/CardFormButton.vue2.js +0 -18
  102. package/dist/legacy/components/CardFormGroup.vue.d.ts +0 -18
  103. package/dist/legacy/components/CardFormGroup.vue.d.ts.map +0 -1
  104. package/dist/legacy/components/CardFormGroup.vue.js +0 -13
  105. package/dist/legacy/components/CardFormRows.vue.d.ts +0 -18
  106. package/dist/legacy/components/CardFormRows.vue.d.ts.map +0 -1
  107. package/dist/legacy/components/CardFormRows.vue.js +0 -13
  108. package/dist/legacy/components/CardFormTextInput.vue.d.ts +0 -23
  109. package/dist/legacy/components/CardFormTextInput.vue.d.ts.map +0 -1
  110. package/dist/legacy/components/CardFormTextInput.vue.js +0 -7
  111. package/dist/legacy/components/CardFormTextInput.vue2.js +0 -53
  112. package/dist/legacy/components/SecurityScheme.vue.d.ts +0 -8
  113. package/dist/legacy/components/SecurityScheme.vue.d.ts.map +0 -1
  114. package/dist/legacy/components/SecurityScheme.vue.js +0 -7
  115. package/dist/legacy/components/SecurityScheme.vue2.js +0 -393
  116. package/dist/legacy/components/SecuritySchemeScopes.vue.d.ts +0 -13
  117. package/dist/legacy/components/SecuritySchemeScopes.vue.d.ts.map +0 -1
  118. package/dist/legacy/components/SecuritySchemeScopes.vue.js +0 -7
  119. package/dist/legacy/components/SecuritySchemeScopes.vue2.js +0 -91
  120. package/dist/legacy/components/SecuritySchemeSelector.vue.d.ts +0 -11
  121. package/dist/legacy/components/SecuritySchemeSelector.vue.d.ts.map +0 -1
  122. package/dist/legacy/components/SecuritySchemeSelector.vue.js +0 -7
  123. package/dist/legacy/components/SecuritySchemeSelector.vue2.js +0 -96
  124. package/dist/legacy/helpers/createPlaceholderRequest.d.ts +0 -6
  125. package/dist/legacy/helpers/createPlaceholderRequest.d.ts.map +0 -1
  126. package/dist/legacy/helpers/encodeStringAsBase64.js +0 -6
  127. package/dist/legacy/helpers/getRequestFromAuthentication.d.ts +0 -10
  128. package/dist/legacy/helpers/getRequestFromAuthentication.d.ts.map +0 -1
  129. package/dist/legacy/helpers/getRequestFromAuthentication.js +0 -83
  130. package/dist/legacy/helpers/humanDiff.d.ts +0 -5
  131. package/dist/legacy/helpers/humanDiff.d.ts.map +0 -1
  132. package/dist/legacy/helpers/mapFromArray.d.ts +0 -5
  133. package/dist/legacy/helpers/mapFromArray.d.ts.map +0 -1
  134. package/dist/legacy/helpers/normalizeHeaderName.d.ts +0 -5
  135. package/dist/legacy/helpers/normalizeHeaderName.d.ts.map +0 -1
  136. package/dist/legacy/helpers/normalizeHeaderName.js +0 -6
  137. package/dist/legacy/helpers/normalizeHeaders.d.ts +0 -8
  138. package/dist/legacy/helpers/normalizeHeaders.d.ts.map +0 -1
  139. package/dist/legacy/helpers/normalizeHeaders.js +0 -22
  140. package/dist/legacy/helpers/normalizePath.d.ts +0 -5
  141. package/dist/legacy/helpers/normalizePath.d.ts.map +0 -1
  142. package/dist/legacy/helpers/normalizeUrl.d.ts +0 -5
  143. package/dist/legacy/helpers/normalizeUrl.d.ts.map +0 -1
  144. package/dist/legacy/helpers/prepareClientRequestConfig.d.ts +0 -24
  145. package/dist/legacy/helpers/prepareClientRequestConfig.d.ts.map +0 -1
  146. package/dist/legacy/stores/useAuthenticationStore.d.ts +0 -55
  147. package/dist/legacy/stores/useAuthenticationStore.d.ts.map +0 -1
  148. package/dist/legacy/stores/useAuthenticationStore.js +0 -36
  149. package/dist/legacy/stores/useOpenApiStore.d.ts +0 -125
  150. package/dist/legacy/stores/useOpenApiStore.d.ts.map +0 -1
  151. package/dist/legacy/stores/useOpenApiStore.js +0 -9
  152. package/dist/legacy/stores/useRequestStore.d.ts +0 -62
  153. package/dist/legacy/stores/useRequestStore.d.ts.map +0 -1
@@ -1,54 +1,49 @@
1
- import { defineComponent as G, useId as Q, computed as f, ref as W, watch as X, inject as Z, onServerPrefetch as ee, useSSRContext as te, unref as r, openBlock as p, createBlock as K, withCtx as a, createVNode as s, createElementBlock as x, Fragment as N, createTextVNode as y, toDisplayString as C, createElementVNode as k, renderSlot as v, createCommentVNode as E } from "vue";
2
- import { ScalarCodeBlock as oe } from "@scalar/components";
3
- import { createHash as re, ssrState as ae } from "@scalar/oas-utils/helpers";
4
- import { getRequestFromOperation as se } from "@scalar/oas-utils/spec-getters";
5
- import { asyncComputed as le } from "@vueuse/core";
6
- import T from "../../components/ScreenReader.vue.js";
7
- import ne from "./ExamplePicker.vue.js";
8
- import ie from "./TextSelect.vue.js";
1
+ import { defineComponent as D, useId as M, computed as p, ref as z, watch as A, onServerPrefetch as G, useSSRContext as L, unref as o, openBlock as m, createBlock as v, withCtx as l, createVNode as r, createElementBlock as g, Fragment as V, createTextVNode as d, toDisplayString as h, createElementVNode as K, renderSlot as f, createCommentVNode as x } from "vue";
2
+ import { ScalarCodeBlock as Q } from "@scalar/components";
3
+ import { createHash as W, ssrState as X } from "@scalar/oas-utils/helpers";
4
+ import { asyncComputed as Y } from "@vueuse/core";
5
+ import H from "../../components/ScreenReader.vue.js";
6
+ import Z from "./ExamplePicker.vue.js";
7
+ import _ from "./TextSelect.vue.js";
9
8
  /* empty css */
10
- import { GLOBAL_SECURITY_SYMBOL as ue } from "../../helpers/provideSymbols.js";
11
- import j from "../../components/Card/Card.vue.js";
12
- import me from "../../components/Card/CardHeader.vue.js";
13
- import F from "../../components/HttpMethod/HttpMethod.vue.js";
14
- import U from "../../components/Card/CardContent.vue.js";
15
- import { getSecretCredentialsFromAuthentication as pe, getRequestFromAuthentication as ce } from "../../legacy/helpers/getRequestFromAuthentication.js";
16
- import de from "../../components/Card/CardFooter.vue.js";
17
- import { getExampleCode as fe } from "../../helpers/getExampleCode.js";
18
- import { useHttpClientStore as ye } from "../../stores/useHttpClientStore.js";
19
- import { useServerStore as ve } from "../../legacy/stores/useServerStore.js";
20
- import { useExampleStore as he } from "../../legacy/stores/useExampleStore.js";
21
- import { useAuthenticationStore as ge } from "../../legacy/stores/useAuthenticationStore.js";
22
- import { getUrlFromServerState as Se } from "../../legacy/helpers/getUrlFromServerState.js";
23
- import { getHarRequest as Ke } from "../../helpers/getHarRequest.js";
24
- const xe = ["id"], Ce = ["id"], ke = {
9
+ import N from "../../components/Card/Card.vue.js";
10
+ import ee from "../../components/Card/CardHeader.vue.js";
11
+ import B from "../../components/HttpMethod/HttpMethod.vue.js";
12
+ import O from "../../components/Card/CardContent.vue.js";
13
+ import te from "../../components/Card/CardFooter.vue.js";
14
+ import { getExampleCode as ae } from "../../helpers/getExampleCode.js";
15
+ import { useHttpClientStore as oe } from "../../stores/useHttpClientStore.js";
16
+ import { useExampleStore as le } from "../../legacy/stores/useExampleStore.js";
17
+ const re = ["id"], se = ["id"], ne = {
25
18
  key: 0,
26
19
  class: "request-card-footer-addon"
27
- }, Ee = { class: "request-header" }, Ge = /* @__PURE__ */ G({
20
+ }, ie = { class: "request-header" }, qe = /* @__PURE__ */ D({
28
21
  __name: "ExampleRequest",
29
22
  props: {
30
23
  operation: {},
24
+ request: {},
25
+ secretCredentials: {},
31
26
  fallback: { type: Boolean }
32
27
  },
33
- setup(w) {
34
- const l = w, b = `components-Content-Operation-Example-Request${re(
35
- l.operation.path + l.operation.httpVerb + l.operation.operationId
36
- )}`, { selectedExampleKey: q, operationId: I } = he(), {
28
+ setup(n) {
29
+ const C = `components-Content-Operation-Example-Request${W(
30
+ n.operation.path + n.operation.httpVerb + n.operation.operationId
31
+ )}`, { selectedExampleKey: T, operationId: j } = le(), {
37
32
  httpClient: i,
38
- setHttpClient: A,
39
- availableTargets: _,
40
- httpTargetTitle: J,
41
- httpClientTitle: L
42
- } = ye(), { server: P } = ve(), { authentication: V } = ge(), h = Q(), m = f(() => {
33
+ setHttpClient: w,
34
+ availableTargets: k,
35
+ httpTargetTitle: R,
36
+ httpClientTitle: I
37
+ } = oe(), y = M(), u = p(() => {
43
38
  var t;
44
39
  const e = ["x-custom-examples", "x-codeSamples", "x-code-samples"];
45
- for (const o of e)
46
- if ((t = l.operation.information) != null && t[o])
47
- return [...l.operation.information[o]];
40
+ for (const a of e)
41
+ if ((t = n.operation.information) != null && t[a])
42
+ return [...n.operation.information[a]];
48
43
  return [];
49
- }), n = W(
44
+ }), s = z(
50
45
  // Default to first custom example
51
- m.value.length ? {
46
+ u.value.length ? {
52
47
  targetKey: "customExamples",
53
48
  clientKey: 0
54
49
  } : (
@@ -59,214 +54,193 @@ const xe = ["id"], Ce = ["id"], ke = {
59
54
  }
60
55
  )
61
56
  );
62
- X(i, () => {
63
- n.value = {
57
+ A(i, () => {
58
+ s.value = {
64
59
  targetKey: i.targetKey,
65
60
  clientKey: i.clientKey
66
61
  };
67
62
  });
68
- const $ = f(
63
+ const E = p(
69
64
  () => {
70
- var e, t, o, u;
65
+ var e, t, a, c;
71
66
  return Object.keys(
72
- ((u = (o = (t = (e = l.operation.information) == null ? void 0 : e.requestBody) == null ? void 0 : t.content) == null ? void 0 : o["application/json"]) == null ? void 0 : u.examples) ?? {}
67
+ ((c = (a = (t = (e = n.operation.information) == null ? void 0 : e.requestBody) == null ? void 0 : t.content) == null ? void 0 : a["application/json"]) == null ? void 0 : c.examples) ?? {}
73
68
  ).length > 1;
74
69
  }
75
- ), g = Z(ue);
76
- async function H() {
77
- var c, d;
78
- if (n.value.targetKey === "customExamples")
79
- return ((c = m.value[n.value.clientKey]) == null ? void 0 : c.source) ?? "";
80
- const e = f(() => {
81
- var R, B;
82
- const S = (B = (R = l.operation.information) == null ? void 0 : R.servers) == null ? void 0 : B[0], { modifiedUrl: z } = Se(P, S);
83
- return z;
84
- }), t = Ke(
85
- {
86
- url: e.value
87
- },
88
- se(
89
- l.operation,
90
- {
91
- replaceVariables: !0
92
- },
93
- q.value,
94
- !0
95
- ),
96
- ce(
97
- V,
98
- ((d = l.operation.information) == null ? void 0 : d.security) ?? (g == null ? void 0 : g())
99
- )
100
- ), o = i.clientKey, u = i.targetKey;
101
- return await fe(t, u, o) ?? "";
102
- }
103
- const O = le(async () => {
70
+ ), S = async () => {
71
+ var a;
72
+ if (s.value.targetKey === "customExamples")
73
+ return ((a = u.value[s.value.clientKey]) == null ? void 0 : a.source) ?? "";
74
+ if (!n.request) return "";
75
+ const e = i.clientKey, t = i.targetKey;
76
+ return await ae(n.request, t, e) ?? "";
77
+ }, b = Y(async () => {
104
78
  try {
105
- return await H();
79
+ return await S();
106
80
  } catch (e) {
107
81
  return console.error("[generateSnippet]", e), "";
108
82
  }
109
- }, ae[b] ?? "");
110
- ee(async () => {
111
- const e = te();
112
- e.payload.data[b] = await H();
83
+ }, X[C] ?? "");
84
+ G(async () => {
85
+ const e = L();
86
+ e.payload.data[C] = await S();
113
87
  });
114
- const M = f(() => {
115
- var t, o;
88
+ const J = p(() => {
89
+ var t, a;
116
90
  const e = (
117
91
  // Specified language
118
- ((t = n.value) == null ? void 0 : t.targetKey) === "customExamples" ? ((o = m.value[n.value.clientKey]) == null ? void 0 : o.lang) ?? "plaintext" : (
92
+ ((t = s.value) == null ? void 0 : t.targetKey) === "customExamples" ? ((a = u.value[s.value.clientKey]) == null ? void 0 : a.lang) ?? "plaintext" : (
119
93
  // Or language for the globally selected HTTP client
120
94
  i.targetKey
121
95
  )
122
96
  );
123
- return e === "shell" && O.value.includes("curl") ? "curl" : e === "Objective-C" ? "objc" : e;
124
- }), Y = f(() => {
125
- const e = _.value.map((t) => ({
97
+ return e === "shell" && b.value.includes("curl") ? "curl" : e === "Objective-C" ? "objc" : e;
98
+ }), P = p(() => {
99
+ const e = k.value.map((t) => ({
126
100
  value: t.key,
127
101
  label: t.title,
128
- options: t.clients.map((o) => ({
102
+ options: t.clients.map((a) => ({
129
103
  value: JSON.stringify({
130
104
  targetKey: t.key,
131
- clientKey: o.key
105
+ clientKey: a.key
132
106
  }),
133
- label: o.title
107
+ label: a.title
134
108
  }))
135
109
  }));
136
- return m.value.length && e.unshift({
110
+ return u.value.length && e.unshift({
137
111
  value: "customExamples",
138
112
  label: "Examples",
139
- options: m.value.map((t, o) => ({
113
+ options: u.value.map((t, a) => ({
140
114
  value: JSON.stringify({
141
115
  targetKey: "customExamples",
142
- clientKey: o
116
+ clientKey: a
143
117
  }),
144
- label: t.label ?? t.lang ?? `Example #${o + 1}`
118
+ label: t.label ?? t.lang ?? `Example #${a + 1}`
145
119
  }))
146
120
  }), e;
147
121
  });
148
- function D(e) {
122
+ function F(e) {
149
123
  const t = JSON.parse(e);
150
- t.targetKey === "customExamples" ? n.value = t : A(t);
124
+ t.targetKey === "customExamples" ? s.value = t : w(t);
151
125
  }
152
- return (e, t) => r(_).length || m.value.length ? (p(), K(r(j), {
126
+ return (e, t) => o(k).length || u.value.length ? (m(), v(o(N), {
153
127
  key: 0,
154
128
  class: "dark-mode"
155
129
  }, {
156
- default: a(() => [
157
- s(r(me), { muted: "" }, {
158
- actions: a(() => [
159
- s(ie, {
130
+ default: l(() => [
131
+ r(o(ee), { muted: "" }, {
132
+ actions: l(() => [
133
+ r(_, {
160
134
  class: "request-client-picker",
161
- controls: `${r(h)}-example`,
162
- modelValue: JSON.stringify(n.value),
163
- options: Y.value,
164
- "onUpdate:modelValue": D
135
+ controls: `${o(y)}-example`,
136
+ modelValue: JSON.stringify(s.value),
137
+ options: P.value,
138
+ "onUpdate:modelValue": F
165
139
  }, {
166
- default: a(() => [
167
- n.value.targetKey === "customExamples" ? (p(), x(N, { key: 0 }, [
168
- s(T, null, {
169
- default: a(() => t[1] || (t[1] = [
170
- y("Selected Example:")
140
+ default: l(() => [
141
+ s.value.targetKey === "customExamples" ? (m(), g(V, { key: 0 }, [
142
+ r(H, null, {
143
+ default: l(() => t[1] || (t[1] = [
144
+ d("Selected Example:")
171
145
  ])),
172
146
  _: 1
173
147
  }),
174
- y(" " + C(m.value[n.value.clientKey].label ?? "Example"), 1)
175
- ], 64)) : (p(), x(N, { key: 1 }, [
176
- s(T, null, {
177
- default: a(() => t[2] || (t[2] = [
178
- y("Selected HTTP client:")
148
+ d(" " + h(u.value[s.value.clientKey].label ?? "Example"), 1)
149
+ ], 64)) : (m(), g(V, { key: 1 }, [
150
+ r(H, null, {
151
+ default: l(() => t[2] || (t[2] = [
152
+ d("Selected HTTP client:")
179
153
  ])),
180
154
  _: 1
181
155
  }),
182
- y(" " + C(r(J)) + " " + C(r(L)), 1)
156
+ d(" " + h(o(R)) + " " + h(o(I)), 1)
183
157
  ], 64))
184
158
  ]),
185
159
  _: 1
186
160
  }, 8, ["controls", "modelValue", "options"])
187
161
  ]),
188
- default: a(() => [
189
- k("div", {
190
- id: `${r(h)}-header`,
162
+ default: l(() => [
163
+ K("div", {
164
+ id: `${o(y)}-header`,
191
165
  class: "request-header"
192
166
  }, [
193
- s(r(F), {
167
+ r(o(B), {
194
168
  as: "span",
195
169
  class: "request-method",
196
170
  method: e.operation.httpVerb
197
171
  }, null, 8, ["method"]),
198
- v(e.$slots, "header", {}, void 0, !0)
199
- ], 8, xe)
172
+ f(e.$slots, "header", {}, void 0, !0)
173
+ ], 8, re)
200
174
  ]),
201
175
  _: 3
202
176
  }),
203
- s(r(U), {
177
+ r(o(O), {
204
178
  borderless: "",
205
179
  class: "request-editor-section custom-scroll",
206
180
  frameless: ""
207
181
  }, {
208
- default: a(() => [
209
- k("div", {
210
- id: `${r(h)}-example`,
182
+ default: l(() => [
183
+ K("div", {
184
+ id: `${o(y)}-example`,
211
185
  class: "code-snippet"
212
186
  }, [
213
- s(r(oe), {
187
+ r(o(Q), {
214
188
  class: "bg-b-2",
215
- content: r(O),
216
- hideCredentials: r(pe)(r(V)),
217
- lang: M.value,
189
+ content: o(b),
190
+ hideCredentials: e.secretCredentials,
191
+ lang: J.value,
218
192
  lineNumbers: ""
219
193
  }, null, 8, ["content", "hideCredentials", "lang"])
220
- ], 8, Ce)
194
+ ], 8, se)
221
195
  ]),
222
196
  _: 1
223
197
  }),
224
- $.value || e.$slots.footer ? (p(), K(r(de), {
198
+ E.value || e.$slots.footer ? (m(), v(o(te), {
225
199
  key: 0,
226
200
  class: "request-card-footer",
227
201
  contrast: ""
228
202
  }, {
229
- default: a(() => {
230
- var o, u, c, d;
203
+ default: l(() => {
204
+ var a, c, q, $;
231
205
  return [
232
- $.value ? (p(), x("div", ke, [
233
- s(ne, {
206
+ E.value ? (m(), g("div", ne, [
207
+ r(Z, {
234
208
  class: "request-example-selector",
235
- examples: ((d = (c = (u = (o = e.operation.information) == null ? void 0 : o.requestBody) == null ? void 0 : u.content) == null ? void 0 : c["application/json"]) == null ? void 0 : d.examples) ?? [],
236
- "onUpdate:modelValue": t[0] || (t[0] = (S) => (q.value = S, I.value = e.operation.operationId))
209
+ examples: (($ = (q = (c = (a = e.operation.information) == null ? void 0 : a.requestBody) == null ? void 0 : c.content) == null ? void 0 : q["application/json"]) == null ? void 0 : $.examples) ?? [],
210
+ "onUpdate:modelValue": t[0] || (t[0] = (U) => (T.value = U, j.value = e.operation.operationId))
237
211
  }, null, 8, ["examples"])
238
- ])) : E("", !0),
239
- v(e.$slots, "footer", {}, void 0, !0)
212
+ ])) : x("", !0),
213
+ f(e.$slots, "footer", {}, void 0, !0)
240
214
  ];
241
215
  }),
242
216
  _: 3
243
- })) : E("", !0)
217
+ })) : x("", !0)
244
218
  ]),
245
219
  _: 3
246
- })) : e.fallback ? (p(), K(r(j), {
220
+ })) : e.fallback ? (m(), v(o(N), {
247
221
  key: 1,
248
222
  class: "dark-mode"
249
223
  }, {
250
- default: a(() => [
251
- s(r(U), { class: "request-card-simple" }, {
252
- default: a(() => [
253
- k("div", Ee, [
254
- s(r(F), {
224
+ default: l(() => [
225
+ r(o(O), { class: "request-card-simple" }, {
226
+ default: l(() => [
227
+ K("div", ie, [
228
+ r(o(B), {
255
229
  as: "span",
256
230
  class: "request-method",
257
231
  method: e.operation.httpVerb
258
232
  }, null, 8, ["method"]),
259
- v(e.$slots, "header", {}, void 0, !0)
233
+ f(e.$slots, "header", {}, void 0, !0)
260
234
  ]),
261
- v(e.$slots, "footer", {}, void 0, !0)
235
+ f(e.$slots, "footer", {}, void 0, !0)
262
236
  ]),
263
237
  _: 3
264
238
  })
265
239
  ]),
266
240
  _: 3
267
- })) : E("", !0);
241
+ })) : x("", !0);
268
242
  }
269
243
  });
270
244
  export {
271
- Ge as default
245
+ qe as default
272
246
  };
@@ -1,11 +1,13 @@
1
+ import { type WorkspaceStore } from '@scalar/api-client/store';
1
2
  import type { TransformedOperation } from '@scalar/types/legacy';
2
3
  type __VLS_Props = {
3
4
  id?: string;
4
- operation: TransformedOperation;
5
5
  layout?: 'modern' | 'classic';
6
+ operation: TransformedOperation;
7
+ requests: WorkspaceStore['requests'];
8
+ requestExamples: WorkspaceStore['requestExamples'];
9
+ securitySchemes: WorkspaceStore['securitySchemes'];
6
10
  };
7
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
- layout: "modern" | "classic";
9
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
12
  export default _default;
11
13
  //# sourceMappingURL=Operation.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Operation.vue.d.ts","sourceRoot":"","sources":["../../../src/features/Operation/Operation.vue"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAOhE,KAAK,WAAW,GAAG;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,oBAAoB,CAAA;IAC/B,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAC9B,CAAC;;YADS,QAAQ,GAAG,SAAS;;AAgFjC,wBAOG"}
1
+ {"version":3,"file":"Operation.vue.d.ts","sourceRoot":"","sources":["../../../src/features/Operation/Operation.vue"],"names":[],"mappings":"AAwDA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAQhE,KAAK,WAAW,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC7B,SAAS,EAAE,oBAAoB,CAAA;IAC/B,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACpC,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;IAClD,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;CACnD,CAAC;;AA0FF,wBAMG"}
@@ -1,25 +1,42 @@
1
- import { defineComponent as i, openBlock as e, createBlock as r } from "vue";
2
- import a from "./layouts/ClassicLayout.vue.js";
3
- import n from "./layouts/ModernLayout.vue.js";
4
- const m = /* @__PURE__ */ i({
1
+ import { defineComponent as c, openBlock as i, createBlock as a, unref as r } from "vue";
2
+ import { useActiveEntities as l } from "@scalar/api-client/store";
3
+ import { useRequestExample as m } from "./hooks/useRequestExample.js";
4
+ import p from "./layouts/ClassicLayout.vue.js";
5
+ import d from "./layouts/ModernLayout.vue.js";
6
+ const h = /* @__PURE__ */ c({
5
7
  __name: "Operation",
6
8
  props: {
7
9
  id: {},
10
+ layout: { default: "modern" },
8
11
  operation: {},
9
- layout: { default: "modern" }
12
+ requests: {},
13
+ requestExamples: {},
14
+ securitySchemes: {}
10
15
  },
11
16
  setup(t) {
12
- return (o, p) => o.layout === "classic" ? (e(), r(a, {
17
+ const { activeCollection: n, activeServer: u } = l(), { request: o, secretCredentials: s } = m({
18
+ operation: t.operation,
19
+ collection: n,
20
+ requests: t.requests,
21
+ requestExamples: t.requestExamples,
22
+ securitySchemes: t.securitySchemes,
23
+ server: u
24
+ });
25
+ return (e, q) => e.layout === "classic" ? (i(), a(p, {
13
26
  key: 0,
14
- id: o.id,
15
- operation: o.operation
16
- }, null, 8, ["id", "operation"])) : (e(), r(n, {
27
+ id: e.id,
28
+ operation: e.operation,
29
+ request: r(o),
30
+ secretCredentials: r(s)
31
+ }, null, 8, ["id", "operation", "request", "secretCredentials"])) : (i(), a(d, {
17
32
  key: 1,
18
- id: o.id,
19
- operation: o.operation
20
- }, null, 8, ["id", "operation"]));
33
+ id: e.id,
34
+ operation: e.operation,
35
+ request: r(o),
36
+ secretCredentials: r(s)
37
+ }, null, 8, ["id", "operation", "request", "secretCredentials"]));
21
38
  }
22
39
  });
23
40
  export {
24
- m as default
41
+ h as default
25
42
  };
@@ -0,0 +1,17 @@
1
+ import type { WorkspaceStore } from '@scalar/api-client/store';
2
+ import type { Collection, Server } from '@scalar/oas-utils/entities/spec';
3
+ import type { TransformedOperation } from '@scalar/types/legacy';
4
+ import { type ComputedRef } from 'vue';
5
+ /** Builds a request object for the code sniipet, as well as the security credentials to obfuscate */
6
+ export declare const useRequestExample: ({ operation, collection, requests, requestExamples, securitySchemes, server, }: {
7
+ operation: TransformedOperation;
8
+ collection: ComputedRef<Collection | undefined>;
9
+ requests: WorkspaceStore["requests"];
10
+ requestExamples: WorkspaceStore["requestExamples"];
11
+ securitySchemes: WorkspaceStore["securitySchemes"];
12
+ server: ComputedRef<Server>;
13
+ }) => {
14
+ request: ComputedRef<Request | null>;
15
+ secretCredentials: ComputedRef<string[]>;
16
+ };
17
+ //# sourceMappingURL=useRequestExample.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRequestExample.d.ts","sourceRoot":"","sources":["../../../../src/features/Operation/hooks/useRequestExample.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,KAAK,CAAA;AAEhD,qGAAqG;AACrG,eAAO,MAAM,iBAAiB,mFAO3B;IACD,SAAS,EAAE,oBAAoB,CAAA;IAC/B,UAAU,EAAE,WAAW,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IAC/C,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACpC,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;IAClD,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;IAClD,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC5B;;;CA6FA,CAAA"}
@@ -0,0 +1,68 @@
1
+ import { getRequest as S } from "../../../helpers/get-request.js";
2
+ import { createRequestOperation as k } from "@scalar/api-client/libs";
3
+ import { computed as c } from "vue";
4
+ const w = ({
5
+ operation: p,
6
+ collection: d,
7
+ requests: v,
8
+ requestExamples: q,
9
+ securitySchemes: f,
10
+ server: b
11
+ }) => {
12
+ const o = c(
13
+ () => S(v, p.path, p.httpVerb)
14
+ ), y = c(() => {
15
+ var n, u, a, l;
16
+ const t = ((n = o.value) == null ? void 0 : n.security) ?? ((u = d.value) == null ? void 0 : u.security) ?? [], s = t.filter(
17
+ (r) => Object.keys(r).length
18
+ ), e = s.map((r) => Object.keys(r)[0]);
19
+ if (s.length < t.length)
20
+ return ((a = d.value) == null ? void 0 : a.selectedSecuritySchemeUids) ?? [];
21
+ {
22
+ const r = Object.values(f), g = e.map((m) => {
23
+ var i;
24
+ return (i = r.find((j) => j.nameKey === m)) == null ? void 0 : i.uid;
25
+ }).filter(Boolean);
26
+ return (l = d.value) == null ? void 0 : l.selectedSecuritySchemeUids.filter(
27
+ (m) => g.find((i) => i === m)
28
+ );
29
+ }
30
+ }), h = c(() => {
31
+ var u, a, l, r;
32
+ const t = q[((a = (u = o.value) == null ? void 0 : u.examples) == null ? void 0 : a[0]) ?? ""];
33
+ if (!o.value || !t) return null;
34
+ const [s, e] = k({
35
+ request: o.value,
36
+ example: t,
37
+ server: b.value,
38
+ securitySchemes: f,
39
+ selectedSecuritySchemeUids: y.value,
40
+ // TODO: env vars if we want em
41
+ environment: {},
42
+ // TODO: cookies if we want em
43
+ globalCookies: []
44
+ });
45
+ if (s)
46
+ return console.error("[useRequestExample]", s), null;
47
+ const n = Object.keys(
48
+ ((r = (l = p.information) == null ? void 0 : l.requestBody) == null ? void 0 : r.content) ?? {}
49
+ );
50
+ return e.request.headers.get("content-type") === "text/plain;charset=UTF-8" && n.length && e.request.headers.set("content-type", n[0]), e.request;
51
+ }), O = c(
52
+ () => {
53
+ var t;
54
+ return ((t = y.value) == null ? void 0 : t.flatMap((s) => {
55
+ const e = f[s];
56
+ return (e == null ? void 0 : e.type) === "apiKey" ? e.value : (e == null ? void 0 : e.type) === "http" ? [
57
+ e.token,
58
+ e.password,
59
+ btoa(`${e.username}:${e.password}`)
60
+ ] : (e == null ? void 0 : e.type) === "oauth2" ? Object.values(e.flows).map((n) => n.token) : [];
61
+ })) ?? [];
62
+ }
63
+ );
64
+ return { request: h, secretCredentials: O };
65
+ };
66
+ export {
67
+ w as useRequestExample
68
+ };
@@ -2,6 +2,8 @@ import type { TransformedOperation } from '@scalar/types/legacy';
2
2
  type __VLS_Props = {
3
3
  id?: string;
4
4
  operation: TransformedOperation;
5
+ request: Request | null;
6
+ secretCredentials: string[];
5
7
  };
6
8
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
9
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"ClassicLayout.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Operation/layouts/ClassicLayout.vue"],"names":[],"mappings":"AAkSA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAShE,KAAK,WAAW,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,oBAAoB,CAAA;CAChC,CAAC;;AAuPF,wBAOG"}
1
+ {"version":3,"file":"ClassicLayout.vue.d.ts","sourceRoot":"","sources":["../../../../src/features/Operation/layouts/ClassicLayout.vue"],"names":[],"mappings":"AAuSA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAShE,KAAK,WAAW,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,oBAAoB,CAAA;IAC/B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAA;CAC5B,CAAC;;AAwPF,wBAOG"}
@@ -1,7 +1,7 @@
1
1
  import o from "./ClassicLayout.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-5753de10"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-040b254b"]]);
5
5
  export {
6
6
  m as default
7
7
  };