@mintlify/msft-sdk 1.1.62 → 1.1.63
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/api-playground/ApiPlayground/Response/DownloadFileButton.js +6 -5
- package/dist/api-playground/ApiPlayground/Response/ResponseBody/CodeResponseContent.js +13 -12
- package/dist/api-playground/ApiPlayground/Response/ResponsePlaceholder.js +8 -7
- package/dist/api-playground/ApiPlayground/Response/ResponseTable.js +3 -2
- package/dist/api-playground/ApiPlayground/Response/ResponseTopbar.js +9 -8
- package/dist/api-playground/ApiPlayground/Response/index.js +4 -3
- package/dist/api-playground/ApiPlayground/components/AdditionalPropertyButton.js +42 -21
- package/dist/api-playground/ApiPlayground/components/ParamFieldWrapper.js +13 -9
- package/dist/api-playground/ApiPlayground/components/PlaygroundModalWrapper.js +6 -5
- package/dist/api-playground/ApiPlayground/components/SendPill.js +3 -2
- package/dist/api-playground/ApiPlayground/components/TypeDropdown.js +6 -5
- package/dist/api-playground/EndpointFields/ParamFields/ExampleDescription.js +3 -2
- package/dist/api-playground/EndpointFields/components/Description.js +6 -5
- package/dist/api-playground/EndpointFields/components/OptionDropdown.js +9 -8
- package/dist/api-playground/EndpointFields/components/SectionHeading.js +8 -7
- package/dist/api-playground-2/ApiExamples.js +19 -20
- package/dist/api-playground-2/ApiFields.js +20 -247
- package/dist/api-playground-2/EndpointHeader.js +59 -47
- package/dist/api-playground-2/OperationPage.js +70 -66
- package/dist/api-playground-2/Playground.js +67 -83
- package/dist/api-playground-2/SchemaPage.js +22 -9
- package/dist/api-playground-2/components/EndpointFields/Body.js +40 -0
- package/dist/api-playground-2/components/EndpointFields/Parameters.js +90 -0
- package/dist/api-playground-2/components/EndpointFields/Response.js +146 -0
- package/dist/api-playground-2/components/EndpointFields/Security.js +88 -0
- package/dist/api-playground-2/components/EndpointFields/fields/ArrayParamField.js +93 -0
- package/dist/api-playground-2/components/EndpointFields/fields/Enum.js +29 -11
- package/dist/api-playground-2/components/EndpointFields/fields/ObjectParamField.js +145 -0
- package/dist/api-playground-2/components/EndpointFields/fields/PrimitiveParamField.js +60 -48
- package/dist/api-playground-2/components/EndpointFields/fields/SchemaField.js +230 -0
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +93 -89
- package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +18 -17
- package/dist/api-playground-2/components/Example/RequestExample.js +92 -93
- package/dist/api-playground-2/components/Example/ResponseExample.js +19 -15
- package/dist/api-playground-2/components/Request/ParameterSection.js +20 -18
- package/dist/api-playground-2/components/Request/SecuritySection.js +53 -43
- package/dist/api-playground-2/components/Request/inputs/ArrayInput.js +89 -40
- package/dist/api-playground-2/components/Request/inputs/DifferentiatedInput.js +12 -12
- package/dist/api-playground-2/components/Request/inputs/FileInput.js +16 -15
- package/dist/api-playground-2/components/Request/inputs/InputContainer.js +76 -57
- package/dist/api-playground-2/components/Request/inputs/NumberInput.js +10 -9
- package/dist/api-playground-2/components/Request/inputs/ObjectInput.js +98 -80
- package/dist/api-playground-2/components/Request/inputs/OneOfInput.js +55 -47
- package/dist/api-playground-2/components/Request/inputs/SelectInput.js +18 -17
- package/dist/api-playground-2/components/Request/inputs/StringInput.js +19 -18
- package/dist/api-playground-2/components/Request/inputs/TextInput.js +12 -11
- package/dist/api-playground-2/components/SendPillWrapper.js +35 -0
- package/dist/api-playground-2/contexts/ApiPlaygroundContext.js +3 -5
- package/dist/api-playground-2/generators/createCookies.js +23 -0
- package/dist/api-playground-2/generators/createHeaders.js +53 -36
- package/dist/api-playground-2/generators/createQueryString.js +30 -0
- package/dist/api-playground-2/generators/generateAuthPlaceholder.js +14 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +27 -25
- package/dist/api-playground-2/generators/generateRequest.js +47 -51
- package/dist/api-playground-2/generators/generateResponseExampleMap.js +15 -11
- package/dist/api-playground-2/generators/generateSnippetMap.js +13 -11
- package/dist/api-playground-2/hooks/useCopyPathWithInputs.js +11 -11
- package/dist/api-playground-2/hooks/useInitializeInputs.js +185 -88
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +70 -25
- package/dist/api-playground-2/hooks/useSelectedBaseUrl.js +13 -0
- package/dist/api-playground-2/hooks/useSelectedExample.js +10 -0
- package/dist/api-playground-2/hooks/useSelectedRequestBodyContentType.js +12 -0
- package/dist/api-playground-2/hooks/useSelectedResponseContentType.js +12 -0
- package/dist/api-playground-2/hooks/useSelectedSecurityOption.js +31 -0
- package/dist/api-playground-2/hooks/useSendPlaygroundRequest.js +114 -101
- package/dist/api-playground-2/schemaGraph/addApiReferenceDataFromMdxAndDocsConfig.js +23 -32
- package/dist/api-playground-2/schemaGraph/addTypeLabelsToSchema.js +50 -0
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js +40 -24
- package/dist/api-playground-2/schemaGraph/getExampleBodyInputs.js +94 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js +56 -50
- package/dist/api-playground-2/schemaGraph/processExamples.js +117 -52
- package/dist/api-playground-2/schemaGraph/processSchema.js +10 -0
- package/dist/api-playground-2/schemaGraph/processSecurityOptions.js +58 -28
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js +220 -181
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js +128 -89
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js +15 -16
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js +14 -12
- package/dist/api-playground-2/schemaGraph/utils.js +185 -147
- package/dist/common/guards.js +11 -19
- package/dist/components/Api/Expandable.js +10 -9
- package/dist/components/Api/Param.js +11 -13
- package/dist/components/Api/dropdown-menu.js +10 -9
- package/dist/components/content-components/code-group.js +4 -4
- package/dist/contexts/EndpointLocationContext.js +3 -3
- package/dist/hooks/useApiParamFieldOption.js +10 -0
- package/dist/hooks/useEndpoint.js +3 -3
- package/dist/hooks/useKeyboardShortcut.js +13 -13
- package/dist/hooks/useSendPlaygroundRequest.js +14 -146
- package/dist/index.d.ts +65 -58
- package/dist/index.js +109 -111
- package/dist/openapi/generateTypeStringFromSchema.js +2 -31
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/api-playground/ApiPlayground/Request/BodySection.js +0 -64
- package/dist/api-playground/ApiPlayground/Request/ParameterSection.js +0 -32
- package/dist/api-playground/ApiPlayground/Request/PlaygroundModal.js +0 -201
- package/dist/api-playground/ApiPlayground/Request/SecuritySection.js +0 -146
- package/dist/api-playground/ApiPlayground/Request/ServerSection.js +0 -30
- package/dist/api-playground/ApiPlayground/Request/index.js +0 -43
- package/dist/api-playground/ApiPlayground/Request/inputs/ArrayInput.js +0 -93
- package/dist/api-playground/ApiPlayground/Request/inputs/DifferentiatedInput.js +0 -90
- package/dist/api-playground/ApiPlayground/Request/inputs/FileInput.js +0 -62
- package/dist/api-playground/ApiPlayground/Request/inputs/NullInput.js +0 -33
- package/dist/api-playground/ApiPlayground/Request/inputs/NumberInput.js +0 -61
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectChildren.js +0 -109
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectInput.js +0 -87
- package/dist/api-playground/ApiPlayground/Request/inputs/RecursiveInput.js +0 -61
- package/dist/api-playground/ApiPlayground/Request/inputs/SelectInput.js +0 -54
- package/dist/api-playground/ApiPlayground/Request/inputs/StringInput.js +0 -67
- package/dist/api-playground/ApiPlayground/Request/inputs/TextInput.js +0 -44
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js +0 -42
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js +0 -43
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuSearch.js +0 -38
- package/dist/api-playground/ApiPlayground/components/InputContainer.js +0 -128
- package/dist/api-playground/ApiPlayground/components/InputSectionContainer.js +0 -59
- package/dist/api-playground/ApiPlayground/components/PathHeader.js +0 -162
- package/dist/api-playground/ApiPlayground/components/TrashButton.js +0 -26
- package/dist/api-playground/ApiPlayground/index.js +0 -67
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/Enum.js +0 -19
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/NumberMetadata.js +0 -18
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/StringMetadata.js +0 -28
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js +0 -5
- package/dist/api-playground/EndpointFields/ParamFields/RecursiveParamField.js +0 -13
- package/dist/api-playground/EndpointFields/index.js +0 -7
- package/dist/api-playground-2/components/EndpointFields/EndpointSecurity.js +0 -87
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleArrayParamField.js +0 -89
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleObjectParamField.js +0 -121
- package/dist/api-playground-2/components/EndpointFields/fields/SimplePrimitiveParamField.js +0 -74
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleSchemaField.js +0 -252
- package/dist/common/potentiallyParseOpenApiString.js +0 -24
- package/dist/common/replaceSlashIndex.js +0 -6
- package/dist/common/slugToTitle.js +0 -10
- package/dist/constants/prism-languages.js +0 -19
- package/dist/contexts/ApiPlaygroundInputsContext.js +0 -17
- package/dist/contexts/MDXContentContext.js +0 -17
- package/dist/hooks/useApiPlaygroundInputs.js +0 -6
- package/dist/hooks/useApiPlaygroundPrefillExamples.js +0 -39
- package/dist/hooks/useBaseUrlOptions.js +0 -18
- package/dist/hooks/useComponentSchemas.js +0 -9
- package/dist/hooks/useGenerateNextAdditionalProperties.js +0 -11
- package/dist/hooks/useGenerateNextItems.js +0 -11
- package/dist/hooks/useGenerateNextProperties.js +0 -11
- package/dist/hooks/useMDXContent.js +0 -6
- package/dist/hooks/useMDXContentController/useApiPlaygroundInputs.js +0 -9
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback.js +0 -15
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback.js +0 -15
- package/dist/hooks/usePlaygroundSchemaOptions.js +0 -42
- package/dist/hooks/usePrefilledInputs/index.js +0 -65
- package/dist/hooks/usePrefilledInputs/storedServerVariables.js +0 -29
- package/dist/hooks/useSecurityOption.js +0 -10
- package/dist/hooks/useSetDefaultValue.js +0 -63
- package/dist/openapi/filterEnums.js +0 -20
- package/dist/openapi/generateNextAdditionalProperties.js +0 -7
- package/dist/openapi/generateNextItems.js +0 -7
- package/dist/openapi/generateNextProperties.js +0 -23
- package/dist/openapi/generateOptionLabels.js +0 -20
- package/dist/openapi/generateSimpleLabels.js +0 -4
- package/dist/openapi/getAuthFilteredSchemaArray.js +0 -18
- package/dist/paths/isEqualIgnoringLeadingSlash.js +0 -21
- package/dist/paths/optionallyRemoveLeadingSlash.js +0 -6
- package/dist/paths/optionallyRemoveTrailingSlash.js +0 -6
- package/dist/utils/api-playground/defaults.js +0 -15
- package/dist/utils/api-playground/paramFieldDefaults.js +0 -10
- package/dist/utils/api-reference/getFilteredSecurityOptions.js +0 -4
- package/dist/utils/api-reference/getNextPropertiesByType.js +0 -5
- package/dist/utils/flattenObject.js +0 -10
|
@@ -1,76 +1,82 @@
|
|
|
1
|
-
import { withDocumentProperties as
|
|
2
|
-
import { resolveGraphNode as
|
|
3
|
-
import { resolveOperationWithDependencies as
|
|
4
|
-
const
|
|
1
|
+
import { withDocumentProperties as y, getResolvedServers as v, getResolvedSecuritys as O } from "./getDocumentProperties.js";
|
|
2
|
+
import { resolveGraphNode as g } from "./resolveGraphNode.js";
|
|
3
|
+
import { resolveOperationWithDependencies as m } from "./resolveOperationWithDependencies.js";
|
|
4
|
+
const U = ({
|
|
5
5
|
operation: e,
|
|
6
|
-
target:
|
|
7
|
-
baseUrlOptions:
|
|
6
|
+
target: s,
|
|
7
|
+
baseUrlOptions: t
|
|
8
8
|
}) => {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
return Array.isArray(e["x-code-samples"]) && e["x-code-samples"].length > 0 && e["x-code-samples"].forEach((
|
|
13
|
-
|
|
14
|
-
label: "label" in
|
|
15
|
-
lang:
|
|
16
|
-
source:
|
|
9
|
+
let i, o = [];
|
|
10
|
+
t.length > 1 ? o = t : i = t[0];
|
|
11
|
+
const r = [];
|
|
12
|
+
return Array.isArray(e["x-code-samples"]) && e["x-code-samples"].length > 0 && e["x-code-samples"].forEach((n) => {
|
|
13
|
+
n && typeof n == "object" && "source" in n && typeof n.source == "string" && "lang" in n && typeof n.lang == "string" && r.push({
|
|
14
|
+
label: "label" in n && typeof n.label == "string" ? n.label : void 0,
|
|
15
|
+
lang: n.lang,
|
|
16
|
+
source: n.source
|
|
17
17
|
});
|
|
18
18
|
}), {
|
|
19
19
|
...e,
|
|
20
|
-
path:
|
|
21
|
-
baseUrl:
|
|
22
|
-
baseUrlOptions:
|
|
20
|
+
path: s.endpoint || "",
|
|
21
|
+
baseUrl: i,
|
|
22
|
+
baseUrlOptions: o,
|
|
23
23
|
title: e.summary ?? "",
|
|
24
24
|
description: e.description ?? "",
|
|
25
|
-
codeSamples:
|
|
25
|
+
codeSamples: r
|
|
26
26
|
};
|
|
27
|
-
},
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
27
|
+
}, u = (e, s, t) => {
|
|
28
|
+
const i = e.spec.refUuidMap[`${s}/${t}`];
|
|
29
|
+
if (i)
|
|
30
|
+
return i;
|
|
31
|
+
}, j = (e, s, t) => {
|
|
32
|
+
const i = u(e, s, t);
|
|
33
|
+
if (!i) return;
|
|
34
|
+
const o = g({
|
|
31
35
|
uuidObjectHashMap: e.spec.uuidObjectHashMap,
|
|
32
36
|
hashedNodeMap: e.spec.hashedNodeMap,
|
|
33
|
-
id:
|
|
37
|
+
id: i
|
|
34
38
|
});
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
let r;
|
|
40
|
+
return t === "webhook" ? r = Object.values(o || {})[0] : r = o == null ? void 0 : o[t], r;
|
|
41
|
+
}, $ = ({
|
|
37
42
|
target: e,
|
|
38
|
-
schemaGraphData:
|
|
43
|
+
schemaGraphData: s
|
|
39
44
|
}) => {
|
|
40
|
-
const { uuidObjectHashMap:
|
|
41
|
-
if (!
|
|
45
|
+
const { uuidObjectHashMap: t, hashedNodeMap: i } = s.spec, o = u(s, e.endpoint, e.method), r = j(s, e.endpoint, e.method);
|
|
46
|
+
if (!r)
|
|
42
47
|
throw new Error(
|
|
43
48
|
`no matching OpenAPI operation found with path "${e.endpoint}" and method "${e.method}"`
|
|
44
49
|
);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
const n = m({
|
|
51
|
+
pathUuid: o,
|
|
52
|
+
operationId: r,
|
|
53
|
+
uuidObjectHashMap: t,
|
|
54
|
+
hashedNodeMap: i
|
|
49
55
|
});
|
|
50
|
-
if (!
|
|
56
|
+
if (!n)
|
|
51
57
|
return {};
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
operation:
|
|
55
|
-
schemaGraphData:
|
|
58
|
+
let c = n.operation;
|
|
59
|
+
c = y({
|
|
60
|
+
operation: c,
|
|
61
|
+
schemaGraphData: s
|
|
56
62
|
});
|
|
57
|
-
const
|
|
58
|
-
operation:
|
|
63
|
+
const d = v(s), p = O(s), l = n.dependencies.security && Object.keys(n.dependencies.security).length > 0 ? n.dependencies.security : p, h = Object.values(d).map((b) => b.url), a = U({
|
|
64
|
+
operation: c,
|
|
59
65
|
target: e,
|
|
60
|
-
baseUrlOptions:
|
|
61
|
-
}),
|
|
62
|
-
...
|
|
63
|
-
servers:
|
|
64
|
-
security:
|
|
65
|
-
...
|
|
66
|
+
baseUrlOptions: h
|
|
67
|
+
}), f = {
|
|
68
|
+
...n.dependencies,
|
|
69
|
+
servers: d,
|
|
70
|
+
security: l,
|
|
71
|
+
...n.schemas && { schemas: n.schemas }
|
|
66
72
|
};
|
|
67
73
|
return {
|
|
68
|
-
operation:
|
|
69
|
-
dependencies:
|
|
74
|
+
operation: a,
|
|
75
|
+
dependencies: f
|
|
70
76
|
};
|
|
71
77
|
};
|
|
72
78
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
U as createOperationV2,
|
|
80
|
+
j as getOperationId,
|
|
81
|
+
$ as getSchemaGraphOperationData
|
|
76
82
|
};
|
|
@@ -1,38 +1,100 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isSchemaObject as
|
|
3
|
-
function
|
|
1
|
+
import f from "html-react-parser";
|
|
2
|
+
import { isSchemaObject as o } from "./utils.js";
|
|
3
|
+
function x(e, r) {
|
|
4
4
|
const t = /language-(\w+)/.exec(e ?? "");
|
|
5
5
|
return t ? t[1] ?? "text" : r ?? "text";
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
var a,
|
|
7
|
+
const y = (e) => {
|
|
8
|
+
var a, s;
|
|
9
9
|
const r = [], t = (a = e.attributes) == null ? void 0 : a.some(
|
|
10
|
-
(
|
|
10
|
+
(l) => l.name === "dropdown" && l.value !== "false"
|
|
11
11
|
);
|
|
12
|
-
return (
|
|
13
|
-
const
|
|
12
|
+
return (s = e.children) == null || s.map((l) => {
|
|
13
|
+
const i = f(l.html ?? ""), n = typeof i == "object" && !Array.isArray(i) && i.type === "pre" ? i.props.language ?? x(i.props.className, l.filename) : void 0;
|
|
14
14
|
r.push({
|
|
15
15
|
dropdown: t,
|
|
16
|
-
language:
|
|
17
|
-
code:
|
|
18
|
-
filename:
|
|
16
|
+
language: n,
|
|
17
|
+
code: i,
|
|
18
|
+
filename: l.filename
|
|
19
19
|
});
|
|
20
20
|
}), r;
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
}, O = (e) => {
|
|
22
|
+
let r = "generated";
|
|
23
|
+
return Object.entries(e).forEach(([t, a]) => {
|
|
24
|
+
const s = {};
|
|
25
|
+
if (a.examples)
|
|
26
|
+
Object.entries(a.examples).forEach(
|
|
27
|
+
([l, i]) => {
|
|
28
|
+
"$ref" in i || (s[l] = {
|
|
29
|
+
title: l,
|
|
30
|
+
description: i.description,
|
|
31
|
+
value: i.value
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
), e[t] && (e[t].examples = s), r = "examples";
|
|
35
|
+
else if (a.example)
|
|
36
|
+
s.Example = {
|
|
37
|
+
title: "Example",
|
|
38
|
+
value: a.example
|
|
39
|
+
}, e[t] && (e[t].examples = s), r = "examples";
|
|
40
|
+
else if (o(a.schema)) {
|
|
41
|
+
const l = c(a.schema);
|
|
42
|
+
l.length > 0 ? (l.forEach((i, n) => {
|
|
43
|
+
const m = l.length > 1 ? `Example ${n + 1}` : "Example";
|
|
44
|
+
s[m] = i;
|
|
45
|
+
}), e[t] && (e[t].examples = s), r = "examples") : (s.Example = p(a.schema), e[t] && (e[t].examples = s), r = "generated");
|
|
30
46
|
}
|
|
31
|
-
),
|
|
47
|
+
}), { content: e, exampleType: r };
|
|
48
|
+
};
|
|
49
|
+
function u(e) {
|
|
50
|
+
const r = [];
|
|
51
|
+
if (e.example !== void 0)
|
|
52
|
+
return r.push(e.example), r;
|
|
53
|
+
if (e.oneOf && Array.isArray(e.oneOf)) {
|
|
54
|
+
for (const t of e.oneOf)
|
|
55
|
+
if (o(t)) {
|
|
56
|
+
const a = u(t);
|
|
57
|
+
r.push(...a);
|
|
58
|
+
}
|
|
59
|
+
if (r.length > 0)
|
|
60
|
+
return r;
|
|
61
|
+
}
|
|
62
|
+
if (e.allOf && Array.isArray(e.allOf)) {
|
|
63
|
+
const t = {};
|
|
64
|
+
let a = !1;
|
|
65
|
+
for (const s of e.allOf)
|
|
66
|
+
if (o(s)) {
|
|
67
|
+
const i = u(s)[0];
|
|
68
|
+
i !== void 0 && typeof i == "object" && i !== null && (Object.assign(t, i), a = !0);
|
|
69
|
+
}
|
|
70
|
+
if (a)
|
|
71
|
+
return r.push(t), r;
|
|
72
|
+
}
|
|
73
|
+
if (e.type === "object" && e.properties) {
|
|
74
|
+
const t = {};
|
|
75
|
+
let a = !1;
|
|
76
|
+
for (const [s, l] of Object.entries(e.properties))
|
|
77
|
+
if (o(l)) {
|
|
78
|
+
const n = u(l)[0];
|
|
79
|
+
n !== void 0 && (t[s] = n, a = !0);
|
|
80
|
+
}
|
|
81
|
+
if (a)
|
|
82
|
+
return r.push(t), r;
|
|
83
|
+
}
|
|
84
|
+
if (e.type === "array" && o(e.items)) {
|
|
85
|
+
const a = u(e.items)[0];
|
|
86
|
+
if (a !== void 0)
|
|
87
|
+
return r.push([a]), r;
|
|
88
|
+
}
|
|
89
|
+
return r;
|
|
90
|
+
}
|
|
91
|
+
function c(e) {
|
|
92
|
+
return u(e).map((t) => ({
|
|
32
93
|
title: "Example",
|
|
33
|
-
value: t
|
|
34
|
-
}
|
|
35
|
-
}
|
|
94
|
+
value: t
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
const p = (e) => {
|
|
36
98
|
const r = {
|
|
37
99
|
title: "Example",
|
|
38
100
|
value: void 0
|
|
@@ -45,33 +107,33 @@ const g = (e) => {
|
|
|
45
107
|
return r.value = e.enum[0], r;
|
|
46
108
|
if (e.oneOf && Array.isArray(e.oneOf) && e.oneOf.length > 0) {
|
|
47
109
|
const t = e.oneOf[0];
|
|
48
|
-
if (
|
|
49
|
-
return
|
|
110
|
+
if (o(t))
|
|
111
|
+
return p(t);
|
|
50
112
|
}
|
|
51
113
|
switch (e.type) {
|
|
52
114
|
case "string":
|
|
53
|
-
return r.value =
|
|
115
|
+
return r.value = v(e), r;
|
|
54
116
|
case "boolean":
|
|
55
117
|
return r.value = !0, r;
|
|
56
118
|
case "number":
|
|
57
119
|
case "integer":
|
|
58
|
-
return r.value =
|
|
120
|
+
return r.value = E(e), r;
|
|
59
121
|
case "object":
|
|
60
122
|
return r.value = Object.fromEntries(
|
|
61
123
|
Object.entries(e.properties ?? {}).map(([t, a]) => [
|
|
62
124
|
t,
|
|
63
|
-
|
|
125
|
+
p(a).value
|
|
64
126
|
])
|
|
65
127
|
), r;
|
|
66
128
|
case "array":
|
|
67
|
-
return r.value = [
|
|
129
|
+
return r.value = [p(e.items).value], r;
|
|
68
130
|
default:
|
|
69
131
|
return r.value = "<unknown>", r;
|
|
70
132
|
}
|
|
71
|
-
},
|
|
133
|
+
}, E = (e) => {
|
|
72
134
|
const r = e.type === "integer" ? Math.floor : (t) => t;
|
|
73
135
|
return e.minimum !== void 0 && e.maximum !== void 0 ? r((e.minimum + e.maximum) / 2) : e.minimum !== void 0 ? r(e.minimum + 1) : e.maximum !== void 0 ? 123 < e.maximum ? 123 : r(e.maximum - 1) : 123;
|
|
74
|
-
},
|
|
136
|
+
}, v = (e) => {
|
|
75
137
|
var r;
|
|
76
138
|
switch ((r = e.format) == null ? void 0 : r.toLowerCase()) {
|
|
77
139
|
case "byte":
|
|
@@ -92,31 +154,34 @@ const g = (e) => {
|
|
|
92
154
|
default:
|
|
93
155
|
return "<string>";
|
|
94
156
|
}
|
|
95
|
-
},
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
157
|
+
}, d = (e, r) => {
|
|
158
|
+
const t = Object.keys(e)[r];
|
|
159
|
+
if (t) {
|
|
160
|
+
const a = e[t], l = Object.values((a == null ? void 0 : a.examples) ?? {})[0];
|
|
161
|
+
if (l && "value" in l)
|
|
162
|
+
return l.value;
|
|
101
163
|
}
|
|
102
|
-
},
|
|
103
|
-
var
|
|
104
|
-
const
|
|
105
|
-
if ((
|
|
106
|
-
const
|
|
107
|
-
|
|
164
|
+
}, j = (e, r) => {
|
|
165
|
+
var a, s;
|
|
166
|
+
const t = [];
|
|
167
|
+
if ((s = (a = e.dependencies) == null ? void 0 : a.requestBody) != null && s.content) {
|
|
168
|
+
const l = d(
|
|
169
|
+
e.dependencies.requestBody.content,
|
|
170
|
+
r
|
|
171
|
+
);
|
|
172
|
+
l && t.push({
|
|
108
173
|
language: "json",
|
|
109
174
|
filename: "Example Request Body",
|
|
110
|
-
code: JSON.stringify(
|
|
175
|
+
code: JSON.stringify(l.value, null, 2)
|
|
111
176
|
});
|
|
112
177
|
}
|
|
113
|
-
return
|
|
178
|
+
return t;
|
|
114
179
|
};
|
|
115
180
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
181
|
+
p as generateExampleFromSchema,
|
|
182
|
+
O as generateExamplesFromSchema,
|
|
183
|
+
d as getFirstExampleValue,
|
|
184
|
+
j as getFirstWebhookExample,
|
|
185
|
+
x as getLanguageFromClassName,
|
|
186
|
+
y as mdxCodeExampleToExamples
|
|
122
187
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { addTypeLabelsToSchema as r } from "./addTypeLabelsToSchema.js";
|
|
2
|
+
import { addUniqueKeysToSchema as s } from "./addUniqueKeysToSchema.js";
|
|
3
|
+
import { sortSchemaByRequired as m } from "./sortSchemaByRequired.js";
|
|
4
|
+
const p = (e) => {
|
|
5
|
+
const o = m(e), t = s(o, "");
|
|
6
|
+
return r(t);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
p as processSchema
|
|
10
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { v4 as
|
|
2
|
-
|
|
1
|
+
import { v4 as d } from "uuid";
|
|
2
|
+
import { getSecuritySchemeName as h } from "./utils.js";
|
|
3
|
+
const y = ["apiKey", "http", "oauth2"], b = "CoboAuth", B = ({
|
|
3
4
|
method: e,
|
|
4
|
-
name:
|
|
5
|
+
name: s
|
|
5
6
|
}) => {
|
|
6
|
-
const r =
|
|
7
|
+
const r = d();
|
|
7
8
|
let t;
|
|
8
9
|
switch (e) {
|
|
9
10
|
case "basic":
|
|
@@ -28,11 +29,22 @@ const c = ["apiKey", "http", "oauth2"], l = ({
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
break;
|
|
32
|
+
case "cobo":
|
|
33
|
+
t = {
|
|
34
|
+
[r]: {
|
|
35
|
+
[b]: {
|
|
36
|
+
type: "apiKey",
|
|
37
|
+
in: "header",
|
|
38
|
+
name: "API-SECRET"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
break;
|
|
31
43
|
case "key":
|
|
32
44
|
t = {
|
|
33
45
|
[r]: {
|
|
34
46
|
Key: {
|
|
35
|
-
name:
|
|
47
|
+
name: s ?? "Key",
|
|
36
48
|
type: "apiKey",
|
|
37
49
|
in: "header"
|
|
38
50
|
}
|
|
@@ -41,21 +53,26 @@ const c = ["apiKey", "http", "oauth2"], l = ({
|
|
|
41
53
|
break;
|
|
42
54
|
}
|
|
43
55
|
return t;
|
|
44
|
-
},
|
|
56
|
+
}, O = (e) => {
|
|
45
57
|
var t;
|
|
46
|
-
const
|
|
47
|
-
if (Object.keys(
|
|
58
|
+
const s = ((t = e.dependencies) == null ? void 0 : t.security) ?? {};
|
|
59
|
+
if (Object.keys(s).length === 0) return [];
|
|
48
60
|
const r = [];
|
|
49
|
-
return Object.entries(
|
|
50
|
-
([
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
return Object.entries(s).forEach(
|
|
62
|
+
([k, c]) => {
|
|
63
|
+
const a = [];
|
|
64
|
+
if (Object.entries(c).forEach(([n, i]) => {
|
|
65
|
+
if (y.includes(i.type)) {
|
|
66
|
+
const u = n, p = h(i), o = g(i);
|
|
67
|
+
o && a.push({ scheme: i, schema: o, schemeName: u, name: p });
|
|
68
|
+
}
|
|
69
|
+
}), a.length > 0) {
|
|
70
|
+
const n = a.map((i) => i.schemeName).join(" & ");
|
|
71
|
+
r.push({ schemes: a, title: n });
|
|
55
72
|
}
|
|
56
73
|
}
|
|
57
74
|
), r;
|
|
58
|
-
},
|
|
75
|
+
}, f = "Basic authentication header of the form `Basic <encoded-value>`, where `<encoded-value>` is the base64-encoded string `username:password`.", l = "Bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token.", m = "The access token received from the authorization server in the OAuth 2.0 flow.", g = (e) => {
|
|
59
76
|
switch (e.type) {
|
|
60
77
|
case "apiKey":
|
|
61
78
|
return {
|
|
@@ -63,17 +80,28 @@ const c = ["apiKey", "http", "oauth2"], l = ({
|
|
|
63
80
|
type: "string",
|
|
64
81
|
description: e.description,
|
|
65
82
|
isRequired: !0,
|
|
66
|
-
default: e["x-default"]
|
|
83
|
+
default: e["x-default"],
|
|
84
|
+
typeLabel: "string"
|
|
67
85
|
};
|
|
68
86
|
case "http":
|
|
69
87
|
return e.scheme === "basic" ? {
|
|
70
88
|
title: "Basic Auth",
|
|
71
89
|
type: "object",
|
|
72
|
-
description: e.description ??
|
|
90
|
+
description: e.description ?? f,
|
|
73
91
|
isRequired: !0,
|
|
74
92
|
properties: {
|
|
75
|
-
username: {
|
|
76
|
-
|
|
93
|
+
username: {
|
|
94
|
+
type: "string",
|
|
95
|
+
uniqueKey: "username",
|
|
96
|
+
isRequired: !0,
|
|
97
|
+
typeLabel: "string"
|
|
98
|
+
},
|
|
99
|
+
password: {
|
|
100
|
+
type: "string",
|
|
101
|
+
uniqueKey: "password",
|
|
102
|
+
isRequired: !0,
|
|
103
|
+
typeLabel: "string"
|
|
104
|
+
}
|
|
77
105
|
},
|
|
78
106
|
additionalProperties: !1,
|
|
79
107
|
default: e["x-default"]
|
|
@@ -81,26 +109,28 @@ const c = ["apiKey", "http", "oauth2"], l = ({
|
|
|
81
109
|
title: "Bearer Auth",
|
|
82
110
|
type: "string",
|
|
83
111
|
isRequired: !0,
|
|
84
|
-
description: e.description ??
|
|
112
|
+
description: e.description ?? l,
|
|
85
113
|
format: "bearer",
|
|
86
|
-
default: e["x-default"]
|
|
114
|
+
default: e["x-default"],
|
|
115
|
+
typeLabel: "string<bearer>"
|
|
87
116
|
};
|
|
88
117
|
case "oauth2":
|
|
89
118
|
return {
|
|
90
119
|
title: "OAuth2 Auth",
|
|
91
120
|
type: "string",
|
|
92
121
|
isRequired: !0,
|
|
93
|
-
description: e.description ??
|
|
94
|
-
format: "bearer"
|
|
122
|
+
description: e.description ?? m,
|
|
123
|
+
format: "bearer",
|
|
124
|
+
typeLabel: "string<bearer>"
|
|
95
125
|
};
|
|
96
126
|
default:
|
|
97
127
|
return;
|
|
98
128
|
}
|
|
99
129
|
};
|
|
100
130
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
131
|
+
f as basicDescription,
|
|
132
|
+
l as bearerDescription,
|
|
133
|
+
B as getDocsJsonSecurityOptions,
|
|
134
|
+
m as oauth2Description,
|
|
135
|
+
O as processSecurityOptions
|
|
106
136
|
};
|