@mintlify/msft-sdk 1.1.62 → 1.1.64

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