@scalar/openapi-to-markdown 0.5.44 → 0.6.0

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.
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { readFiles } from "@scalar/json-magic/bundle/plugins/node";
3
3
  import { normalize } from "@scalar/json-magic/helpers/normalize";
4
4
  import { createWorkspaceStore } from "@scalar/workspace-store/client";
5
5
  import { forEachPathItemOperation, getPathItemOperation, getResolvedPathItem } from "@scalar/workspace-store/helpers/for-each-path-item-operation";
6
+ import { getResolvedRef, mergeSiblingReferences } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
7
  import { minify } from "html-minifier-terser";
7
8
  import rehypeParse from "rehype-parse";
8
9
  import rehypeRemark from "rehype-remark";
@@ -13,16 +14,15 @@ import { unified } from "unified";
13
14
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSSRApp, createTextVNode, createVNode, defineComponent, openBlock, renderList, resolveComponent, toDisplayString, unref } from "vue";
14
15
  import { renderToString } from "vue/server-renderer";
15
16
  import { ScalarMarkdown } from "@scalar/components/markdown";
16
- import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
17
17
  import { getExampleFromSchema } from "@scalar/workspace-store/request-example";
18
18
  import { resolve } from "@scalar/workspace-store/resolve";
19
19
  import { json2xml } from "@scalar/helpers/file/json2xml";
20
20
  //#region src/components/Schema.vue?vue&type=script&setup=true&lang.ts
21
- var _hoisted_1$2 = { key: 0 };
22
- var _hoisted_2$2 = { key: 1 };
23
- var _hoisted_3$2 = { key: 0 };
24
- var _hoisted_4$2 = { key: 1 };
25
- var _hoisted_5$1 = { key: 2 };
21
+ var _hoisted_1$3 = { key: 0 };
22
+ var _hoisted_2$3 = { key: 1 };
23
+ var _hoisted_3$3 = { key: 0 };
24
+ var _hoisted_4$3 = { key: 1 };
25
+ var _hoisted_5$2 = { key: 2 };
26
26
  var _hoisted_6$1 = { key: 3 };
27
27
  var _hoisted_7$1 = { key: 4 };
28
28
  var _hoisted_8$1 = { key: 0 };
@@ -37,10 +37,10 @@ var _hoisted_16$1 = { key: 0 };
37
37
  var _hoisted_17$1 = { key: 1 };
38
38
  var _hoisted_18$1 = { key: 2 };
39
39
  var _hoisted_19$1 = { key: 6 };
40
- var _hoisted_20 = { key: 0 };
41
- var _hoisted_21 = { key: 1 };
42
- var _hoisted_22 = { key: 2 };
43
- var _hoisted_23 = { key: 3 };
40
+ var _hoisted_20$1 = { key: 0 };
41
+ var _hoisted_21$1 = { key: 1 };
42
+ var _hoisted_22$1 = { key: 2 };
43
+ var _hoisted_23$1 = { key: 3 };
44
44
  var MAX_DEPTH = 10;
45
45
  //#endregion
46
46
  //#region src/components/Schema.vue
@@ -48,10 +48,14 @@ var Schema_default = /* @__PURE__ */ defineComponent({
48
48
  __name: "Schema",
49
49
  props: {
50
50
  schema: {},
51
- depth: { default: 0 }
51
+ depth: { default: 0 },
52
+ ancestors: { default: () => [] }
52
53
  },
53
54
  setup(__props) {
54
55
  const resolvedSchema = resolve.schema(__props.schema);
56
+ const identity = "$ref" in __props.schema ? __props.schema.$ref : __props.schema;
57
+ const circular = __props.ancestors.includes(identity);
58
+ const childAncestors = [...__props.ancestors, identity];
55
59
  const resolveNestedSchema = (value) => resolve.schema(value);
56
60
  const asObject = (value) => value !== null && typeof value === "object" ? value : void 0;
57
61
  const getSchemaType = (value) => {
@@ -119,25 +123,29 @@ var Schema_default = /* @__PURE__ */ defineComponent({
119
123
  };
120
124
  return (_ctx, _cache) => {
121
125
  const _component_Schema = resolveComponent("Schema", true);
122
- return __props.depth >= MAX_DEPTH ? (openBlock(), createElementBlock("section", _hoisted_1$2, [..._cache[0] || (_cache[0] = [createElementVNode("p", null, [createElementVNode("em", null, "[Circular Reference]")], -1)])])) : unref(resolvedSchema) ? (openBlock(), createElementBlock("section", _hoisted_2$2, [getSchemaArray(unref(resolvedSchema), "allOf") ? (openBlock(), createElementBlock("section", _hoisted_3$2, [_cache[1] || (_cache[1] = createElementVNode("header", null, [createElementVNode("strong", null, "All of:")], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(getSchemaArray(unref(resolvedSchema), "allOf"), (subSchema, index) => {
126
+ return unref(circular) || __props.depth >= MAX_DEPTH ? (openBlock(), createElementBlock("section", _hoisted_1$3, [..._cache[0] || (_cache[0] = [createElementVNode("p", null, [createElementVNode("em", null, "[Circular Reference]")], -1)])])) : unref(resolvedSchema) ? (openBlock(), createElementBlock("section", _hoisted_2$3, [getSchemaArray(unref(resolvedSchema), "allOf") ? (openBlock(), createElementBlock("section", _hoisted_3$3, [_cache[1] || (_cache[1] = createElementVNode("header", null, [createElementVNode("strong", null, "All of:")], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(getSchemaArray(unref(resolvedSchema), "allOf"), (subSchema, index) => {
123
127
  return openBlock(), createElementBlock("section", { key: index }, [createVNode(_component_Schema, {
124
- schema: subSchema,
125
- depth: __props.depth + 1
126
- }, null, 8, ["schema", "depth"])]);
127
- }), 128))])) : getSchemaArray(unref(resolvedSchema), "anyOf") ? (openBlock(), createElementBlock("section", _hoisted_4$2, [_cache[2] || (_cache[2] = createElementVNode("header", null, [createElementVNode("strong", null, "Any of:")], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(getSchemaArray(unref(resolvedSchema), "anyOf"), (subSchema, index) => {
128
+ ancestors: childAncestors,
129
+ depth: __props.depth + 1,
130
+ schema: subSchema
131
+ }, null, 8, ["depth", "schema"])]);
132
+ }), 128))])) : getSchemaArray(unref(resolvedSchema), "anyOf") ? (openBlock(), createElementBlock("section", _hoisted_4$3, [_cache[2] || (_cache[2] = createElementVNode("header", null, [createElementVNode("strong", null, "Any of:")], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(getSchemaArray(unref(resolvedSchema), "anyOf"), (subSchema, index) => {
128
133
  return openBlock(), createElementBlock("section", { key: index }, [createVNode(_component_Schema, {
129
- schema: subSchema,
130
- depth: __props.depth + 1
131
- }, null, 8, ["schema", "depth"])]);
132
- }), 128))])) : getSchemaArray(unref(resolvedSchema), "oneOf") ? (openBlock(), createElementBlock("section", _hoisted_5$1, [_cache[3] || (_cache[3] = createElementVNode("header", null, [createElementVNode("strong", null, "One of:")], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(getSchemaArray(unref(resolvedSchema), "oneOf"), (subSchema, index) => {
134
+ ancestors: childAncestors,
135
+ depth: __props.depth + 1,
136
+ schema: subSchema
137
+ }, null, 8, ["depth", "schema"])]);
138
+ }), 128))])) : getSchemaArray(unref(resolvedSchema), "oneOf") ? (openBlock(), createElementBlock("section", _hoisted_5$2, [_cache[3] || (_cache[3] = createElementVNode("header", null, [createElementVNode("strong", null, "One of:")], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(getSchemaArray(unref(resolvedSchema), "oneOf"), (subSchema, index) => {
133
139
  return openBlock(), createElementBlock("section", { key: index }, [createVNode(_component_Schema, {
134
- schema: subSchema,
135
- depth: __props.depth + 1
136
- }, null, 8, ["schema", "depth"])]);
140
+ ancestors: childAncestors,
141
+ depth: __props.depth + 1,
142
+ schema: subSchema
143
+ }, null, 8, ["depth", "schema"])]);
137
144
  }), 128))])) : getSchemaNot(unref(resolvedSchema)) ? (openBlock(), createElementBlock("section", _hoisted_6$1, [_cache[4] || (_cache[4] = createElementVNode("header", null, [createElementVNode("strong", null, "Not:")], -1)), createElementVNode("section", null, [createVNode(_component_Schema, {
138
- schema: getSchemaNot(unref(resolvedSchema)),
139
- depth: __props.depth + 1
140
- }, null, 8, ["schema", "depth"])])])) : getSchemaType(unref(resolvedSchema)) === "object" || Object.keys(getSchemaProperties(unref(resolvedSchema))).length ? (openBlock(), createElementBlock("section", _hoisted_7$1, [createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(sortProperties(getSchemaProperties(unref(resolvedSchema)), getSchemaRequired(unref(resolvedSchema))), (propSchema, propName) => {
145
+ ancestors: childAncestors,
146
+ depth: __props.depth + 1,
147
+ schema: getSchemaNot(unref(resolvedSchema))
148
+ }, null, 8, ["depth", "schema"])])])) : getSchemaType(unref(resolvedSchema)) === "object" || Object.keys(getSchemaProperties(unref(resolvedSchema))).length ? (openBlock(), createElementBlock("section", _hoisted_7$1, [createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(sortProperties(getSchemaProperties(unref(resolvedSchema)), getSchemaRequired(unref(resolvedSchema))), (propSchema, propName) => {
141
149
  return openBlock(), createElementBlock("li", { key: propName }, [
142
150
  createElementVNode("strong", null, [createElementVNode("code", null, toDisplayString(propName), 1), getSchemaRequired(unref(resolvedSchema)).includes(propName) ? (openBlock(), createElementBlock("span", _hoisted_8$1, " (required) ")) : createCommentVNode("", true)]),
143
151
  createElementVNode("p", null, [
@@ -149,20 +157,23 @@ var Schema_default = /* @__PURE__ */ defineComponent({
149
157
  ]),
150
158
  getResolvedSchemaType(propSchema) === "object" || Object.keys(getResolvedSchemaProperties(propSchema)).length ? (openBlock(), createBlock(_component_Schema, {
151
159
  key: 0,
152
- schema: propSchema,
153
- depth: __props.depth + 1
154
- }, null, 8, ["schema", "depth"])) : createCommentVNode("", true),
160
+ ancestors: childAncestors,
161
+ depth: __props.depth + 1,
162
+ schema: propSchema
163
+ }, null, 8, ["depth", "schema"])) : createCommentVNode("", true),
155
164
  getResolvedSchemaType(propSchema) === "array" && getResolvedSchemaItems(propSchema) ? (openBlock(), createElementBlock("section", _hoisted_13$1, [_cache[8] || (_cache[8] = createElementVNode("header", null, [createElementVNode("strong", null, "Items:")], -1)), createVNode(_component_Schema, {
156
- schema: getResolvedSchemaItems(propSchema),
157
- depth: __props.depth + 1
158
- }, null, 8, ["schema", "depth"])])) : createCommentVNode("", true)
165
+ ancestors: childAncestors,
166
+ depth: __props.depth + 1,
167
+ schema: getResolvedSchemaItems(propSchema)
168
+ }, null, 8, ["depth", "schema"])])) : createCommentVNode("", true)
159
169
  ]);
160
170
  }), 128))])])) : getSchemaType(unref(resolvedSchema)) === "array" && getSchemaItems(unref(resolvedSchema)) ? (openBlock(), createElementBlock("section", _hoisted_14$1, [
161
171
  _cache[12] || (_cache[12] = createElementVNode("header", null, [createElementVNode("strong", null, "Array of:")], -1)),
162
172
  createElementVNode("section", null, [createVNode(_component_Schema, {
163
- schema: getSchemaItems(unref(resolvedSchema)),
164
- depth: __props.depth + 1
165
- }, null, 8, ["schema", "depth"])]),
173
+ ancestors: childAncestors,
174
+ depth: __props.depth + 1,
175
+ schema: getSchemaItems(unref(resolvedSchema))
176
+ }, null, 8, ["depth", "schema"])]),
166
177
  getSchemaMinItems(unref(resolvedSchema)) !== void 0 || getSchemaMaxItems(unref(resolvedSchema)) !== void 0 || getSchemaUniqueItems(unref(resolvedSchema)) ? (openBlock(), createElementBlock("ul", _hoisted_15$1, [
167
178
  getSchemaMinItems(unref(resolvedSchema)) !== void 0 ? (openBlock(), createElementBlock("li", _hoisted_16$1, [_cache[9] || (_cache[9] = createTextVNode(" Min items: ", -1)), createElementVNode("code", null, toDisplayString(getSchemaMinItems(unref(resolvedSchema))), 1)])) : createCommentVNode("", true),
168
179
  getSchemaMaxItems(unref(resolvedSchema)) !== void 0 ? (openBlock(), createElementBlock("li", _hoisted_17$1, [_cache[10] || (_cache[10] = createTextVNode(" Max items: ", -1)), createElementVNode("code", null, toDisplayString(getSchemaMaxItems(unref(resolvedSchema))), 1)])) : createCommentVNode("", true),
@@ -170,15 +181,55 @@ var Schema_default = /* @__PURE__ */ defineComponent({
170
181
  ])) : createCommentVNode("", true)
171
182
  ])) : (openBlock(), createElementBlock("section", _hoisted_19$1, [createElementVNode("p", null, [
172
183
  createElementVNode("code", null, toDisplayString(getSchemaType(unref(resolvedSchema))), 1),
173
- getSchemaFormat(unref(resolvedSchema)) ? (openBlock(), createElementBlock("span", _hoisted_20, [_cache[13] || (_cache[13] = createTextVNode(", format: ", -1)), createElementVNode("code", null, toDisplayString(getSchemaFormat(unref(resolvedSchema))), 1)])) : createCommentVNode("", true),
174
- getSchemaEnum(unref(resolvedSchema)) ? (openBlock(), createElementBlock("span", _hoisted_21, [_cache[14] || (_cache[14] = createTextVNode(", possible values: ", -1)), createElementVNode("code", null, toDisplayString(formatEnumValues(getSchemaEnum(unref(resolvedSchema)))), 1)])) : createCommentVNode("", true),
175
- getSchemaDefault(unref(resolvedSchema)) !== void 0 ? (openBlock(), createElementBlock("span", _hoisted_22, [_cache[15] || (_cache[15] = createTextVNode(", default: ", -1)), createElementVNode("code", null, toDisplayString(JSON.stringify(getSchemaDefault(unref(resolvedSchema)))), 1)])) : createCommentVNode("", true),
176
- getSchemaDescription(unref(resolvedSchema)) ? (openBlock(), createElementBlock("span", _hoisted_23, " — " + toDisplayString(getSchemaDescription(unref(resolvedSchema))), 1)) : createCommentVNode("", true)
184
+ getSchemaFormat(unref(resolvedSchema)) ? (openBlock(), createElementBlock("span", _hoisted_20$1, [_cache[13] || (_cache[13] = createTextVNode(", format: ", -1)), createElementVNode("code", null, toDisplayString(getSchemaFormat(unref(resolvedSchema))), 1)])) : createCommentVNode("", true),
185
+ getSchemaEnum(unref(resolvedSchema)) ? (openBlock(), createElementBlock("span", _hoisted_21$1, [_cache[14] || (_cache[14] = createTextVNode(", possible values: ", -1)), createElementVNode("code", null, toDisplayString(formatEnumValues(getSchemaEnum(unref(resolvedSchema)))), 1)])) : createCommentVNode("", true),
186
+ getSchemaDefault(unref(resolvedSchema)) !== void 0 ? (openBlock(), createElementBlock("span", _hoisted_22$1, [_cache[15] || (_cache[15] = createTextVNode(", default: ", -1)), createElementVNode("code", null, toDisplayString(JSON.stringify(getSchemaDefault(unref(resolvedSchema)))), 1)])) : createCommentVNode("", true),
187
+ getSchemaDescription(unref(resolvedSchema)) ? (openBlock(), createElementBlock("span", _hoisted_23$1, " — " + toDisplayString(getSchemaDescription(unref(resolvedSchema))), 1)) : createCommentVNode("", true)
177
188
  ])]))])) : createCommentVNode("", true);
178
189
  };
179
190
  }
180
191
  });
181
192
  //#endregion
193
+ //#region src/components/Security.vue?vue&type=script&setup=true&lang.ts
194
+ var _hoisted_1$2 = { key: 0 };
195
+ var _hoisted_2$2 = { key: 0 };
196
+ var _hoisted_3$2 = { key: 0 };
197
+ var _hoisted_4$2 = { key: 1 };
198
+ var _hoisted_5$1 = { key: 2 };
199
+ //#endregion
200
+ //#region src/components/Security.vue
201
+ var Security_default = /* @__PURE__ */ defineComponent({
202
+ __name: "Security",
203
+ props: {
204
+ requirements: {},
205
+ schemes: {}
206
+ },
207
+ setup(__props) {
208
+ const schemeContent = computed(() => Object.fromEntries(Object.entries(__props.schemes ?? {}).map(([name, reference]) => {
209
+ const scheme = getResolvedRef(reference);
210
+ return [name, {
211
+ json: JSON.stringify(scheme, null, 2),
212
+ description: scheme?.description
213
+ }];
214
+ })));
215
+ return (_ctx, _cache) => {
216
+ return __props.requirements ? (openBlock(), createElementBlock("section", _hoisted_1$2, [
217
+ _cache[0] || (_cache[0] = createElementVNode("h4", null, "Authentication", -1)),
218
+ !__props.requirements.length ? (openBlock(), createElementBlock("p", _hoisted_2$2, "No authentication required.")) : createCommentVNode("", true),
219
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.requirements, (requirement, index) => {
220
+ return openBlock(), createElementBlock(Fragment, { key: index }, [index ? (openBlock(), createElementBlock("p", _hoisted_3$2, "Or:")) : createCommentVNode("", true), !Object.keys(requirement).length ? (openBlock(), createElementBlock("p", _hoisted_4$2, "No authentication required.")) : (openBlock(), createElementBlock("ul", _hoisted_5$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(requirement, (scopes, name) => {
221
+ return openBlock(), createElementBlock("li", { key: name }, [
222
+ createElementVNode("strong", null, toDisplayString(name), 1),
223
+ scopes?.length ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" Scopes: " + toDisplayString(scopes.join(", ")), 1)], 64)) : createCommentVNode("", true),
224
+ schemeContent.value[name] ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("pre", null, [createElementVNode("code", null, toDisplayString(schemeContent.value[name].json), 1)]), createVNode(unref(ScalarMarkdown), { value: schemeContent.value[name].description }, null, 8, ["value"])], 64)) : createCommentVNode("", true)
225
+ ]);
226
+ }), 128))]))], 64);
227
+ }), 128))
228
+ ])) : createCommentVNode("", true);
229
+ };
230
+ }
231
+ });
232
+ //#endregion
182
233
  //#region src/components/XmlOrJson.vue?vue&type=script&setup=true&lang.ts
183
234
  var _hoisted_1$1 = { key: 0 };
184
235
  var _hoisted_2$1 = { class: "language-xml" };
@@ -204,25 +255,32 @@ var XmlOrJson_default = /* @__PURE__ */ defineComponent({
204
255
  });
205
256
  //#endregion
206
257
  //#region src/components/MarkdownReference.vue?vue&type=script&setup=true&lang.ts
207
- var _hoisted_1 = { key: 1 };
208
- var _hoisted_2 = { key: 0 };
258
+ var _hoisted_1 = { key: 0 };
259
+ var _hoisted_2 = ["href"];
209
260
  var _hoisted_3 = { key: 1 };
210
- var _hoisted_4 = { key: 2 };
211
- var _hoisted_5 = { key: 0 };
212
- var _hoisted_6 = { key: 1 };
213
- var _hoisted_7 = { key: 0 };
214
- var _hoisted_8 = { key: 0 };
215
- var _hoisted_9 = { key: 1 };
216
- var _hoisted_10 = { key: 2 };
217
- var _hoisted_11 = { key: 3 };
218
- var _hoisted_12 = { key: 1 };
219
- var _hoisted_13 = { key: 2 };
220
- var _hoisted_14 = { key: 3 };
221
- var _hoisted_15 = { key: 2 };
222
- var _hoisted_16 = { key: 3 };
261
+ var _hoisted_4 = ["href"];
262
+ var _hoisted_5 = ["href"];
263
+ var _hoisted_6 = { key: 2 };
264
+ var _hoisted_7 = ["href"];
265
+ var _hoisted_8 = { key: 1 };
266
+ var _hoisted_9 = { key: 0 };
267
+ var _hoisted_10 = { key: 1 };
268
+ var _hoisted_11 = { key: 2 };
269
+ var _hoisted_12 = ["href"];
270
+ var _hoisted_13 = { key: 0 };
271
+ var _hoisted_14 = { key: 0 };
272
+ var _hoisted_15 = { key: 1 };
273
+ var _hoisted_16 = { key: 0 };
223
274
  var _hoisted_17 = { key: 0 };
224
275
  var _hoisted_18 = { key: 1 };
225
- var _hoisted_19 = { key: 4 };
276
+ var _hoisted_19 = { key: 0 };
277
+ var _hoisted_20 = { key: 1 };
278
+ var _hoisted_21 = { key: 2 };
279
+ var _hoisted_22 = { key: 3 };
280
+ var _hoisted_23 = { key: 2 };
281
+ var _hoisted_24 = { key: 0 };
282
+ var _hoisted_25 = { key: 3 };
283
+ var _hoisted_26 = { key: 3 };
226
284
  //#endregion
227
285
  //#region src/components/MarkdownReference.vue
228
286
  var MarkdownReference_default = /* @__PURE__ */ defineComponent({
@@ -230,7 +288,11 @@ var MarkdownReference_default = /* @__PURE__ */ defineComponent({
230
288
  props: { content: {} },
231
289
  setup(__props) {
232
290
  const resolveRefAs = (reference) => {
233
- const resolved = getResolvedRef(reference);
291
+ const resolved = getResolvedRef(reference, (node) => {
292
+ const resolved = mergeSiblingReferences(node);
293
+ if (resolved && typeof resolved === "object") Reflect.deleteProperty(resolved, "$ref");
294
+ return resolved;
295
+ });
234
296
  return resolved && typeof resolved === "object" ? resolved : null;
235
297
  };
236
298
  const resolveOperation = (operation) => resolveRefAs(operation);
@@ -257,8 +319,7 @@ var MarkdownReference_default = /* @__PURE__ */ defineComponent({
257
319
  }
258
320
  return Array.from(parameters.values());
259
321
  };
260
- const operations = computed(() => {
261
- const paths = __props.content?.paths ?? {};
322
+ const getEntries = (paths) => {
262
323
  const entries = [];
263
324
  for (const [path, pathItemRef] of Object.entries(paths)) {
264
325
  const resolvedPathItem = getResolvedPathItem(pathItemRef);
@@ -279,6 +340,8 @@ var MarkdownReference_default = /* @__PURE__ */ defineComponent({
279
340
  path,
280
341
  method,
281
342
  operation: resolvedOperation,
343
+ servers: resolvedOperation.servers ?? resolvedPathItem?.servers ?? __props.content.servers,
344
+ security: resolvedOperation.security ?? __props.content.security,
282
345
  parameters,
283
346
  requestBody,
284
347
  responses
@@ -286,21 +349,16 @@ var MarkdownReference_default = /* @__PURE__ */ defineComponent({
286
349
  });
287
350
  }
288
351
  return entries;
289
- });
290
- const webhooks = computed(() => {
291
- const webhookItems = __props.content?.webhooks ?? {};
292
- const entries = [];
293
- for (const [name, pathItemRef] of Object.entries(webhookItems)) forEachPathItemOperation(pathItemRef, (method, operation) => {
294
- const resolvedOperation = resolveOperation(operation);
295
- if (!resolvedOperation) return;
296
- entries.push({
297
- name,
298
- method,
299
- operation: resolvedOperation
300
- });
301
- });
302
- return entries;
303
- });
352
+ };
353
+ const groups = computed(() => [{
354
+ title: "Operations",
355
+ webhook: false,
356
+ entries: getEntries(__props.content.paths ?? {})
357
+ }, {
358
+ title: "Webhooks",
359
+ webhook: true,
360
+ entries: getEntries(__props.content.webhooks ?? {})
361
+ }]);
304
362
  const componentSchemas = computed(() => {
305
363
  const schemas = __props.content?.components?.schemas ?? {};
306
364
  return Object.entries(schemas).flatMap(([name, schema]) => {
@@ -315,148 +373,183 @@ var MarkdownReference_default = /* @__PURE__ */ defineComponent({
315
373
  const getSchemaView = (schema) => schema;
316
374
  return (_ctx, _cache) => {
317
375
  return openBlock(), createElementBlock("section", null, [
318
- createElementVNode("header", null, [createElementVNode("h1", null, toDisplayString(__props.content?.info?.title), 1), createElementVNode("ul", null, [createElementVNode("li", null, [
319
- _cache[0] || (_cache[0] = createElementVNode("strong", null, "OpenAPI Version:", -1)),
320
- _cache[1] || (_cache[1] = createTextVNode("\xA0", -1)),
321
- createElementVNode("code", null, toDisplayString(__props.content?.openapi), 1)
322
- ]), createElementVNode("li", null, [
323
- _cache[2] || (_cache[2] = createElementVNode("strong", null, "API Version:", -1)),
324
- _cache[3] || (_cache[3] = createTextVNode("\xA0", -1)),
325
- createElementVNode("code", null, toDisplayString(__props.content?.info?.version), 1)
326
- ])])]),
376
+ createElementVNode("header", null, [createElementVNode("h1", null, toDisplayString(__props.content?.info?.title), 1), createElementVNode("ul", null, [
377
+ createElementVNode("li", null, [
378
+ _cache[0] || (_cache[0] = createElementVNode("strong", null, "OpenAPI Version:", -1)),
379
+ _cache[1] || (_cache[1] = createTextVNode("\xA0", -1)),
380
+ createElementVNode("code", null, toDisplayString(__props.content?.openapi), 1)
381
+ ]),
382
+ createElementVNode("li", null, [
383
+ _cache[2] || (_cache[2] = createElementVNode("strong", null, "API Version:", -1)),
384
+ _cache[3] || (_cache[3] = createTextVNode("\xA0", -1)),
385
+ createElementVNode("code", null, toDisplayString(__props.content?.info?.version), 1)
386
+ ]),
387
+ __props.content.info.termsOfService ? (openBlock(), createElementBlock("li", _hoisted_1, [_cache[4] || (_cache[4] = createElementVNode("strong", null, "Terms of service:", -1)), createElementVNode("a", { href: __props.content.info.termsOfService }, toDisplayString(__props.content.info.termsOfService), 9, _hoisted_2)])) : createCommentVNode("", true),
388
+ __props.content.info.contact ? (openBlock(), createElementBlock("li", _hoisted_3, [
389
+ _cache[5] || (_cache[5] = createElementVNode("strong", null, "Contact:", -1)),
390
+ createTextVNode(" " + toDisplayString(__props.content.info.contact.name) + " ", 1),
391
+ __props.content.info.contact.url ? (openBlock(), createElementBlock("a", {
392
+ key: 0,
393
+ href: __props.content.info.contact.url
394
+ }, toDisplayString(__props.content.info.contact.url), 9, _hoisted_4)) : createCommentVNode("", true),
395
+ __props.content.info.contact.email ? (openBlock(), createElementBlock("a", {
396
+ key: 1,
397
+ href: `mailto:${__props.content.info.contact.email}`
398
+ }, toDisplayString(__props.content.info.contact.email), 9, _hoisted_5)) : createCommentVNode("", true)
399
+ ])) : createCommentVNode("", true),
400
+ __props.content.info.license ? (openBlock(), createElementBlock("li", _hoisted_6, [_cache[6] || (_cache[6] = createElementVNode("strong", null, "License:", -1)), __props.content.info.license.url ? (openBlock(), createElementBlock("a", {
401
+ key: 0,
402
+ href: __props.content.info.license.url
403
+ }, toDisplayString(__props.content.info.license.name), 9, _hoisted_7)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(__props.content.info.license.name), 1)], 64))])) : createCommentVNode("", true)
404
+ ])]),
327
405
  __props.content?.info?.description ? (openBlock(), createBlock(unref(ScalarMarkdown), {
328
406
  key: 0,
329
407
  value: __props.content?.info?.description
330
408
  }, null, 8, ["value"])) : createCommentVNode("", true),
331
- __props.content?.servers?.length ? (openBlock(), createElementBlock("section", _hoisted_1, [_cache[10] || (_cache[10] = createElementVNode("h2", null, "Servers", -1)), createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.content.servers, (server) => {
409
+ __props.content?.servers?.length ? (openBlock(), createElementBlock("section", _hoisted_8, [_cache[13] || (_cache[13] = createElementVNode("h2", null, "Servers", -1)), createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.content.servers, (server) => {
332
410
  return openBlock(), createElementBlock("li", { key: server.url }, [
333
- _cache[8] || (_cache[8] = createElementVNode("strong", null, "URL:", -1)),
334
- _cache[9] || (_cache[9] = createTextVNode("\xA0", -1)),
411
+ _cache[11] || (_cache[11] = createElementVNode("strong", null, "URL:", -1)),
412
+ _cache[12] || (_cache[12] = createTextVNode("\xA0", -1)),
335
413
  createElementVNode("code", null, toDisplayString(server.url), 1),
336
- createElementVNode("ul", null, [server.description ? (openBlock(), createElementBlock("li", _hoisted_2, [_cache[4] || (_cache[4] = createElementVNode("strong", null, "Description:", -1)), createTextVNode("\xA0" + toDisplayString(server.description), 1)])) : createCommentVNode("", true), server.variables && Object.keys(server.variables).length ? (openBlock(), createElementBlock("li", _hoisted_3, [_cache[7] || (_cache[7] = createElementVNode("strong", null, "Variables:", -1)), createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(server.variables, (variable, name) => {
414
+ createElementVNode("ul", null, [server.description ? (openBlock(), createElementBlock("li", _hoisted_9, [_cache[7] || (_cache[7] = createElementVNode("strong", null, "Description:", -1)), createTextVNode("\xA0" + toDisplayString(server.description), 1)])) : createCommentVNode("", true), server.variables && Object.keys(server.variables).length ? (openBlock(), createElementBlock("li", _hoisted_10, [_cache[10] || (_cache[10] = createElementVNode("strong", null, "Variables:", -1)), createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(server.variables, (variable, name) => {
337
415
  return openBlock(), createElementBlock("li", { key: name }, [
338
416
  createElementVNode("code", null, toDisplayString(name), 1),
339
- _cache[5] || (_cache[5] = createTextVNode(" (default: ", -1)),
417
+ _cache[8] || (_cache[8] = createTextVNode(" (default: ", -1)),
340
418
  createElementVNode("code", null, toDisplayString(variable.default), 1),
341
- _cache[6] || (_cache[6] = createTextVNode(")", -1)),
419
+ _cache[9] || (_cache[9] = createTextVNode(")", -1)),
342
420
  variable.description ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(": " + toDisplayString(variable.description), 1)], 64)) : createCommentVNode("", true)
343
421
  ]);
344
422
  }), 128))])])) : createCommentVNode("", true)])
345
423
  ]);
346
424
  }), 128))])])) : createCommentVNode("", true),
347
- operations.value.length ? (openBlock(), createElementBlock("section", _hoisted_4, [_cache[30] || (_cache[30] = createElementVNode("h2", null, "Operations", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(operations.value, (entry) => {
348
- return openBlock(), createElementBlock("section", { key: `${entry.method}:${entry.path}` }, [
349
- createElementVNode("header", null, [createElementVNode("h3", null, [entry.operation.summary ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(entry.operation.summary), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(entry.method.toString().toUpperCase()) + " " + toDisplayString(entry.path), 1)], 64)), entry.operation["x-scalar-stability"] ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [createTextVNode(" (" + toDisplayString(entry.operation["x-scalar-stability"]) + ") ", 1)], 64)) : entry.operation.deprecated ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [createTextVNode(" ⚠️ Deprecated ")], 64)) : createCommentVNode("", true)])]),
350
- createElementVNode("ul", null, [
351
- createElementVNode("li", null, [
352
- _cache[11] || (_cache[11] = createElementVNode("strong", null, "Method:", -1)),
353
- _cache[12] || (_cache[12] = createTextVNode("\xA0", -1)),
354
- createElementVNode("code", null, toDisplayString(entry.method.toString().toUpperCase()), 1)
355
- ]),
356
- createElementVNode("li", null, [
357
- _cache[13] || (_cache[13] = createElementVNode("strong", null, "Path:", -1)),
358
- _cache[14] || (_cache[14] = createTextVNode("\xA0", -1)),
359
- createElementVNode("code", null, toDisplayString(entry.path), 1)
360
- ]),
361
- entry.operation.tags ? (openBlock(), createElementBlock("li", _hoisted_5, [_cache[15] || (_cache[15] = createElementVNode("strong", null, "Tags:", -1)), createTextVNode("\xA0" + toDisplayString(entry.operation.tags.join(", ")), 1)])) : createCommentVNode("", true),
362
- entry.operation["x-scalar-stability"] ? (openBlock(), createElementBlock("li", _hoisted_6, [_cache[16] || (_cache[16] = createElementVNode("strong", null, "Stability:", -1)), createTextVNode("\xA0" + toDisplayString(entry.operation["x-scalar-stability"]), 1)])) : createCommentVNode("", true)
363
- ]),
364
- createVNode(unref(ScalarMarkdown), { value: entry.operation.description }, null, 8, ["value"]),
365
- entry.parameters.length ? (openBlock(), createElementBlock("section", _hoisted_7, [_cache[25] || (_cache[25] = createElementVNode("h4", null, "Parameters", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(entry.parameters, (parameter) => {
366
- return openBlock(), createElementBlock("section", { key: `${parameter.in}:${parameter.name}` }, [
367
- createElementVNode("h5", null, [
368
- createElementVNode("code", null, toDisplayString(parameter.name), 1),
369
- parameter.required ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" required")], 64)) : createCommentVNode("", true),
370
- parameter.deprecated ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" deprecated")], 64)) : createCommentVNode("", true)
425
+ createVNode(Security_default, {
426
+ requirements: __props.content.security,
427
+ schemes: __props.content.components?.securitySchemes
428
+ }, null, 8, ["requirements", "schemes"]),
429
+ __props.content.tags?.length ? (openBlock(), createElementBlock("section", _hoisted_11, [_cache[14] || (_cache[14] = createElementVNode("h2", null, "Tags", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.content.tags, (tag) => {
430
+ return openBlock(), createElementBlock("section", { key: tag.name }, [
431
+ createElementVNode("h3", null, toDisplayString(tag.name), 1),
432
+ createVNode(unref(ScalarMarkdown), { value: tag.description }, null, 8, ["value"]),
433
+ tag.externalDocs ? (openBlock(), createElementBlock("a", {
434
+ key: 0,
435
+ href: tag.externalDocs.url
436
+ }, toDisplayString(tag.externalDocs.description ?? tag.externalDocs.url), 9, _hoisted_12)) : createCommentVNode("", true)
437
+ ]);
438
+ }), 128))])) : createCommentVNode("", true),
439
+ (openBlock(true), createElementBlock(Fragment, null, renderList(groups.value, (group) => {
440
+ return openBlock(), createElementBlock(Fragment, { key: group.title }, [group.entries.length ? (openBlock(), createElementBlock("section", _hoisted_13, [createElementVNode("h2", null, toDisplayString(group.title), 1), (openBlock(true), createElementBlock(Fragment, null, renderList(group.entries, (entry) => {
441
+ return openBlock(), createElementBlock("section", { key: `${entry.method}:${entry.path}` }, [
442
+ createElementVNode("header", null, [createElementVNode("h3", null, [entry.operation.summary ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(entry.operation.summary), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(entry.method.toString().toUpperCase()) + " " + toDisplayString(entry.path), 1)], 64)), entry.operation["x-scalar-stability"] ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [createTextVNode(" (" + toDisplayString(entry.operation["x-scalar-stability"]) + ") ", 1)], 64)) : entry.operation.deprecated ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [createTextVNode(" ⚠️ Deprecated ")], 64)) : createCommentVNode("", true)])]),
443
+ createElementVNode("ul", null, [
444
+ createElementVNode("li", null, [
445
+ _cache[15] || (_cache[15] = createElementVNode("strong", null, "Method:", -1)),
446
+ _cache[16] || (_cache[16] = createTextVNode("\xA0", -1)),
447
+ createElementVNode("code", null, toDisplayString(entry.method.toString().toUpperCase()), 1)
371
448
  ]),
372
- createElementVNode("ul", null, [
373
- createElementVNode("li", null, [
374
- _cache[17] || (_cache[17] = createElementVNode("strong", null, "In:", -1)),
375
- _cache[18] || (_cache[18] = createTextVNode("\xA0", -1)),
376
- createElementVNode("code", null, toDisplayString(parameter.in), 1)
377
- ]),
378
- parameter.style ? (openBlock(), createElementBlock("li", _hoisted_8, [
379
- _cache[19] || (_cache[19] = createElementVNode("strong", null, "Style:", -1)),
380
- _cache[20] || (_cache[20] = createTextVNode("\xA0", -1)),
381
- createElementVNode("code", null, toDisplayString(parameter.style), 1)
382
- ])) : createCommentVNode("", true),
383
- typeof parameter.explode === "boolean" ? (openBlock(), createElementBlock("li", _hoisted_9, [
384
- _cache[21] || (_cache[21] = createElementVNode("strong", null, "Explode:", -1)),
385
- _cache[22] || (_cache[22] = createTextVNode("\xA0", -1)),
386
- createElementVNode("code", null, toDisplayString(parameter.explode), 1)
387
- ])) : createCommentVNode("", true),
388
- parameter.allowEmptyValue ? (openBlock(), createElementBlock("li", _hoisted_10, [..._cache[23] || (_cache[23] = [createElementVNode("strong", null, "Allow Empty Value:", -1), createTextVNode("\xA0true", -1)])])) : createCommentVNode("", true),
389
- parameter.allowReserved ? (openBlock(), createElementBlock("li", _hoisted_11, [..._cache[24] || (_cache[24] = [createElementVNode("strong", null, "Allow Reserved:", -1), createTextVNode("\xA0true", -1)])])) : createCommentVNode("", true)
449
+ createElementVNode("li", null, [
450
+ createElementVNode("strong", null, toDisplayString(group.webhook ? "Webhook:" : "Path:"), 1),
451
+ _cache[17] || (_cache[17] = createTextVNode("\xA0", -1)),
452
+ createElementVNode("code", null, toDisplayString(entry.path), 1)
390
453
  ]),
391
- parameter.description ? (openBlock(), createBlock(unref(ScalarMarkdown), {
392
- key: 0,
393
- value: parameter.description
394
- }, null, 8, ["value"])) : createCommentVNode("", true),
395
- resolveSchema(parameter.schema) ? (openBlock(), createBlock(Schema_default, {
396
- key: 1,
397
- schema: resolveSchema(parameter.schema)
398
- }, null, 8, ["schema"])) : createCommentVNode("", true),
399
- parameter.content ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(parameter.content, (parameterContent, mediaType) => {
400
- return openBlock(), createElementBlock(Fragment, { key: mediaType }, [createElementVNode("h6", null, "Content-Type: " + toDisplayString(mediaType), 1), resolveSchema(parameterContent.schema) ? (openBlock(), createBlock(Schema_default, {
454
+ entry.operation.tags ? (openBlock(), createElementBlock("li", _hoisted_14, [_cache[18] || (_cache[18] = createElementVNode("strong", null, "Tags:", -1)), createTextVNode("\xA0" + toDisplayString(entry.operation.tags.join(", ")), 1)])) : createCommentVNode("", true),
455
+ entry.operation["x-scalar-stability"] ? (openBlock(), createElementBlock("li", _hoisted_15, [_cache[19] || (_cache[19] = createElementVNode("strong", null, "Stability:", -1)), createTextVNode("\xA0" + toDisplayString(entry.operation["x-scalar-stability"]), 1)])) : createCommentVNode("", true)
456
+ ]),
457
+ createVNode(unref(ScalarMarkdown), { value: entry.operation.description }, null, 8, ["value"]),
458
+ entry.servers?.length ? (openBlock(), createElementBlock("section", _hoisted_16, [_cache[20] || (_cache[20] = createElementVNode("h4", null, "Effective servers", -1)), createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(entry.servers, (server) => {
459
+ return openBlock(), createElementBlock("li", { key: server.url }, [
460
+ createElementVNode("code", null, toDisplayString(server.url), 1),
461
+ createVNode(unref(ScalarMarkdown), { value: server.description }, null, 8, ["value"]),
462
+ server.variables ? (openBlock(), createElementBlock("ul", _hoisted_17, [(openBlock(true), createElementBlock(Fragment, null, renderList(server.variables, (variable, name) => {
463
+ return openBlock(), createElementBlock("li", { key: name }, [createTextVNode(toDisplayString(name) + ": ", 1), createElementVNode("code", null, toDisplayString(variable.default), 1)]);
464
+ }), 128))])) : createCommentVNode("", true)
465
+ ]);
466
+ }), 128))])])) : createCommentVNode("", true),
467
+ createVNode(Security_default, {
468
+ requirements: entry.security,
469
+ schemes: __props.content.components?.securitySchemes
470
+ }, null, 8, ["requirements", "schemes"]),
471
+ entry.parameters.length ? (openBlock(), createElementBlock("section", _hoisted_18, [_cache[29] || (_cache[29] = createElementVNode("h4", null, "Parameters", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(entry.parameters, (parameter) => {
472
+ return openBlock(), createElementBlock("section", { key: `${parameter.in}:${parameter.name}` }, [
473
+ createElementVNode("h5", null, [
474
+ createElementVNode("code", null, toDisplayString(parameter.name), 1),
475
+ parameter.required ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" required")], 64)) : createCommentVNode("", true),
476
+ parameter.deprecated ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" deprecated ")], 64)) : createCommentVNode("", true)
477
+ ]),
478
+ createElementVNode("ul", null, [
479
+ createElementVNode("li", null, [
480
+ _cache[21] || (_cache[21] = createElementVNode("strong", null, "In:", -1)),
481
+ _cache[22] || (_cache[22] = createTextVNode("\xA0", -1)),
482
+ createElementVNode("code", null, toDisplayString(parameter.in), 1)
483
+ ]),
484
+ parameter.style ? (openBlock(), createElementBlock("li", _hoisted_19, [
485
+ _cache[23] || (_cache[23] = createElementVNode("strong", null, "Style:", -1)),
486
+ _cache[24] || (_cache[24] = createTextVNode("\xA0", -1)),
487
+ createElementVNode("code", null, toDisplayString(parameter.style), 1)
488
+ ])) : createCommentVNode("", true),
489
+ typeof parameter.explode === "boolean" ? (openBlock(), createElementBlock("li", _hoisted_20, [
490
+ _cache[25] || (_cache[25] = createElementVNode("strong", null, "Explode:", -1)),
491
+ _cache[26] || (_cache[26] = createTextVNode("\xA0", -1)),
492
+ createElementVNode("code", null, toDisplayString(parameter.explode), 1)
493
+ ])) : createCommentVNode("", true),
494
+ parameter.allowEmptyValue ? (openBlock(), createElementBlock("li", _hoisted_21, [..._cache[27] || (_cache[27] = [createElementVNode("strong", null, "Allow Empty Value:", -1), createTextVNode("\xA0true", -1)])])) : createCommentVNode("", true),
495
+ parameter.allowReserved ? (openBlock(), createElementBlock("li", _hoisted_22, [..._cache[28] || (_cache[28] = [createElementVNode("strong", null, "Allow Reserved:", -1), createTextVNode("\xA0true", -1)])])) : createCommentVNode("", true)
496
+ ]),
497
+ parameter.description ? (openBlock(), createBlock(unref(ScalarMarkdown), {
401
498
  key: 0,
402
- schema: resolveSchema(parameterContent.schema)
403
- }, null, 8, ["schema"])) : createCommentVNode("", true)], 64);
404
- }), 128)) : createCommentVNode("", true)
405
- ]);
406
- }), 128))])) : createCommentVNode("", true),
407
- entry.requestBody?.content ? (openBlock(), createElementBlock("section", _hoisted_12, [_cache[27] || (_cache[27] = createElementVNode("h4", null, "Request Body", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(entry.requestBody.content, (bodyContent, mediaType) => {
408
- return openBlock(), createElementBlock(Fragment, { key: mediaType }, [createElementVNode("h5", null, "Content-Type: " + toDisplayString(mediaType), 1), resolveSchema(bodyContent.schema) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
409
- createVNode(Schema_default, { schema: resolveSchema(bodyContent.schema) }, null, 8, ["schema"]),
410
- _cache[26] || (_cache[26] = createElementVNode("p", null, [createElementVNode("strong", null, "Example:")], -1)),
411
- createVNode(XmlOrJson_default, {
412
- modelValue: unref(getExampleFromSchema)(resolveSchema(bodyContent.schema), { xml: mediaType?.toString().includes("xml") }),
413
- xml: mediaType?.toString().includes("xml")
414
- }, null, 8, ["modelValue", "xml"])
415
- ], 64)) : createCommentVNode("", true)], 64);
416
- }), 128))])) : createCommentVNode("", true),
417
- entry.responses.length ? (openBlock(), createElementBlock("section", _hoisted_13, [_cache[29] || (_cache[29] = createElementVNode("h4", null, "Responses", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(entry.responses, (entryResponse) => {
418
- return openBlock(), createElementBlock("section", { key: entryResponse.statusCode }, [createElementVNode("header", null, [createElementVNode("h5", null, [createTextVNode(" Status: " + toDisplayString(entryResponse.statusCode) + " ", 1), entryResponse.response.description ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(entryResponse.response.description), 1)], 64)) : createCommentVNode("", true)])]), entryResponse.response.content ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(entryResponse.response.content, (responseContent, mediaType) => {
419
- return openBlock(), createElementBlock("section", { key: mediaType }, [createElementVNode("h6", null, "Content-Type: " + toDisplayString(mediaType), 1), resolveSchema(responseContent.schema) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
420
- createVNode(Schema_default, { schema: resolveSchema(responseContent.schema) }, null, 8, ["schema"]),
421
- _cache[28] || (_cache[28] = createElementVNode("p", null, [createElementVNode("strong", null, "Example:")], -1)),
422
- createVNode(XmlOrJson_default, {
423
- modelValue: unref(getExampleFromSchema)(resolveSchema(responseContent.schema), { xml: mediaType?.toString().includes("xml") }),
424
- xml: mediaType?.toString().includes("xml")
425
- }, null, 8, ["modelValue", "xml"])
426
- ], 64)) : createCommentVNode("", true)]);
427
- }), 128)) : createCommentVNode("", true)]);
428
- }), 128))])) : createCommentVNode("", true)
429
- ]);
430
- }), 128))])) : createCommentVNode("", true),
431
- webhooks.value.length ? (openBlock(), createElementBlock("section", _hoisted_14, [_cache[35] || (_cache[35] = createElementVNode("h2", null, "Webhooks", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(webhooks.value, (webhook) => {
432
- return openBlock(), createElementBlock("section", { key: `${webhook.name}:${webhook.method}` }, [
433
- createElementVNode("header", null, [createElementVNode("h3", null, [webhook.operation.summary ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(webhook.operation.summary), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(webhook.name), 1)], 64)), webhook.operation["x-scalar-stability"] ? (openBlock(), createElementBlock("span", _hoisted_15, "(" + toDisplayString(webhook.operation["x-scalar-stability"]) + ")", 1)) : webhook.operation.deprecated ? (openBlock(), createElementBlock("span", _hoisted_16, "⚠️ Deprecated")) : createCommentVNode("", true)])]),
434
- createElementVNode("ul", null, [
435
- createElementVNode("li", null, [_cache[31] || (_cache[31] = createElementVNode("strong", null, "Method:", -1)), createElementVNode("code", null, toDisplayString(webhook.method.toString().toUpperCase()), 1)]),
436
- createElementVNode("li", null, [_cache[32] || (_cache[32] = createElementVNode("strong", null, "Path:", -1)), createElementVNode("code", null, "/webhooks/" + toDisplayString(webhook.name), 1)]),
437
- webhook.operation.tags ? (openBlock(), createElementBlock("li", _hoisted_17, [_cache[33] || (_cache[33] = createElementVNode("strong", null, "Tags:", -1)), createTextVNode(" " + toDisplayString(webhook.operation.tags.join(", ")), 1)])) : createCommentVNode("", true),
438
- webhook.operation.deprecated ? (openBlock(), createElementBlock("li", _hoisted_18, [..._cache[34] || (_cache[34] = [createElementVNode("strong", null, "Deprecated", -1)])])) : createCommentVNode("", true)
439
- ]),
440
- createVNode(unref(ScalarMarkdown), { value: webhook.operation.description }, null, 8, ["value"])
441
- ]);
442
- }), 128))])) : createCommentVNode("", true),
443
- componentSchemas.value.length ? (openBlock(), createElementBlock("section", _hoisted_19, [_cache[38] || (_cache[38] = createElementVNode("h2", null, "Schemas", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(componentSchemas.value, (entry) => {
499
+ value: parameter.description
500
+ }, null, 8, ["value"])) : createCommentVNode("", true),
501
+ resolveSchema(parameter.schema) ? (openBlock(), createBlock(Schema_default, {
502
+ key: 1,
503
+ schema: resolveSchema(parameter.schema)
504
+ }, null, 8, ["schema"])) : createCommentVNode("", true),
505
+ parameter.content ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(parameter.content, (parameterContent, mediaType) => {
506
+ return openBlock(), createElementBlock(Fragment, { key: mediaType }, [createElementVNode("h6", null, "Content-Type: " + toDisplayString(mediaType), 1), resolveSchema(parameterContent.schema) ? (openBlock(), createBlock(Schema_default, {
507
+ key: 0,
508
+ schema: resolveSchema(parameterContent.schema)
509
+ }, null, 8, ["schema"])) : createCommentVNode("", true)], 64);
510
+ }), 128)) : createCommentVNode("", true)
511
+ ]);
512
+ }), 128))])) : createCommentVNode("", true),
513
+ entry.requestBody?.content ? (openBlock(), createElementBlock("section", _hoisted_23, [
514
+ _cache[32] || (_cache[32] = createElementVNode("h4", null, "Request Body", -1)),
515
+ createVNode(unref(ScalarMarkdown), { value: entry.requestBody.description }, null, 8, ["value"]),
516
+ entry.requestBody.required ? (openBlock(), createElementBlock("p", _hoisted_24, [..._cache[30] || (_cache[30] = [createElementVNode("strong", null, "Required:", -1), createTextVNode(" true ", -1)])])) : createCommentVNode("", true),
517
+ (openBlock(true), createElementBlock(Fragment, null, renderList(entry.requestBody.content, (bodyContent, mediaType) => {
518
+ return openBlock(), createElementBlock(Fragment, { key: mediaType }, [createElementVNode("h5", null, "Content-Type: " + toDisplayString(mediaType), 1), resolveSchema(bodyContent.schema) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
519
+ createVNode(Schema_default, { schema: resolveSchema(bodyContent.schema) }, null, 8, ["schema"]),
520
+ _cache[31] || (_cache[31] = createElementVNode("p", null, [createElementVNode("strong", null, "Example:")], -1)),
521
+ createVNode(XmlOrJson_default, {
522
+ modelValue: unref(getExampleFromSchema)(resolveSchema(bodyContent.schema), { xml: mediaType?.toString().includes("xml") }),
523
+ xml: mediaType?.toString().includes("xml")
524
+ }, null, 8, ["modelValue", "xml"])
525
+ ], 64)) : createCommentVNode("", true)], 64);
526
+ }), 128))
527
+ ])) : createCommentVNode("", true),
528
+ entry.responses.length ? (openBlock(), createElementBlock("section", _hoisted_25, [_cache[34] || (_cache[34] = createElementVNode("h4", null, "Responses", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(entry.responses, (entryResponse) => {
529
+ return openBlock(), createElementBlock("section", { key: entryResponse.statusCode }, [createElementVNode("header", null, [createElementVNode("h5", null, [createTextVNode(" Status: " + toDisplayString(entryResponse.statusCode) + " ", 1), entryResponse.response.description ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(entryResponse.response.description), 1)], 64)) : createCommentVNode("", true)])]), entryResponse.response.content ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(entryResponse.response.content, (responseContent, mediaType) => {
530
+ return openBlock(), createElementBlock("section", { key: mediaType }, [createElementVNode("h6", null, "Content-Type: " + toDisplayString(mediaType), 1), resolveSchema(responseContent.schema) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
531
+ createVNode(Schema_default, { schema: resolveSchema(responseContent.schema) }, null, 8, ["schema"]),
532
+ _cache[33] || (_cache[33] = createElementVNode("p", null, [createElementVNode("strong", null, "Example:")], -1)),
533
+ createVNode(XmlOrJson_default, {
534
+ modelValue: unref(getExampleFromSchema)(resolveSchema(responseContent.schema), { xml: mediaType?.toString().includes("xml") }),
535
+ xml: mediaType?.toString().includes("xml")
536
+ }, null, 8, ["modelValue", "xml"])
537
+ ], 64)) : createCommentVNode("", true)]);
538
+ }), 128)) : createCommentVNode("", true)]);
539
+ }), 128))])) : createCommentVNode("", true)
540
+ ]);
541
+ }), 128))])) : createCommentVNode("", true)], 64);
542
+ }), 128)),
543
+ componentSchemas.value.length ? (openBlock(), createElementBlock("section", _hoisted_26, [_cache[37] || (_cache[37] = createElementVNode("h2", null, "Schemas", -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(componentSchemas.value, (entry) => {
444
544
  return openBlock(), createElementBlock("section", { key: entry.name }, [
445
545
  createElementVNode("header", null, [createElementVNode("h3", null, toDisplayString(getSchemaView(entry.schema).title ?? entry.name), 1)]),
446
- createElementVNode("ul", null, [createElementVNode("li", null, [_cache[36] || (_cache[36] = createElementVNode("strong", null, "Type:", -1)), createElementVNode("code", null, toDisplayString(getSchemaView(entry.schema).type), 1)])]),
546
+ createElementVNode("ul", null, [createElementVNode("li", null, [_cache[35] || (_cache[35] = createElementVNode("strong", null, "Type:", -1)), createElementVNode("code", null, toDisplayString(getSchemaView(entry.schema).type), 1)])]),
447
547
  getSchemaView(entry.schema).description ? (openBlock(), createBlock(unref(ScalarMarkdown), {
448
548
  key: 0,
449
549
  value: getSchemaView(entry.schema).description
450
550
  }, null, 8, ["value"])) : createCommentVNode("", true),
451
- getSchemaView(entry.schema).type === "object" ? (openBlock(), createBlock(Schema_default, {
452
- key: 1,
453
- schema: entry.schema
454
- }, null, 8, ["schema"])) : createCommentVNode("", true),
455
- _cache[37] || (_cache[37] = createElementVNode("p", null, [createElementVNode("strong", null, "Example:")], -1)),
456
- getSchemaView(entry.schema).type === "object" ? (openBlock(), createBlock(XmlOrJson_default, {
457
- key: 2,
458
- modelValue: unref(getExampleFromSchema)(entry.schema)
459
- }, null, 8, ["modelValue"])) : createCommentVNode("", true)
551
+ createVNode(Schema_default, { schema: entry.schema }, null, 8, ["schema"]),
552
+ getSchemaView(entry.schema).type === "object" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [_cache[36] || (_cache[36] = createElementVNode("p", null, [createElementVNode("strong", null, "Example:")], -1)), createVNode(XmlOrJson_default, { modelValue: unref(getExampleFromSchema)(entry.schema) }, null, 8, ["modelValue"])], 64)) : createCommentVNode("", true)
460
553
  ]);
461
554
  }), 128))])) : createCommentVNode("", true)
462
555
  ]);
@@ -497,6 +590,7 @@ var normalizeHttpMethod = (method) => {
497
590
  return null;
498
591
  };
499
592
  var normalizeJsonPointer = (pointer) => {
593
+ if (/~(?![01])/.test(pointer)) throw new Error(`Invalid JSON pointer escape in "${pointer}"`);
500
594
  if (pointer.startsWith("#/")) return pointer.slice(1);
501
595
  if (pointer.startsWith("/")) return pointer;
502
596
  throw new Error(`Invalid JSON pointer "${pointer}". JSON pointers must start with "#/"`);
@@ -566,6 +660,162 @@ var filterDocumentByOperation = (document, selector) => {
566
660
  paths: { [match.path]: filterPathItemToSingleOperation(pathItem, match.method) }
567
661
  };
568
662
  };
663
+ /** Scope after resolving references and migrating older documents. */
664
+ var selectDocument = (document, options = {}) => {
665
+ if (!isObject(options)) throw new Error("Render options must be an object");
666
+ const keys = Object.keys(options).filter((key) => options[key] !== void 0);
667
+ if (!keys.length) return document;
668
+ if (keys.length !== 1 || ![
669
+ "operation",
670
+ "tag",
671
+ "model",
672
+ "webhook",
673
+ "introduction"
674
+ ].includes(keys[0])) throw new Error("Specify exactly one of operation, tag, model, webhook, or introduction");
675
+ if (options.introduction !== void 0 && options.introduction !== true) throw new Error("Introduction selector must be true");
676
+ for (const key of ["tag", "model"]) if (options[key] !== void 0 && (typeof options[key] !== "string" || !options[key].length)) throw new Error(`${key} selector must be a non-empty string`);
677
+ if (options.operation !== void 0) {
678
+ const selector = options.operation;
679
+ if (!isObject(selector) || !(Object.keys(selector).length === 1 && ("operationId" in selector ? typeof selector.operationId === "string" && selector.operationId.length : "pointer" in selector && typeof selector.pointer === "string" && selector.pointer.length) || Object.keys(selector).length === 2 && "path" in selector && typeof selector.path === "string" && "method" in selector && typeof selector.method === "string")) throw new Error("Invalid operation selector. Use { path, method }, { operationId }, or { pointer }");
680
+ }
681
+ const selected = {
682
+ ...document,
683
+ paths: {},
684
+ webhooks: {},
685
+ tags: []
686
+ };
687
+ const modelRoots = [];
688
+ if (options.operation) selected.paths = filterDocumentByOperation(document, options.operation).paths;
689
+ if (options.tag !== void 0) {
690
+ const metadata = document.tags?.filter((tag) => tag.name === options.tag) ?? [];
691
+ if (metadata.length > 1) throw new Error(`Multiple tags found for "${options.tag}"`);
692
+ selected.tags = metadata.length ? metadata : [{ name: options.tag }];
693
+ for (const [path, item] of getPathEntries(document)) {
694
+ const methods = HTTP_METHODS.filter((method) => getPathItemOperation(item, method)?.tags?.includes(options.tag));
695
+ if (methods.length) selected.paths[path] = Object.fromEntries(Object.entries(item).filter(([key]) => !HTTP_METHOD_SET.has(key) || methods.includes(key)));
696
+ }
697
+ if (!metadata.length && !Object.keys(selected.paths ?? {}).length) throw new Error(`Tag "${options.tag}" was not found`);
698
+ }
699
+ if (options.model !== void 0) {
700
+ const schema = document.components?.schemas?.[options.model];
701
+ if (schema === void 0 || !Object.hasOwn(document.components?.schemas ?? {}, options.model)) throw new Error(`Model "${options.model}" was not found`);
702
+ modelRoots.push(schema);
703
+ }
704
+ if (options.webhook !== void 0) {
705
+ const selector = options.webhook;
706
+ if (!isObject(selector) || typeof selector.name !== "string" || !selector.name || typeof selector.method !== "string" || Object.keys(selector).length !== 2) throw new Error("Invalid webhook selector. Use { name, method }");
707
+ const method = normalizeHttpMethod(selector.method);
708
+ if (!method) throw new Error(`Invalid HTTP method "${selector.method}"`);
709
+ const item = getResolvedPathItem(document.webhooks?.[selector.name]);
710
+ if (!item || !getPathItemOperation(item, method)) throw new Error(`Webhook "${selector.name}" with method "${method.toUpperCase()}" was not found`);
711
+ selected.webhooks = { [selector.name]: filterPathItemToSingleOperation(item, method) };
712
+ }
713
+ const securityNames = /* @__PURE__ */ new Set();
714
+ const tagNames = /* @__PURE__ */ new Set();
715
+ for (const items of [selected.paths, selected.webhooks]) for (const [path, itemRef] of Object.entries(items ?? {})) {
716
+ const item = getResolvedPathItem(itemRef);
717
+ const scoped = {
718
+ ...item,
719
+ parameters: void 0,
720
+ servers: void 0
721
+ };
722
+ for (const method of HTTP_METHODS) {
723
+ const operation = getPathItemOperation(item, method);
724
+ if (!operation) continue;
725
+ const parameters = /* @__PURE__ */ new Map();
726
+ for (const ref of [...item.parameters ?? [], ...operation.parameters ?? []]) {
727
+ const parameter = getResolvedRef(ref);
728
+ if (parameter) parameters.set(`${parameter.in}:${parameter.name}`, ref);
729
+ }
730
+ const security = operation.security ?? document.security ?? [];
731
+ for (const requirement of security) for (const name of Object.keys(requirement)) securityNames.add(name);
732
+ for (const name of operation.tags ?? []) tagNames.add(name);
733
+ scoped[method] = {
734
+ ...operation,
735
+ parameters: [...parameters.values()],
736
+ servers: operation.servers ?? item.servers ?? document.servers,
737
+ security,
738
+ tags: options.tag !== void 0 ? [options.tag] : operation.tags
739
+ };
740
+ }
741
+ items[path] = scoped;
742
+ }
743
+ if (options.operation || options.webhook) selected.tags = document.tags?.filter((tag) => tagNames.has(tag.name)) ?? [];
744
+ if (options.introduction) for (const requirement of document.security ?? []) for (const name of Object.keys(requirement)) securityNames.add(name);
745
+ else {
746
+ selected.servers = [];
747
+ selected.security = void 0;
748
+ }
749
+ const schemas = document.components?.schemas ?? {};
750
+ const needed = new Set(options.model !== void 0 ? [options.model] : []);
751
+ const visited = /* @__PURE__ */ new WeakSet();
752
+ const references = /* @__PURE__ */ new Set();
753
+ const opaqueValues = /* @__PURE__ */ new Set([
754
+ "example",
755
+ "examples",
756
+ "default",
757
+ "enum",
758
+ "const",
759
+ "value",
760
+ "dataValue"
761
+ ]);
762
+ const namedMaps = /* @__PURE__ */ new Set([
763
+ "paths",
764
+ "webhooks",
765
+ "responses",
766
+ "content",
767
+ "headers",
768
+ "links",
769
+ "encoding",
770
+ "variables",
771
+ "parameters",
772
+ "requestBodies",
773
+ "securitySchemes",
774
+ "pathItems",
775
+ "callbacks",
776
+ "mediaTypes",
777
+ "additionalOperations",
778
+ "schemas",
779
+ "properties",
780
+ "patternProperties",
781
+ "$defs",
782
+ "definitions",
783
+ "dependentSchemas"
784
+ ]);
785
+ const visit = (value, namedLevels = 0) => {
786
+ if (!value || typeof value !== "object" || visited.has(value)) return;
787
+ visited.add(value);
788
+ if (!namedLevels && "$ref" in value && typeof value.$ref === "string") {
789
+ const ref = value.$ref;
790
+ if (!references.has(ref)) {
791
+ references.add(ref);
792
+ if (ref.startsWith("#/components/schemas/")) {
793
+ const name = parseJsonPointer(ref)[2];
794
+ if (Object.hasOwn(schemas, name)) {
795
+ needed.add(name);
796
+ visit(schemas[name]);
797
+ }
798
+ }
799
+ visit(getResolvedRef(value), namedLevels);
800
+ }
801
+ }
802
+ for (const [key, child] of Object.entries(value)) if (key !== "$ref-value" && (namedLevels || !opaqueValues.has(key) && !key.startsWith("x-"))) {
803
+ const childNamedLevels = namedLevels ? namedLevels - 1 : key === "callbacks" ? 2 : namedMaps.has(key) ? 1 : 0;
804
+ visit(child, childNamedLevels);
805
+ }
806
+ };
807
+ visit({
808
+ paths: selected.paths,
809
+ webhooks: selected.webhooks
810
+ });
811
+ for (const root of modelRoots) visit(root);
812
+ selected.components = {
813
+ ...document.components,
814
+ schemas: Object.fromEntries(Object.entries(schemas).filter(([name]) => needed.has(name))),
815
+ securitySchemes: Object.fromEntries(Object.entries(document.components?.securitySchemes ?? {}).filter(([name]) => securityNames.has(name)))
816
+ };
817
+ return selected;
818
+ };
569
819
  async function createHtmlFromOpenApi(input, options) {
570
820
  const workspaceStore = createWorkspaceStore({ fileLoader: readFiles() });
571
821
  const name = "openapi-to-markdown";
@@ -575,7 +825,7 @@ async function createHtmlFromOpenApi(input, options) {
575
825
  })) throw new Error("Failed to load OpenAPI document");
576
826
  const content = workspaceStore.workspace.documents[name];
577
827
  if (!content) throw new Error("OpenAPI document could not be resolved");
578
- return minify(await renderToString(createSSRApp(MarkdownReference_default, { content: options?.operation && isObject(content) ? filterDocumentByOperation(content, options.operation) : content })), {
828
+ return minify(await renderToString(createSSRApp(MarkdownReference_default, { content: selectDocument(content, options) })), {
579
829
  removeComments: true,
580
830
  removeEmptyElements: true,
581
831
  collapseWhitespace: true,