@scalar/openapi-to-markdown 0.6.0 → 1.0.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/CHANGELOG.md +16 -0
- package/README.md +44 -35
- package/dist/create-markdown-from-openapi.d.ts +15 -25
- package/dist/create-markdown-from-openapi.d.ts.map +1 -1
- package/dist/create-markdown-from-openapi.js +35 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -850
- package/dist/load-document.d.ts +4 -0
- package/dist/load-document.d.ts.map +1 -0
- package/dist/load-document.js +151 -0
- package/dist/markdown-nodes.d.ts +25 -0
- package/dist/markdown-nodes.d.ts.map +1 -0
- package/dist/markdown-nodes.js +34 -0
- package/dist/parse-description.d.ts +6 -0
- package/dist/parse-description.d.ts.map +1 -0
- package/dist/parse-description.js +116 -0
- package/dist/parse-html-description.d.ts +4 -0
- package/dist/parse-html-description.d.ts.map +1 -0
- package/dist/parse-html-description.js +11 -0
- package/dist/render-document.d.ts +4 -0
- package/dist/render-document.d.ts.map +1 -0
- package/dist/render-document.js +112 -0
- package/dist/render-operation.d.ts +13 -0
- package/dist/render-operation.d.ts.map +1 -0
- package/dist/render-operation.js +89 -0
- package/dist/render-schema.d.ts +31 -0
- package/dist/render-schema.d.ts.map +1 -0
- package/dist/render-schema.js +98 -0
- package/dist/render-security.d.ts +6 -0
- package/dist/render-security.d.ts.map +1 -0
- package/dist/render-security.js +33 -0
- package/dist/select-document.d.ts +29 -0
- package/dist/select-document.d.ts.map +1 -0
- package/dist/select-document.js +312 -0
- package/package.json +15 -27
- package/dist/components/MarkdownReference.test.d.ts +0 -2
- package/dist/components/MarkdownReference.test.d.ts.map +0 -1
- package/dist/components/MarkdownReference.vue.d.ts +0 -9
- package/dist/components/MarkdownReference.vue.d.ts.map +0 -1
- package/dist/components/Schema.test.d.ts +0 -2
- package/dist/components/Schema.test.d.ts.map +0 -1
- package/dist/components/Schema.vue.d.ts +0 -10
- package/dist/components/Schema.vue.d.ts.map +0 -1
- package/dist/components/Security.vue.d.ts +0 -9
- package/dist/components/Security.vue.d.ts.map +0 -1
- package/dist/components/XmlOrJson.vue.d.ts +0 -8
- package/dist/components/XmlOrJson.vue.d.ts.map +0 -1
- package/dist/create-markdown-from-openapi.test.d.ts +0 -2
- package/dist/create-markdown-from-openapi.test.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/selection.test.d.ts +0 -2
- package/dist/selection.test.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,850 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
3
|
-
import { normalize } from "@scalar/json-magic/helpers/normalize";
|
|
4
|
-
import { createWorkspaceStore } from "@scalar/workspace-store/client";
|
|
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";
|
|
7
|
-
import { minify } from "html-minifier-terser";
|
|
8
|
-
import rehypeParse from "rehype-parse";
|
|
9
|
-
import rehypeRemark from "rehype-remark";
|
|
10
|
-
import rehypeSanitize from "rehype-sanitize";
|
|
11
|
-
import remarkGfm from "remark-gfm";
|
|
12
|
-
import remarkStringify from "remark-stringify";
|
|
13
|
-
import { unified } from "unified";
|
|
14
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSSRApp, createTextVNode, createVNode, defineComponent, openBlock, renderList, resolveComponent, toDisplayString, unref } from "vue";
|
|
15
|
-
import { renderToString } from "vue/server-renderer";
|
|
16
|
-
import { ScalarMarkdown } from "@scalar/components/markdown";
|
|
17
|
-
import { getExampleFromSchema } from "@scalar/workspace-store/request-example";
|
|
18
|
-
import { resolve } from "@scalar/workspace-store/resolve";
|
|
19
|
-
import { json2xml } from "@scalar/helpers/file/json2xml";
|
|
20
|
-
//#region src/components/Schema.vue?vue&type=script&setup=true&lang.ts
|
|
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
|
-
var _hoisted_6$1 = { key: 3 };
|
|
27
|
-
var _hoisted_7$1 = { key: 4 };
|
|
28
|
-
var _hoisted_8$1 = { key: 0 };
|
|
29
|
-
var _hoisted_9$1 = { key: 0 };
|
|
30
|
-
var _hoisted_10$1 = { key: 1 };
|
|
31
|
-
var _hoisted_11$1 = { key: 2 };
|
|
32
|
-
var _hoisted_12$1 = { key: 3 };
|
|
33
|
-
var _hoisted_13$1 = { key: 1 };
|
|
34
|
-
var _hoisted_14$1 = { key: 5 };
|
|
35
|
-
var _hoisted_15$1 = { key: 0 };
|
|
36
|
-
var _hoisted_16$1 = { key: 0 };
|
|
37
|
-
var _hoisted_17$1 = { key: 1 };
|
|
38
|
-
var _hoisted_18$1 = { key: 2 };
|
|
39
|
-
var _hoisted_19$1 = { key: 6 };
|
|
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
|
-
var MAX_DEPTH = 10;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/components/Schema.vue
|
|
47
|
-
var Schema_default = /* @__PURE__ */ defineComponent({
|
|
48
|
-
__name: "Schema",
|
|
49
|
-
props: {
|
|
50
|
-
schema: {},
|
|
51
|
-
depth: { default: 0 },
|
|
52
|
-
ancestors: { default: () => [] }
|
|
53
|
-
},
|
|
54
|
-
setup(__props) {
|
|
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];
|
|
59
|
-
const resolveNestedSchema = (value) => resolve.schema(value);
|
|
60
|
-
const asObject = (value) => value !== null && typeof value === "object" ? value : void 0;
|
|
61
|
-
const getSchemaType = (value) => {
|
|
62
|
-
const schemaType = asObject(value)?.type;
|
|
63
|
-
if (typeof schemaType === "string") return schemaType;
|
|
64
|
-
if (Array.isArray(schemaType) && schemaType.every((entry) => typeof entry === "string")) return schemaType;
|
|
65
|
-
};
|
|
66
|
-
const getSchemaArray = (value, key) => {
|
|
67
|
-
const collection = asObject(value)?.[key];
|
|
68
|
-
if (!Array.isArray(collection)) return;
|
|
69
|
-
return collection.filter((entry) => entry !== null && typeof entry === "object");
|
|
70
|
-
};
|
|
71
|
-
const getSchemaNot = (value) => {
|
|
72
|
-
const notSchema = asObject(value)?.not;
|
|
73
|
-
return notSchema !== null && typeof notSchema === "object" ? notSchema : void 0;
|
|
74
|
-
};
|
|
75
|
-
const getSchemaProperties = (value) => {
|
|
76
|
-
const properties = asObject(value)?.properties;
|
|
77
|
-
if (!properties || typeof properties !== "object") return {};
|
|
78
|
-
return Object.entries(properties).reduce((acc, [name, prop]) => {
|
|
79
|
-
if (prop !== null && typeof prop === "object") acc[name] = prop;
|
|
80
|
-
return acc;
|
|
81
|
-
}, {});
|
|
82
|
-
};
|
|
83
|
-
const getSchemaRequired = (value) => {
|
|
84
|
-
const required = asObject(value)?.required;
|
|
85
|
-
if (!Array.isArray(required)) return [];
|
|
86
|
-
return required.filter((item) => typeof item === "string");
|
|
87
|
-
};
|
|
88
|
-
const getSchemaItems = (value) => {
|
|
89
|
-
const items = asObject(value)?.items;
|
|
90
|
-
return items !== null && typeof items === "object" ? items : void 0;
|
|
91
|
-
};
|
|
92
|
-
const getSchemaFormat = (value) => typeof asObject(value)?.format === "string" ? asObject(value)?.format : void 0;
|
|
93
|
-
const getSchemaEnum = (value) => {
|
|
94
|
-
const enumValues = asObject(value)?.enum;
|
|
95
|
-
return Array.isArray(enumValues) ? enumValues : void 0;
|
|
96
|
-
};
|
|
97
|
-
const getSchemaDefault = (value) => asObject(value)?.default;
|
|
98
|
-
const getSchemaDescription = (value) => typeof asObject(value)?.description === "string" ? asObject(value)?.description : void 0;
|
|
99
|
-
const getSchemaMinItems = (value) => typeof asObject(value)?.minItems === "number" ? asObject(value)?.minItems : void 0;
|
|
100
|
-
const getSchemaMaxItems = (value) => typeof asObject(value)?.maxItems === "number" ? asObject(value)?.maxItems : void 0;
|
|
101
|
-
const getSchemaUniqueItems = (value) => typeof asObject(value)?.uniqueItems === "boolean" ? asObject(value)?.uniqueItems : void 0;
|
|
102
|
-
const getResolvedSchemaType = (value) => getSchemaType(resolveNestedSchema(value));
|
|
103
|
-
const getResolvedSchemaFormat = (value) => getSchemaFormat(resolveNestedSchema(value));
|
|
104
|
-
const getResolvedSchemaEnum = (value) => getSchemaEnum(resolveNestedSchema(value));
|
|
105
|
-
const getResolvedSchemaDefault = (value) => getSchemaDefault(resolveNestedSchema(value));
|
|
106
|
-
const getResolvedSchemaDescription = (value) => getSchemaDescription(resolveNestedSchema(value));
|
|
107
|
-
const getResolvedSchemaProperties = (value) => getSchemaProperties(resolveNestedSchema(value));
|
|
108
|
-
const getResolvedSchemaItems = (value) => getSchemaItems(resolveNestedSchema(value));
|
|
109
|
-
const formatSchemaType = (value) => {
|
|
110
|
-
const schemaType = getResolvedSchemaType(value);
|
|
111
|
-
return Array.isArray(schemaType) ? schemaType.join(" | ") : schemaType || "object";
|
|
112
|
-
};
|
|
113
|
-
const formatEnumValues = (value) => value?.map((entry) => JSON.stringify(entry)).join(", ") || "";
|
|
114
|
-
const sortProperties = (properties, required) => {
|
|
115
|
-
const sorted = Object.entries(properties).sort(([a], [b]) => {
|
|
116
|
-
const aRequired = required?.includes(a);
|
|
117
|
-
const bRequired = required?.includes(b);
|
|
118
|
-
if (aRequired && !bRequired) return -1;
|
|
119
|
-
if (!aRequired && bRequired) return 1;
|
|
120
|
-
return a.localeCompare(b);
|
|
121
|
-
});
|
|
122
|
-
return Object.fromEntries(sorted);
|
|
123
|
-
};
|
|
124
|
-
return (_ctx, _cache) => {
|
|
125
|
-
const _component_Schema = resolveComponent("Schema", true);
|
|
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) => {
|
|
127
|
-
return openBlock(), createElementBlock("section", { key: index }, [createVNode(_component_Schema, {
|
|
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) => {
|
|
133
|
-
return openBlock(), createElementBlock("section", { key: index }, [createVNode(_component_Schema, {
|
|
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) => {
|
|
139
|
-
return openBlock(), createElementBlock("section", { key: index }, [createVNode(_component_Schema, {
|
|
140
|
-
ancestors: childAncestors,
|
|
141
|
-
depth: __props.depth + 1,
|
|
142
|
-
schema: subSchema
|
|
143
|
-
}, null, 8, ["depth", "schema"])]);
|
|
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, {
|
|
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) => {
|
|
149
|
-
return openBlock(), createElementBlock("li", { key: propName }, [
|
|
150
|
-
createElementVNode("strong", null, [createElementVNode("code", null, toDisplayString(propName), 1), getSchemaRequired(unref(resolvedSchema)).includes(propName) ? (openBlock(), createElementBlock("span", _hoisted_8$1, " (required) ")) : createCommentVNode("", true)]),
|
|
151
|
-
createElementVNode("p", null, [
|
|
152
|
-
createElementVNode("code", null, toDisplayString(formatSchemaType(propSchema)), 1),
|
|
153
|
-
getResolvedSchemaFormat(propSchema) ? (openBlock(), createElementBlock("span", _hoisted_9$1, [_cache[5] || (_cache[5] = createTextVNode(", format: ", -1)), createElementVNode("code", null, toDisplayString(getResolvedSchemaFormat(propSchema)), 1)])) : createCommentVNode("", true),
|
|
154
|
-
getResolvedSchemaEnum(propSchema) ? (openBlock(), createElementBlock("span", _hoisted_10$1, [_cache[6] || (_cache[6] = createTextVNode(", possible values: ", -1)), createElementVNode("code", null, toDisplayString(formatEnumValues(getResolvedSchemaEnum(propSchema))), 1)])) : createCommentVNode("", true),
|
|
155
|
-
getResolvedSchemaDefault(propSchema) !== void 0 ? (openBlock(), createElementBlock("span", _hoisted_11$1, [_cache[7] || (_cache[7] = createTextVNode(", default: ", -1)), createElementVNode("code", null, toDisplayString(JSON.stringify(getResolvedSchemaDefault(propSchema))), 1)])) : createCommentVNode("", true),
|
|
156
|
-
getResolvedSchemaDescription(propSchema) ? (openBlock(), createElementBlock("span", _hoisted_12$1, " — " + toDisplayString(getResolvedSchemaDescription(propSchema)), 1)) : createCommentVNode("", true)
|
|
157
|
-
]),
|
|
158
|
-
getResolvedSchemaType(propSchema) === "object" || Object.keys(getResolvedSchemaProperties(propSchema)).length ? (openBlock(), createBlock(_component_Schema, {
|
|
159
|
-
key: 0,
|
|
160
|
-
ancestors: childAncestors,
|
|
161
|
-
depth: __props.depth + 1,
|
|
162
|
-
schema: propSchema
|
|
163
|
-
}, null, 8, ["depth", "schema"])) : createCommentVNode("", true),
|
|
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, {
|
|
165
|
-
ancestors: childAncestors,
|
|
166
|
-
depth: __props.depth + 1,
|
|
167
|
-
schema: getResolvedSchemaItems(propSchema)
|
|
168
|
-
}, null, 8, ["depth", "schema"])])) : createCommentVNode("", true)
|
|
169
|
-
]);
|
|
170
|
-
}), 128))])])) : getSchemaType(unref(resolvedSchema)) === "array" && getSchemaItems(unref(resolvedSchema)) ? (openBlock(), createElementBlock("section", _hoisted_14$1, [
|
|
171
|
-
_cache[12] || (_cache[12] = createElementVNode("header", null, [createElementVNode("strong", null, "Array of:")], -1)),
|
|
172
|
-
createElementVNode("section", null, [createVNode(_component_Schema, {
|
|
173
|
-
ancestors: childAncestors,
|
|
174
|
-
depth: __props.depth + 1,
|
|
175
|
-
schema: getSchemaItems(unref(resolvedSchema))
|
|
176
|
-
}, null, 8, ["depth", "schema"])]),
|
|
177
|
-
getSchemaMinItems(unref(resolvedSchema)) !== void 0 || getSchemaMaxItems(unref(resolvedSchema)) !== void 0 || getSchemaUniqueItems(unref(resolvedSchema)) ? (openBlock(), createElementBlock("ul", _hoisted_15$1, [
|
|
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),
|
|
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),
|
|
180
|
-
getSchemaUniqueItems(unref(resolvedSchema)) ? (openBlock(), createElementBlock("li", _hoisted_18$1, [..._cache[11] || (_cache[11] = [createTextVNode(" Unique items: ", -1), createElementVNode("code", null, "true", -1)])])) : createCommentVNode("", true)
|
|
181
|
-
])) : createCommentVNode("", true)
|
|
182
|
-
])) : (openBlock(), createElementBlock("section", _hoisted_19$1, [createElementVNode("p", null, [
|
|
183
|
-
createElementVNode("code", null, toDisplayString(getSchemaType(unref(resolvedSchema))), 1),
|
|
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)
|
|
188
|
-
])]))])) : createCommentVNode("", true);
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
});
|
|
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
|
|
233
|
-
//#region src/components/XmlOrJson.vue?vue&type=script&setup=true&lang.ts
|
|
234
|
-
var _hoisted_1$1 = { key: 0 };
|
|
235
|
-
var _hoisted_2$1 = { class: "language-xml" };
|
|
236
|
-
var _hoisted_3$1 = { key: 1 };
|
|
237
|
-
var _hoisted_4$1 = { class: "language-json" };
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region src/components/XmlOrJson.vue
|
|
240
|
-
var XmlOrJson_default = /* @__PURE__ */ defineComponent({
|
|
241
|
-
__name: "XmlOrJson",
|
|
242
|
-
props: {
|
|
243
|
-
xml: {
|
|
244
|
-
type: Boolean,
|
|
245
|
-
default: false
|
|
246
|
-
},
|
|
247
|
-
modelValue: {}
|
|
248
|
-
},
|
|
249
|
-
setup(__props) {
|
|
250
|
-
const xmlContent = computed(() => json2xml(__props.modelValue));
|
|
251
|
-
return (_ctx, _cache) => {
|
|
252
|
-
return __props.xml ? (openBlock(), createElementBlock("pre", _hoisted_1$1, [createElementVNode("code", _hoisted_2$1, toDisplayString(xmlContent.value), 1)])) : (openBlock(), createElementBlock("pre", _hoisted_3$1, [createElementVNode("code", _hoisted_4$1, toDisplayString(JSON.stringify(__props.modelValue, null, 2)), 1)]));
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/components/MarkdownReference.vue?vue&type=script&setup=true&lang.ts
|
|
258
|
-
var _hoisted_1 = { key: 0 };
|
|
259
|
-
var _hoisted_2 = ["href"];
|
|
260
|
-
var _hoisted_3 = { key: 1 };
|
|
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 };
|
|
274
|
-
var _hoisted_17 = { key: 0 };
|
|
275
|
-
var _hoisted_18 = { key: 1 };
|
|
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 };
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/components/MarkdownReference.vue
|
|
286
|
-
var MarkdownReference_default = /* @__PURE__ */ defineComponent({
|
|
287
|
-
__name: "MarkdownReference",
|
|
288
|
-
props: { content: {} },
|
|
289
|
-
setup(__props) {
|
|
290
|
-
const resolveRefAs = (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
|
-
});
|
|
296
|
-
return resolved && typeof resolved === "object" ? resolved : null;
|
|
297
|
-
};
|
|
298
|
-
const resolveOperation = (operation) => resolveRefAs(operation);
|
|
299
|
-
const resolveSchema = (schema) => resolveRefAs(schema);
|
|
300
|
-
const resolveRequestBody = (body) => resolveRefAs(body);
|
|
301
|
-
const resolveParameter = (parameter) => resolveRefAs(parameter);
|
|
302
|
-
const resolveResponse = (response) => resolveRefAs(response);
|
|
303
|
-
const toRequestBodyView = (body) => resolveRequestBody(body);
|
|
304
|
-
const toParameterView = (parameter) => {
|
|
305
|
-
const resolvedParameter = resolveParameter(parameter);
|
|
306
|
-
if (!resolvedParameter) return null;
|
|
307
|
-
return resolvedParameter;
|
|
308
|
-
};
|
|
309
|
-
const toResponseView = (response) => resolveResponse(response);
|
|
310
|
-
const getParameterKey = (parameter) => `${parameter.in}:${parameter.name}`;
|
|
311
|
-
const getParameters = (pathParameters, operationParameters) => {
|
|
312
|
-
const parameters = /* @__PURE__ */ new Map();
|
|
313
|
-
for (const parameterList of [pathParameters, operationParameters]) {
|
|
314
|
-
if (!Array.isArray(parameterList)) continue;
|
|
315
|
-
for (const parameter of parameterList) {
|
|
316
|
-
const parameterView = toParameterView(parameter);
|
|
317
|
-
if (parameterView) parameters.set(getParameterKey(parameterView), parameterView);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return Array.from(parameters.values());
|
|
321
|
-
};
|
|
322
|
-
const getEntries = (paths) => {
|
|
323
|
-
const entries = [];
|
|
324
|
-
for (const [path, pathItemRef] of Object.entries(paths)) {
|
|
325
|
-
const resolvedPathItem = getResolvedPathItem(pathItemRef);
|
|
326
|
-
forEachPathItemOperation(pathItemRef, (method, operation) => {
|
|
327
|
-
const resolvedOperation = resolveOperation(operation);
|
|
328
|
-
if (!resolvedOperation) return;
|
|
329
|
-
const parameters = getParameters(resolvedPathItem?.parameters, resolvedOperation.parameters);
|
|
330
|
-
const requestBody = toRequestBodyView(resolvedOperation.requestBody);
|
|
331
|
-
const responses = Object.entries(resolvedOperation.responses ?? {}).flatMap(([statusCode, response]) => {
|
|
332
|
-
const resolvedResponse = toResponseView(response);
|
|
333
|
-
if (!resolvedResponse) return [];
|
|
334
|
-
return [{
|
|
335
|
-
statusCode,
|
|
336
|
-
response: resolvedResponse
|
|
337
|
-
}];
|
|
338
|
-
});
|
|
339
|
-
entries.push({
|
|
340
|
-
path,
|
|
341
|
-
method,
|
|
342
|
-
operation: resolvedOperation,
|
|
343
|
-
servers: resolvedOperation.servers ?? resolvedPathItem?.servers ?? __props.content.servers,
|
|
344
|
-
security: resolvedOperation.security ?? __props.content.security,
|
|
345
|
-
parameters,
|
|
346
|
-
requestBody,
|
|
347
|
-
responses
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
return entries;
|
|
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
|
-
}]);
|
|
362
|
-
const componentSchemas = computed(() => {
|
|
363
|
-
const schemas = __props.content?.components?.schemas ?? {};
|
|
364
|
-
return Object.entries(schemas).flatMap(([name, schema]) => {
|
|
365
|
-
const resolvedSchema = resolveSchema(schema);
|
|
366
|
-
if (!resolvedSchema) return [];
|
|
367
|
-
return [{
|
|
368
|
-
name,
|
|
369
|
-
schema: resolvedSchema
|
|
370
|
-
}];
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
const getSchemaView = (schema) => schema;
|
|
374
|
-
return (_ctx, _cache) => {
|
|
375
|
-
return openBlock(), createElementBlock("section", null, [
|
|
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
|
-
])]),
|
|
405
|
-
__props.content?.info?.description ? (openBlock(), createBlock(unref(ScalarMarkdown), {
|
|
406
|
-
key: 0,
|
|
407
|
-
value: __props.content?.info?.description
|
|
408
|
-
}, null, 8, ["value"])) : createCommentVNode("", true),
|
|
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) => {
|
|
410
|
-
return openBlock(), createElementBlock("li", { key: server.url }, [
|
|
411
|
-
_cache[11] || (_cache[11] = createElementVNode("strong", null, "URL:", -1)),
|
|
412
|
-
_cache[12] || (_cache[12] = createTextVNode("\xA0", -1)),
|
|
413
|
-
createElementVNode("code", null, toDisplayString(server.url), 1),
|
|
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) => {
|
|
415
|
-
return openBlock(), createElementBlock("li", { key: name }, [
|
|
416
|
-
createElementVNode("code", null, toDisplayString(name), 1),
|
|
417
|
-
_cache[8] || (_cache[8] = createTextVNode(" (default: ", -1)),
|
|
418
|
-
createElementVNode("code", null, toDisplayString(variable.default), 1),
|
|
419
|
-
_cache[9] || (_cache[9] = createTextVNode(")", -1)),
|
|
420
|
-
variable.description ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(": " + toDisplayString(variable.description), 1)], 64)) : createCommentVNode("", true)
|
|
421
|
-
]);
|
|
422
|
-
}), 128))])])) : createCommentVNode("", true)])
|
|
423
|
-
]);
|
|
424
|
-
}), 128))])])) : 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)
|
|
448
|
-
]),
|
|
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)
|
|
453
|
-
]),
|
|
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), {
|
|
498
|
-
key: 0,
|
|
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) => {
|
|
544
|
-
return openBlock(), createElementBlock("section", { key: entry.name }, [
|
|
545
|
-
createElementVNode("header", null, [createElementVNode("h3", null, toDisplayString(getSchemaView(entry.schema).title ?? entry.name), 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)])]),
|
|
547
|
-
getSchemaView(entry.schema).description ? (openBlock(), createBlock(unref(ScalarMarkdown), {
|
|
548
|
-
key: 0,
|
|
549
|
-
value: getSchemaView(entry.schema).description
|
|
550
|
-
}, null, 8, ["value"])) : 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)
|
|
553
|
-
]);
|
|
554
|
-
}), 128))])) : createCommentVNode("", true)
|
|
555
|
-
]);
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
//#endregion
|
|
560
|
-
//#region src/create-markdown-from-openapi.ts
|
|
561
|
-
var HTTP_METHODS = [
|
|
562
|
-
"get",
|
|
563
|
-
"put",
|
|
564
|
-
"post",
|
|
565
|
-
"delete",
|
|
566
|
-
"options",
|
|
567
|
-
"head",
|
|
568
|
-
"patch",
|
|
569
|
-
"trace"
|
|
570
|
-
];
|
|
571
|
-
var HTTP_METHOD_SET = new Set(HTTP_METHODS);
|
|
572
|
-
var isHttpUrl = (value) => {
|
|
573
|
-
try {
|
|
574
|
-
const url = new URL(value);
|
|
575
|
-
return url.protocol === "http:" || url.protocol === "https:";
|
|
576
|
-
} catch {
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
var toWorkspaceInput = (input) => {
|
|
581
|
-
if (typeof input !== "string") return { document: input };
|
|
582
|
-
const normalized = normalize(input);
|
|
583
|
-
if (isObject(normalized)) return { document: normalized };
|
|
584
|
-
if (isHttpUrl(input)) return { url: input };
|
|
585
|
-
return { path: input };
|
|
586
|
-
};
|
|
587
|
-
var normalizeHttpMethod = (method) => {
|
|
588
|
-
const normalized = method.toLowerCase();
|
|
589
|
-
if (HTTP_METHOD_SET.has(normalized)) return normalized;
|
|
590
|
-
return null;
|
|
591
|
-
};
|
|
592
|
-
var normalizeJsonPointer = (pointer) => {
|
|
593
|
-
if (/~(?![01])/.test(pointer)) throw new Error(`Invalid JSON pointer escape in "${pointer}"`);
|
|
594
|
-
if (pointer.startsWith("#/")) return pointer.slice(1);
|
|
595
|
-
if (pointer.startsWith("/")) return pointer;
|
|
596
|
-
throw new Error(`Invalid JSON pointer "${pointer}". JSON pointers must start with "#/"`);
|
|
597
|
-
};
|
|
598
|
-
var parseJsonPointer = (pointer) => normalizeJsonPointer(pointer).slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
599
|
-
var getOperationSelectorFromPointer = (pointer) => {
|
|
600
|
-
const segments = parseJsonPointer(pointer);
|
|
601
|
-
if (segments.length !== 3 || segments[0] !== "paths") throw new Error(`JSON pointer "${pointer}" must target an operation object under "/paths/{path}/{method}"`);
|
|
602
|
-
const path = segments[1];
|
|
603
|
-
const method = segments[2];
|
|
604
|
-
if (!path || !method) throw new Error(`JSON pointer "${pointer}" must target an operation object under "/paths/{path}/{method}"`);
|
|
605
|
-
return {
|
|
606
|
-
path,
|
|
607
|
-
method
|
|
608
|
-
};
|
|
609
|
-
};
|
|
610
|
-
var getPathEntries = (document) => {
|
|
611
|
-
const paths = document.paths;
|
|
612
|
-
if (!isObject(paths)) return [];
|
|
613
|
-
return Object.entries(paths).flatMap(([path, pathItemRef]) => {
|
|
614
|
-
const pathItem = getResolvedPathItem(pathItemRef);
|
|
615
|
-
return pathItem ? [[path, pathItem]] : [];
|
|
616
|
-
});
|
|
617
|
-
};
|
|
618
|
-
var filterPathItemToSingleOperation = (pathItem, selectedMethod) => Object.fromEntries(Object.entries(pathItem).filter(([key]) => {
|
|
619
|
-
const method = normalizeHttpMethod(key);
|
|
620
|
-
return !method || method === selectedMethod;
|
|
621
|
-
}));
|
|
622
|
-
var findOperationByPathAndMethod = (document, selector) => {
|
|
623
|
-
const method = normalizeHttpMethod(selector.method);
|
|
624
|
-
if (!method) throw new Error(`Invalid HTTP method "${selector.method}". Supported methods: ${HTTP_METHODS.join(", ")}`);
|
|
625
|
-
const pathItemRef = document.paths?.[selector.path];
|
|
626
|
-
if (!getPathItemOperation(pathItemRef, method)) throw new Error(`Operation not found for path "${selector.path}" and method "${method.toUpperCase()}"`);
|
|
627
|
-
return {
|
|
628
|
-
path: selector.path,
|
|
629
|
-
method
|
|
630
|
-
};
|
|
631
|
-
};
|
|
632
|
-
var findOperationsByOperationId = (document, operationId) => getPathEntries(document).flatMap(([path, pathItem]) => Object.entries(pathItem).flatMap(([methodKey, operation]) => {
|
|
633
|
-
const method = normalizeHttpMethod(methodKey);
|
|
634
|
-
if (!method || !isObject(operation)) return [];
|
|
635
|
-
if (("operationId" in operation && typeof operation.operationId === "string" ? operation.operationId : void 0) !== operationId) return [];
|
|
636
|
-
return [{
|
|
637
|
-
path,
|
|
638
|
-
method
|
|
639
|
-
}];
|
|
640
|
-
}));
|
|
641
|
-
var resolveOperationMatch = (document, selector) => {
|
|
642
|
-
if ("pointer" in selector) return findOperationByPathAndMethod(document, getOperationSelectorFromPointer(selector.pointer));
|
|
643
|
-
if ("operationId" in selector) {
|
|
644
|
-
const matches = findOperationsByOperationId(document, selector.operationId);
|
|
645
|
-
if (!matches.length) throw new Error(`Operation with operationId "${selector.operationId}" was not found`);
|
|
646
|
-
if (matches.length > 1) {
|
|
647
|
-
const uniqueCandidates = matches.map(({ path, method }) => `"${method.toUpperCase()} ${path}"`);
|
|
648
|
-
throw new Error(`Multiple operations found for operationId "${selector.operationId}". Use { path, method } instead. Matches: ${uniqueCandidates.join(", ")}`);
|
|
649
|
-
}
|
|
650
|
-
return matches[0];
|
|
651
|
-
}
|
|
652
|
-
return findOperationByPathAndMethod(document, selector);
|
|
653
|
-
};
|
|
654
|
-
var filterDocumentByOperation = (document, selector) => {
|
|
655
|
-
const match = resolveOperationMatch(document, selector);
|
|
656
|
-
const pathItem = getPathEntries(document).find(([path]) => path === match.path)?.[1];
|
|
657
|
-
if (!pathItem) throw new Error(`Operation not found for path "${match.path}" and method "${match.method.toUpperCase()}"`);
|
|
658
|
-
return {
|
|
659
|
-
...document,
|
|
660
|
-
paths: { [match.path]: filterPathItemToSingleOperation(pathItem, match.method) }
|
|
661
|
-
};
|
|
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
|
-
};
|
|
819
|
-
async function createHtmlFromOpenApi(input, options) {
|
|
820
|
-
const workspaceStore = createWorkspaceStore({ fileLoader: readFiles() });
|
|
821
|
-
const name = "openapi-to-markdown";
|
|
822
|
-
if (!await workspaceStore.addDocument({
|
|
823
|
-
name,
|
|
824
|
-
...toWorkspaceInput(input)
|
|
825
|
-
})) throw new Error("Failed to load OpenAPI document");
|
|
826
|
-
const content = workspaceStore.workspace.documents[name];
|
|
827
|
-
if (!content) throw new Error("OpenAPI document could not be resolved");
|
|
828
|
-
return minify(await renderToString(createSSRApp(MarkdownReference_default, { content: selectDocument(content, options) })), {
|
|
829
|
-
removeComments: true,
|
|
830
|
-
removeEmptyElements: true,
|
|
831
|
-
collapseWhitespace: true,
|
|
832
|
-
continueOnParseError: true,
|
|
833
|
-
noNewlinesBeforeTagClose: true,
|
|
834
|
-
preserveLineBreaks: true,
|
|
835
|
-
removeEmptyAttributes: true,
|
|
836
|
-
decodeEntities: true,
|
|
837
|
-
useShortDoctype: true
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
async function createMarkdownFromOpenApi(content, options) {
|
|
841
|
-
return markdownFromHtml(await createHtmlFromOpenApi(content, options));
|
|
842
|
-
}
|
|
843
|
-
async function markdownFromHtml(html) {
|
|
844
|
-
const file = await unified().use(rehypeParse, { fragment: true }).use(remarkGfm).use(rehypeSanitize).use(rehypeRemark).use(remarkStringify, { bullet: "-" }).process(html);
|
|
845
|
-
return String(file);
|
|
846
|
-
}
|
|
847
|
-
//#endregion
|
|
848
|
-
export { createHtmlFromOpenApi, createMarkdownFromOpenApi };
|
|
849
|
-
|
|
850
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { createHtmlFromOpenApi, createMarkdownFromOpenApi, createOpenApiMarkdownRenderer, } from './create-markdown-from-openapi.js';
|