@gitbook/react-openapi 1.4.2 → 1.5.1

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 (225) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/index.d.ts +663 -10
  3. package/dist/index.js +3873 -8
  4. package/package.json +11 -7
  5. package/dist/InteractiveSection.d.ts +0 -33
  6. package/dist/InteractiveSection.jsx +0 -61
  7. package/dist/Markdown.d.ts +0 -4
  8. package/dist/Markdown.jsx +0 -5
  9. package/dist/OpenAPICodeSample.d.ts +0 -19
  10. package/dist/OpenAPICodeSample.jsx +0 -230
  11. package/dist/OpenAPICodeSampleInteractive.d.ts +0 -14
  12. package/dist/OpenAPICodeSampleInteractive.jsx +0 -73
  13. package/dist/OpenAPICodeSampleSelector.d.ts +0 -14
  14. package/dist/OpenAPICodeSampleSelector.jsx +0 -44
  15. package/dist/OpenAPICopyButton.d.ts +0 -13
  16. package/dist/OpenAPICopyButton.jsx +0 -35
  17. package/dist/OpenAPIDisclosure.d.ts +0 -11
  18. package/dist/OpenAPIDisclosure.jsx +0 -30
  19. package/dist/OpenAPIDisclosureGroup.d.ts +0 -23
  20. package/dist/OpenAPIDisclosureGroup.jsx +0 -83
  21. package/dist/OpenAPIExample.d.ts +0 -16
  22. package/dist/OpenAPIExample.jsx +0 -36
  23. package/dist/OpenAPIMediaType.d.ts +0 -21
  24. package/dist/OpenAPIMediaType.jsx +0 -61
  25. package/dist/OpenAPIOperation.d.ts +0 -10
  26. package/dist/OpenAPIOperation.jsx +0 -25
  27. package/dist/OpenAPIOperationContext.d.ts +0 -16
  28. package/dist/OpenAPIOperationContext.jsx +0 -26
  29. package/dist/OpenAPIOperationDescription.d.ts +0 -9
  30. package/dist/OpenAPIOperationDescription.jsx +0 -22
  31. package/dist/OpenAPIOperationStability.d.ts +0 -9
  32. package/dist/OpenAPIOperationStability.jsx +0 -27
  33. package/dist/OpenAPIPath.d.ts +0 -18
  34. package/dist/OpenAPIPath.jsx +0 -55
  35. package/dist/OpenAPIPrefillContextProvider.d.ts +0 -22
  36. package/dist/OpenAPIPrefillContextProvider.jsx +0 -19
  37. package/dist/OpenAPIRequestBody.d.ts +0 -11
  38. package/dist/OpenAPIRequestBody.jsx +0 -28
  39. package/dist/OpenAPIRequestBodyHeaderType.d.ts +0 -8
  40. package/dist/OpenAPIRequestBodyHeaderType.jsx +0 -25
  41. package/dist/OpenAPIResponse.d.ts +0 -10
  42. package/dist/OpenAPIResponse.jsx +0 -57
  43. package/dist/OpenAPIResponseExample.d.ts +0 -9
  44. package/dist/OpenAPIResponseExample.jsx +0 -105
  45. package/dist/OpenAPIResponseExampleContent.d.ts +0 -22
  46. package/dist/OpenAPIResponseExampleContent.jsx +0 -60
  47. package/dist/OpenAPIResponses.d.ts +0 -9
  48. package/dist/OpenAPIResponses.jsx +0 -77
  49. package/dist/OpenAPISchema.d.ts +0 -27
  50. package/dist/OpenAPISchema.jsx +0 -400
  51. package/dist/OpenAPISchemaName.d.ts +0 -16
  52. package/dist/OpenAPISchemaName.jsx +0 -43
  53. package/dist/OpenAPISchemaServer.d.ts +0 -12
  54. package/dist/OpenAPISchemaServer.jsx +0 -8
  55. package/dist/OpenAPISecurities.d.ts +0 -9
  56. package/dist/OpenAPISecurities.jsx +0 -114
  57. package/dist/OpenAPISelect.d.ts +0 -22
  58. package/dist/OpenAPISelect.jsx +0 -44
  59. package/dist/OpenAPISpec.d.ts +0 -6
  60. package/dist/OpenAPISpec.jsx +0 -80
  61. package/dist/OpenAPITabs.d.ts +0 -26
  62. package/dist/OpenAPITabs.jsx +0 -109
  63. package/dist/OpenAPIWebhook.d.ts +0 -10
  64. package/dist/OpenAPIWebhook.jsx +0 -23
  65. package/dist/OpenAPIWebhookExample.d.ts +0 -6
  66. package/dist/OpenAPIWebhookExample.jsx +0 -41
  67. package/dist/ScalarApiButton.d.ts +0 -14
  68. package/dist/ScalarApiButton.jsx +0 -81
  69. package/dist/StaticSection.d.ts +0 -13
  70. package/dist/StaticSection.jsx +0 -32
  71. package/dist/code-samples.d.ts +0 -17
  72. package/dist/code-samples.js +0 -427
  73. package/dist/common/OpenAPIColumnSpec.d.ts +0 -6
  74. package/dist/common/OpenAPIColumnSpec.jsx +0 -20
  75. package/dist/common/OpenAPIOperationDescription.d.ts +0 -6
  76. package/dist/common/OpenAPIOperationDescription.jsx +0 -19
  77. package/dist/common/OpenAPIStability.d.ts +0 -4
  78. package/dist/common/OpenAPIStability.jsx +0 -15
  79. package/dist/common/OpenAPISummary.d.ts +0 -6
  80. package/dist/common/OpenAPISummary.jsx +0 -30
  81. package/dist/contentTypeChecks.d.ts +0 -10
  82. package/dist/contentTypeChecks.js +0 -30
  83. package/dist/context.d.ts +0 -75
  84. package/dist/context.js +0 -43
  85. package/dist/decycle.d.ts +0 -2
  86. package/dist/decycle.js +0 -70
  87. package/dist/dereference.d.ts +0 -5
  88. package/dist/dereference.js +0 -68
  89. package/dist/generateSchemaExample.d.ts +0 -45
  90. package/dist/generateSchemaExample.js +0 -342
  91. package/dist/getDisclosureLabel.d.ts +0 -7
  92. package/dist/getDisclosureLabel.js +0 -18
  93. package/dist/getOrCreateStoreByKey.d.ts +0 -10
  94. package/dist/getOrCreateStoreByKey.js +0 -19
  95. package/dist/json2xml.d.ts +0 -4
  96. package/dist/json2xml.js +0 -7
  97. package/dist/resolveOpenAPIOperation.d.ts +0 -11
  98. package/dist/resolveOpenAPIOperation.js +0 -173
  99. package/dist/resolveOpenAPIWebhook.d.ts +0 -11
  100. package/dist/resolveOpenAPIWebhook.js +0 -127
  101. package/dist/schemas/OpenAPISchemaItem.d.ts +0 -7
  102. package/dist/schemas/OpenAPISchemaItem.jsx +0 -16
  103. package/dist/schemas/OpenAPISchemas.d.ts +0 -14
  104. package/dist/schemas/OpenAPISchemas.jsx +0 -59
  105. package/dist/schemas/index.d.ts +0 -2
  106. package/dist/schemas/index.js +0 -2
  107. package/dist/schemas/resolveOpenAPISchemas.d.ts +0 -10
  108. package/dist/schemas/resolveOpenAPISchemas.js +0 -61
  109. package/dist/stringifyOpenAPI.d.ts +0 -4
  110. package/dist/stringifyOpenAPI.js +0 -15
  111. package/dist/translate.d.ts +0 -10
  112. package/dist/translate.jsx +0 -75
  113. package/dist/translations/de.d.ts +0 -43
  114. package/dist/translations/de.js +0 -43
  115. package/dist/translations/en.d.ts +0 -43
  116. package/dist/translations/en.js +0 -43
  117. package/dist/translations/es.d.ts +0 -43
  118. package/dist/translations/es.js +0 -43
  119. package/dist/translations/fr.d.ts +0 -43
  120. package/dist/translations/fr.js +0 -43
  121. package/dist/translations/index.d.ts +0 -395
  122. package/dist/translations/index.js +0 -27
  123. package/dist/translations/ja.d.ts +0 -43
  124. package/dist/translations/ja.js +0 -43
  125. package/dist/translations/nl.d.ts +0 -43
  126. package/dist/translations/nl.js +0 -43
  127. package/dist/translations/no.d.ts +0 -43
  128. package/dist/translations/no.js +0 -43
  129. package/dist/translations/pt-br.d.ts +0 -43
  130. package/dist/translations/pt-br.js +0 -43
  131. package/dist/translations/types.d.ts +0 -5
  132. package/dist/translations/types.js +0 -1
  133. package/dist/translations/zh.d.ts +0 -43
  134. package/dist/translations/zh.js +0 -43
  135. package/dist/tsconfig.build.tsbuildinfo +0 -1
  136. package/dist/types.d.ts +0 -31
  137. package/dist/types.js +0 -1
  138. package/dist/util/example.d.ts +0 -35
  139. package/dist/util/example.jsx +0 -103
  140. package/dist/util/server.d.ts +0 -9
  141. package/dist/util/server.js +0 -44
  142. package/dist/util/tryit-prefill.d.ts +0 -20
  143. package/dist/util/tryit-prefill.js +0 -129
  144. package/dist/utils.d.ts +0 -50
  145. package/dist/utils.js +0 -224
  146. package/src/InteractiveSection.tsx +0 -147
  147. package/src/Markdown.tsx +0 -12
  148. package/src/OpenAPICodeSample.tsx +0 -330
  149. package/src/OpenAPICodeSampleInteractive.tsx +0 -136
  150. package/src/OpenAPICodeSampleSelector.tsx +0 -94
  151. package/src/OpenAPICopyButton.tsx +0 -72
  152. package/src/OpenAPIDisclosure.tsx +0 -46
  153. package/src/OpenAPIDisclosureGroup.tsx +0 -158
  154. package/src/OpenAPIExample.tsx +0 -55
  155. package/src/OpenAPIMediaType.tsx +0 -139
  156. package/src/OpenAPIOperation.tsx +0 -35
  157. package/src/OpenAPIOperationContext.tsx +0 -45
  158. package/src/OpenAPIOperationDescription.tsx +0 -34
  159. package/src/OpenAPIOperationStability.tsx +0 -39
  160. package/src/OpenAPIPath.tsx +0 -90
  161. package/src/OpenAPIPrefillContextProvider.tsx +0 -40
  162. package/src/OpenAPIRequestBody.tsx +0 -54
  163. package/src/OpenAPIRequestBodyHeaderType.tsx +0 -36
  164. package/src/OpenAPIResponse.tsx +0 -82
  165. package/src/OpenAPIResponseExample.tsx +0 -151
  166. package/src/OpenAPIResponseExampleContent.tsx +0 -125
  167. package/src/OpenAPIResponses.tsx +0 -125
  168. package/src/OpenAPISchema.test.ts +0 -172
  169. package/src/OpenAPISchema.tsx +0 -654
  170. package/src/OpenAPISchemaName.tsx +0 -80
  171. package/src/OpenAPISchemaServer.tsx +0 -34
  172. package/src/OpenAPISecurities.tsx +0 -231
  173. package/src/OpenAPISelect.tsx +0 -96
  174. package/src/OpenAPISpec.tsx +0 -138
  175. package/src/OpenAPITabs.tsx +0 -147
  176. package/src/OpenAPIWebhook.tsx +0 -33
  177. package/src/OpenAPIWebhookExample.tsx +0 -60
  178. package/src/ScalarApiButton.tsx +0 -132
  179. package/src/StaticSection.tsx +0 -91
  180. package/src/__snapshots__/json2xml.test.ts.snap +0 -18
  181. package/src/code-samples.test.ts +0 -714
  182. package/src/code-samples.ts +0 -448
  183. package/src/common/OpenAPIColumnSpec.tsx +0 -31
  184. package/src/common/OpenAPIOperationDescription.tsx +0 -31
  185. package/src/common/OpenAPIStability.tsx +0 -23
  186. package/src/common/OpenAPISummary.tsx +0 -45
  187. package/src/contentTypeChecks.ts +0 -39
  188. package/src/context.ts +0 -99
  189. package/src/decycle.ts +0 -68
  190. package/src/dereference.ts +0 -29
  191. package/src/generateSchemaExample.test.ts +0 -1040
  192. package/src/generateSchemaExample.ts +0 -530
  193. package/src/getDisclosureLabel.ts +0 -25
  194. package/src/getOrCreateStoreByKey.ts +0 -33
  195. package/src/index.ts +0 -10
  196. package/src/json2xml.test.ts +0 -46
  197. package/src/json2xml.ts +0 -8
  198. package/src/resolveOpenAPIOperation.test.ts +0 -177
  199. package/src/resolveOpenAPIOperation.ts +0 -151
  200. package/src/resolveOpenAPIWebhook.ts +0 -99
  201. package/src/schemas/OpenAPISchemaItem.tsx +0 -34
  202. package/src/schemas/OpenAPISchemas.tsx +0 -98
  203. package/src/schemas/index.ts +0 -2
  204. package/src/schemas/resolveOpenAPISchemas.test.ts +0 -174
  205. package/src/schemas/resolveOpenAPISchemas.ts +0 -28
  206. package/src/stringifyOpenAPI.ts +0 -25
  207. package/src/translate.tsx +0 -80
  208. package/src/translations/de.ts +0 -43
  209. package/src/translations/en.ts +0 -43
  210. package/src/translations/es.ts +0 -43
  211. package/src/translations/fr.ts +0 -43
  212. package/src/translations/index.ts +0 -33
  213. package/src/translations/ja.ts +0 -43
  214. package/src/translations/nl.ts +0 -43
  215. package/src/translations/no.ts +0 -43
  216. package/src/translations/pt-br.ts +0 -43
  217. package/src/translations/types.ts +0 -7
  218. package/src/translations/zh.ts +0 -43
  219. package/src/types.ts +0 -46
  220. package/src/util/example.tsx +0 -129
  221. package/src/util/server.test.ts +0 -58
  222. package/src/util/server.ts +0 -47
  223. package/src/util/tryit-prefill.test.ts +0 -311
  224. package/src/util/tryit-prefill.ts +0 -160
  225. package/src/utils.ts +0 -255
@@ -1,173 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
- import { fromJSON, toJSON } from 'flatted';
58
- import { dereferenceFilesystem } from './dereference';
59
- import { checkIsReference } from './utils';
60
- export { fromJSON, toJSON };
61
- /**
62
- * Resolve an OpenAPI operation in a file and compile it to a more usable format.
63
- */
64
- export function resolveOpenAPIOperation(filesystem, operationDescriptor) {
65
- return __awaiter(this, void 0, void 0, function () {
66
- var path, method, schema, operation, commonParameters, servers, schemaSecurity, security, isOptionalSecurity, flatSecurities, securities, _i, flatSecurities_1, entry, securityKey, securityScheme;
67
- var _a, _b, _c, _d, _e;
68
- return __generator(this, function (_f) {
69
- switch (_f.label) {
70
- case 0:
71
- path = operationDescriptor.path, method = operationDescriptor.method;
72
- return [4 /*yield*/, dereferenceFilesystem(filesystem)];
73
- case 1:
74
- schema = _f.sent();
75
- operation = getOperationByPathAndMethod(schema, path, method);
76
- if (!operation) {
77
- return [2 /*return*/, null];
78
- }
79
- commonParameters = getPathObjectParameter(schema, path);
80
- if (commonParameters) {
81
- operation = __assign(__assign({}, operation), { parameters: __spreadArray(__spreadArray([], commonParameters, true), ((_a = operation.parameters) !== null && _a !== void 0 ? _a : []), true) });
82
- }
83
- servers = 'servers' in schema ? ((_b = schema.servers) !== null && _b !== void 0 ? _b : []) : [];
84
- schemaSecurity = Array.isArray(schema.security)
85
- ? schema.security
86
- : schema.security
87
- ? [schema.security]
88
- : [];
89
- security = (_c = operation.security) !== null && _c !== void 0 ? _c : schemaSecurity;
90
- isOptionalSecurity = security.some(function (entry) { return Object.keys(entry).length === 0; });
91
- flatSecurities = flattenSecurities(security);
92
- securities = [];
93
- for (_i = 0, flatSecurities_1 = flatSecurities; _i < flatSecurities_1.length; _i++) {
94
- entry = flatSecurities_1[_i];
95
- securityKey = Object.keys(entry)[0];
96
- if (securityKey) {
97
- securityScheme = (_e = (_d = schema.components) === null || _d === void 0 ? void 0 : _d.securitySchemes) === null || _e === void 0 ? void 0 : _e[securityKey];
98
- if (securityScheme && !checkIsReference(securityScheme)) {
99
- securities.push([
100
- securityKey,
101
- __assign(__assign({}, securityScheme), { required: !isOptionalSecurity }),
102
- ]);
103
- }
104
- }
105
- }
106
- return [2 /*return*/, {
107
- servers: servers,
108
- operation: operation,
109
- method: method,
110
- path: path,
111
- securities: securities,
112
- 'x-codeSamples': typeof schema['x-codeSamples'] === 'boolean' ? schema['x-codeSamples'] : undefined,
113
- 'x-hideTryItPanel': typeof schema['x-hideTryItPanel'] === 'boolean'
114
- ? schema['x-hideTryItPanel']
115
- : undefined,
116
- }];
117
- }
118
- });
119
- });
120
- }
121
- /**
122
- * Get a path object from its path.
123
- */
124
- function getPathObject(schema, path) {
125
- var _a;
126
- if ((_a = schema.paths) === null || _a === void 0 ? void 0 : _a[path]) {
127
- return schema.paths[path];
128
- }
129
- return null;
130
- }
131
- /**
132
- * Resolve parameters from a path in an OpenAPI schema.
133
- */
134
- function getPathObjectParameter(schema, path) {
135
- var pathObject = getPathObject(schema, path);
136
- if (pathObject === null || pathObject === void 0 ? void 0 : pathObject.parameters) {
137
- return pathObject.parameters;
138
- }
139
- return null;
140
- }
141
- /**
142
- * Get an operation by its path and method.
143
- */
144
- function getOperationByPathAndMethod(schema, path, method) {
145
- // Types are buffy for OpenAPIV3_1.OperationObject, so we use v3
146
- var pathObject = getPathObject(schema, path);
147
- if (!pathObject) {
148
- return null;
149
- }
150
- var normalizedMethod = method.toLowerCase();
151
- if (!pathObject[normalizedMethod]) {
152
- return null;
153
- }
154
- return pathObject[normalizedMethod];
155
- }
156
- /**
157
- * Flatten security objects in case they are nested.
158
- * @example [{bearerAuth:[], basicAuth:[]}] => [{ bearerAuth: [] }, { basicAuth: [] }]
159
- */
160
- function flattenSecurities(security) {
161
- if (!Array.isArray(security) || security.length === 0) {
162
- return [];
163
- }
164
- return security.flatMap(function (securityObject) {
165
- return Object.entries(securityObject).map(function (_a) {
166
- var _b;
167
- var authType = _a[0], config = _a[1];
168
- return (_b = {},
169
- _b[authType] = config,
170
- _b);
171
- });
172
- });
173
- }
@@ -1,11 +0,0 @@
1
- import { fromJSON, toJSON } from 'flatted';
2
- import type { Filesystem, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
3
- import type { OpenAPIWebhookData } from './types';
4
- export { fromJSON, toJSON };
5
- /**
6
- * Resolve an OpenAPI webhook in a file and compile it to a more usable format.
7
- */
8
- export declare function resolveOpenAPIWebhook(filesystem: Filesystem<OpenAPIV3xDocument>, webhookDescriptor: {
9
- name: string;
10
- method: string;
11
- }): Promise<OpenAPIWebhookData | null>;
@@ -1,127 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
- import { fromJSON, toJSON } from 'flatted';
58
- import { dereferenceFilesystem } from './dereference';
59
- export { fromJSON, toJSON };
60
- /**
61
- * Resolve an OpenAPI webhook in a file and compile it to a more usable format.
62
- */
63
- export function resolveOpenAPIWebhook(filesystem, webhookDescriptor) {
64
- return __awaiter(this, void 0, void 0, function () {
65
- var name, method, schema, operation, commonParameters, servers;
66
- var _a, _b;
67
- return __generator(this, function (_c) {
68
- switch (_c.label) {
69
- case 0:
70
- name = webhookDescriptor.name, method = webhookDescriptor.method;
71
- return [4 /*yield*/, dereferenceFilesystem(filesystem)];
72
- case 1:
73
- schema = _c.sent();
74
- operation = getWebhookByNameAndMethod(schema, name, method);
75
- if (!operation) {
76
- return [2 /*return*/, null];
77
- }
78
- commonParameters = getPathObjectParameter(schema, name);
79
- if (commonParameters) {
80
- operation = __assign(__assign({}, operation), { parameters: __spreadArray(__spreadArray([], commonParameters, true), ((_a = operation.parameters) !== null && _a !== void 0 ? _a : []), true) });
81
- }
82
- servers = 'servers' in schema ? ((_b = schema.servers) !== null && _b !== void 0 ? _b : []) : [];
83
- return [2 /*return*/, {
84
- servers: servers,
85
- operation: operation,
86
- method: method,
87
- name: name,
88
- }];
89
- }
90
- });
91
- });
92
- }
93
- /**
94
- * Get a path object from its path.
95
- */
96
- function getPathObject(schema, name) {
97
- var _a;
98
- if ((_a = schema.webhooks) === null || _a === void 0 ? void 0 : _a[name]) {
99
- return schema.webhooks[name];
100
- }
101
- return null;
102
- }
103
- /**
104
- * Resolve parameters from a path in an OpenAPI schema.
105
- */
106
- function getPathObjectParameter(schema, path) {
107
- var pathObject = getPathObject(schema, path);
108
- if (pathObject === null || pathObject === void 0 ? void 0 : pathObject.parameters) {
109
- return pathObject.parameters;
110
- }
111
- return null;
112
- }
113
- /**
114
- * Get an operation by its path and method.
115
- */
116
- function getWebhookByNameAndMethod(schema, name, method) {
117
- // Types are buffy for OpenAPIV3_1.OperationObject, so we use v3
118
- var pathObject = getPathObject(schema, name);
119
- if (!pathObject) {
120
- return null;
121
- }
122
- var normalizedMethod = method.toLowerCase();
123
- if (!pathObject[normalizedMethod]) {
124
- return null;
125
- }
126
- return pathObject[normalizedMethod];
127
- }
@@ -1,7 +0,0 @@
1
- import type { OpenAPIV3 } from '@gitbook/openapi-parser';
2
- import type { OpenAPIClientContext } from '../context';
3
- export declare function OpenAPISchemaItem(props: {
4
- name: string;
5
- schema: OpenAPIV3.SchemaObject;
6
- context: OpenAPIClientContext;
7
- }): import("react").JSX.Element;
@@ -1,16 +0,0 @@
1
- 'use client';
2
- import { SectionBody } from '../StaticSection';
3
- import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
4
- import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
5
- import { Section } from '../StaticSection';
6
- import { getDisclosureLabel } from '../getDisclosureLabel';
7
- export function OpenAPISchemaItem(props) {
8
- var schema = props.schema, context = props.context, name = props.name;
9
- return (<OpenAPIDisclosure className="openapi-schemas-disclosure" key={name} icon={context.icons.plus} header={name} label={function (isExpanded) { return getDisclosureLabel({ schema: schema, isExpanded: isExpanded, context: context }); }}>
10
- <Section className="openapi-section-schemas">
11
- <SectionBody>
12
- <OpenAPIRootSchema schema={schema} context={context}/>
13
- </SectionBody>
14
- </Section>
15
- </OpenAPIDisclosure>);
16
- }
@@ -1,14 +0,0 @@
1
- import type { OpenAPISchema } from '@gitbook/openapi-parser';
2
- import { type OpenAPIContextInput } from '../context';
3
- /**
4
- * OpenAPI Schemas component.
5
- */
6
- export declare function OpenAPISchemas(props: {
7
- className?: string;
8
- schemas: OpenAPISchema[];
9
- context: OpenAPIContextInput;
10
- /**
11
- * Whether to show the schema directly if there is only one.
12
- */
13
- grouped?: boolean;
14
- }): import("react").JSX.Element | null;
@@ -1,59 +0,0 @@
1
- import clsx from 'clsx';
2
- import { OpenAPIExample } from '../OpenAPIExample';
3
- import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
4
- import { StaticSection } from '../StaticSection';
5
- import { getOpenAPIClientContext, resolveOpenAPIContext, } from '../context';
6
- import { t } from '../translate';
7
- import { getExampleFromSchema } from '../util/example';
8
- import { OpenAPISchemaItem } from './OpenAPISchemaItem';
9
- /**
10
- * OpenAPI Schemas component.
11
- */
12
- export function OpenAPISchemas(props) {
13
- var schemas = props.schemas, contextInput = props.context, grouped = props.grouped, className = props.className;
14
- var firstSchema = schemas[0];
15
- if (!firstSchema) {
16
- return null;
17
- }
18
- var context = resolveOpenAPIContext(contextInput);
19
- var clientContext = getOpenAPIClientContext(context);
20
- // If there is only one model and we are not grouping, we show it directly.
21
- if (schemas.length === 1 && !grouped) {
22
- var title = "The ".concat(firstSchema.name, " object");
23
- return (<div className={clsx('openapi-schemas', className)}>
24
- <div className="openapi-summary" id={context.id}>
25
- {context.renderHeading({
26
- title: title,
27
- deprecated: Boolean(firstSchema.schema.deprecated),
28
- stability: firstSchema.schema['x-stability'],
29
- })}
30
- </div>
31
- <div className="openapi-columns">
32
- <div className="openapi-column-spec">
33
- <StaticSection className="openapi-parameters" header={t(context.translation, 'attributes')}>
34
- <OpenAPIRootSchema schema={firstSchema.schema} context={clientContext}/>
35
- </StaticSection>
36
- </div>
37
- <div className="openapi-column-preview">
38
- <div className="openapi-column-preview-body">
39
- <div className="openapi-panel">
40
- <h4 className="openapi-panel-heading">{title}</h4>
41
- <div className="openapi-panel-body">
42
- <OpenAPIExample example={getExampleFromSchema({
43
- schema: firstSchema.schema,
44
- })} context={context} syntax="json"/>
45
- </div>
46
- </div>
47
- </div>
48
- </div>
49
- </div>
50
- </div>);
51
- }
52
- // If there are multiple schemas, we use a disclosure group to show them all.
53
- return (<div className={clsx('openapi-schemas', className)}>
54
- {schemas.map(function (_a) {
55
- var name = _a.name, schema = _a.schema;
56
- return (<OpenAPISchemaItem key={name} name={name} context={clientContext} schema={schema}/>);
57
- })}
58
- </div>);
59
- }
@@ -1,2 +0,0 @@
1
- export * from './OpenAPISchemas';
2
- export * from './resolveOpenAPISchemas';
@@ -1,2 +0,0 @@
1
- export * from './OpenAPISchemas';
2
- export * from './resolveOpenAPISchemas';
@@ -1,10 +0,0 @@
1
- import type { Filesystem, OpenAPISchema, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
2
- /**
3
- * Resolve an OpenAPI schemas from a file and compile it to a more usable format.
4
- * Schemas are extracted from the OpenAPI components.schemas
5
- */
6
- export declare function resolveOpenAPISchemas(filesystem: Filesystem<OpenAPIV3xDocument>, options: {
7
- schemas: string[];
8
- }): Promise<{
9
- schemas: OpenAPISchema[];
10
- } | null>;
@@ -1,61 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { filterSelectedOpenAPISchemas } from '@gitbook/openapi-parser';
38
- import { dereferenceFilesystem } from '../dereference';
39
- /**
40
- * Resolve an OpenAPI schemas from a file and compile it to a more usable format.
41
- * Schemas are extracted from the OpenAPI components.schemas
42
- */
43
- export function resolveOpenAPISchemas(filesystem, options) {
44
- return __awaiter(this, void 0, void 0, function () {
45
- var selectedSchemas, schema, schemas;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0:
49
- selectedSchemas = options.schemas;
50
- return [4 /*yield*/, dereferenceFilesystem(filesystem)];
51
- case 1:
52
- schema = _a.sent();
53
- schemas = filterSelectedOpenAPISchemas(schema, selectedSchemas);
54
- if (schemas.length === 0) {
55
- return [2 /*return*/, null];
56
- }
57
- return [2 /*return*/, { schemas: schemas }];
58
- }
59
- });
60
- });
61
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Stringify an OpenAPI object. Same API as JSON.stringify.
3
- */
4
- export declare function stringifyOpenAPI(value: any, replacer?: ((this: any, key: string, value: any) => any) | null, space?: string | number): string;
@@ -1,15 +0,0 @@
1
- /**
2
- * Stringify an OpenAPI object. Same API as JSON.stringify.
3
- */
4
- export function stringifyOpenAPI(value, replacer, space) {
5
- return JSON.stringify(value, function (key, value) {
6
- // Ignore internal keys
7
- if (key.startsWith('x-gitbook-')) {
8
- return undefined;
9
- }
10
- if (replacer) {
11
- return replacer(key, value);
12
- }
13
- return value;
14
- }, space);
15
- }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import type { Translation, TranslationKey } from './translations';
3
- /**
4
- * Translate a string.
5
- */
6
- export declare function t(translation: Translation, id: TranslationKey, ...args: React.ReactNode[]): React.ReactNode;
7
- /**
8
- * Version of `t` that returns a string.
9
- */
10
- export declare function tString(translation: Translation, id: TranslationKey, ...args: React.ReactNode[]): string;
@@ -1,75 +0,0 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
- import React from 'react';
11
- /**
12
- * Translate a string.
13
- */
14
- export function t(translation, id) {
15
- var args = [];
16
- for (var _i = 2; _i < arguments.length; _i++) {
17
- args[_i - 2] = arguments[_i];
18
- }
19
- var string = translation[id];
20
- if (!string) {
21
- throw new Error("Translation not found for \"".concat(id, "\""));
22
- }
23
- // Now we are going to replace the arguments
24
- // but we want to return a string as long as it's possible
25
- // (eg. if there isn't any argument that is a ReactNode)
26
- var parts = [];
27
- var currentStringToReplace = string;
28
- args.forEach(function (arg, i) {
29
- if (typeof arg === 'string') {
30
- currentStringToReplace = currentStringToReplace.replace("${".concat(i + 1, "}"), arg);
31
- }
32
- else {
33
- var _a = currentStringToReplace.split("${".concat(i + 1, "}")), partToPush = _a[0], partToReplace = _a[1];
34
- if (partToPush === undefined || partToReplace === undefined) {
35
- throw new Error("Invalid translation \"".concat(id, "\""));
36
- }
37
- parts.push(<React.Fragment key={"string-".concat(i)}>{partToPush}</React.Fragment>);
38
- parts.push(<React.Fragment key={"arg-".concat(i)}>{arg}</React.Fragment>);
39
- currentStringToReplace = partToReplace;
40
- }
41
- });
42
- if (!parts.length) {
43
- return currentStringToReplace;
44
- }
45
- return (<>
46
- {parts}
47
- {currentStringToReplace}
48
- </>);
49
- }
50
- /**
51
- * Version of `t` that returns a string.
52
- */
53
- export function tString(translation, id) {
54
- var args = [];
55
- for (var _i = 2; _i < arguments.length; _i++) {
56
- args[_i - 2] = arguments[_i];
57
- }
58
- var result = t.apply(void 0, __spreadArray([translation, id], args, false));
59
- return reactToString(result);
60
- }
61
- function reactToString(el) {
62
- if (typeof el === 'string' || typeof el === 'number' || typeof el === 'boolean') {
63
- return "".concat(el);
64
- }
65
- if (el === null || el === undefined) {
66
- return '';
67
- }
68
- if (Array.isArray(el)) {
69
- return el.map(reactToString).join('');
70
- }
71
- if (typeof el === 'object' && 'props' in el) {
72
- return el.props.children.map(reactToString).join('');
73
- }
74
- throw new Error("Unsupported type ".concat(typeof el));
75
- }
@@ -1,43 +0,0 @@
1
- export declare const de: {
2
- required: string;
3
- deprecated: string;
4
- deprecated_and_sunset_on: string;
5
- stability_experimental: string;
6
- stability_alpha: string;
7
- stability_beta: string;
8
- copy_to_clipboard: string;
9
- copied: string;
10
- no_content: string;
11
- unresolved_reference: string;
12
- circular_reference: string;
13
- read_only: string;
14
- write_only: string;
15
- optional: string;
16
- min: string;
17
- max: string;
18
- nullable: string;
19
- body: string;
20
- payload: string;
21
- headers: string;
22
- header: string;
23
- authorizations: string;
24
- responses: string;
25
- response: string;
26
- path_parameters: string;
27
- query_parameters: string;
28
- header_parameters: string;
29
- attributes: string;
30
- test_it: string;
31
- information: string;
32
- success: string;
33
- redirect: string;
34
- error: string;
35
- show: string;
36
- hide: string;
37
- available_items: string;
38
- available_scopes: string;
39
- properties: string;
40
- or: string;
41
- and: string;
42
- possible_values: string;
43
- };