@jpmorganchase/elemental 1.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/__fixtures__/api-descriptions/Instagram.d.ts +1547 -0
- package/__fixtures__/api-descriptions/badgesForSchema.d.ts +1 -0
- package/__fixtures__/api-descriptions/simpleApiWithInternalOperations.d.ts +224 -0
- package/__fixtures__/api-descriptions/simpleApiWithoutDescription.d.ts +212 -0
- package/__fixtures__/api-descriptions/todosApiBundled.d.ts +1 -0
- package/__fixtures__/api-descriptions/zoomApiYaml.d.ts +1 -0
- package/components/API/APIWithSidebarLayout.d.ts +17 -0
- package/components/API/APIWithStackedLayout.d.ts +15 -0
- package/components/API/utils.d.ts +18 -0
- package/containers/API.d.ts +23 -0
- package/containers/API.spec.d.ts +3 -0
- package/containers/API.stories.d.ts +57 -0
- package/hooks/useExportDocumentProps.d.ts +11 -0
- package/hooks/useExportDocumentProps.spec.d.ts +1 -0
- package/index.esm.js +516 -0
- package/index.js +549 -0
- package/index.mjs +516 -0
- package/package.json +17 -76
- package/styles.min.css +1 -0
- package/utils/oas/index.d.ts +3 -0
- package/utils/oas/oas2.d.ts +2 -0
- package/utils/oas/oas3.d.ts +2 -0
- package/utils/oas/types.d.ts +30 -0
- package/web-components/components.d.ts +1 -0
- package/web-components/index.d.ts +1 -0
- package/web-components.min.js +2 -0
- package/web-components.min.js.LICENSE.txt +189 -0
- package/.storybook/main.js +0 -1
- package/.storybook/manager.js +0 -1
- package/.storybook/preview.jsx +0 -3
- package/jest.config.js +0 -7
- package/src/__fixtures__/api-descriptions/Instagram.ts +0 -1859
- package/src/__fixtures__/api-descriptions/badgesForSchema.ts +0 -36
- package/src/__fixtures__/api-descriptions/simpleApiWithInternalOperations.ts +0 -253
- package/src/__fixtures__/api-descriptions/simpleApiWithoutDescription.ts +0 -243
- package/src/__fixtures__/api-descriptions/todosApiBundled.ts +0 -430
- package/src/__fixtures__/api-descriptions/zoomApiYaml.ts +0 -6083
- package/src/components/API/APIWithSidebarLayout.tsx +0 -111
- package/src/components/API/APIWithStackedLayout.tsx +0 -220
- package/src/components/API/__tests__/utils.test.ts +0 -848
- package/src/components/API/utils.ts +0 -174
- package/src/containers/API.spec.tsx +0 -131
- package/src/containers/API.stories.tsx +0 -99
- package/src/containers/API.tsx +0 -200
- package/src/hooks/useExportDocumentProps.spec.tsx +0 -68
- package/src/hooks/useExportDocumentProps.tsx +0 -48
- package/src/styles.css +0 -1
- package/src/utils/oas/__tests__/oas.spec.ts +0 -272
- package/src/utils/oas/index.ts +0 -150
- package/src/utils/oas/oas2.ts +0 -31
- package/src/utils/oas/oas3.ts +0 -37
- package/src/utils/oas/types.ts +0 -31
- package/src/web-components/__stories__/Api.stories.tsx +0 -63
- package/src/web-components/components.ts +0 -20
- package/src/web-components/index.ts +0 -3
- package/tsconfig.build.json +0 -18
- package/tsconfig.json +0 -7
- package/web-components.config.js +0 -1
- /package/{src/index.ts → index.d.ts} +0 -0
@@ -1,848 +0,0 @@
|
|
1
|
-
import { OpenAPIObject } from 'openapi3-ts';
|
2
|
-
|
3
|
-
import { transformOasToServiceNode } from '../../../utils/oas';
|
4
|
-
import { computeAPITree, computeTagGroups } from '../utils';
|
5
|
-
|
6
|
-
describe('computeTagGroups', () => {
|
7
|
-
it('orders endpoints according to specificed tags', () => {
|
8
|
-
const apiDocument: OpenAPIObject = {
|
9
|
-
openapi: '3.0.0',
|
10
|
-
info: {
|
11
|
-
title: 'some api',
|
12
|
-
version: '1.0.0',
|
13
|
-
description: 'some description',
|
14
|
-
},
|
15
|
-
tags: [
|
16
|
-
{
|
17
|
-
name: 'beta',
|
18
|
-
},
|
19
|
-
{
|
20
|
-
name: 'alpha',
|
21
|
-
},
|
22
|
-
],
|
23
|
-
paths: {
|
24
|
-
'/a': {
|
25
|
-
get: {
|
26
|
-
tags: ['alpha'],
|
27
|
-
},
|
28
|
-
},
|
29
|
-
'/b': {
|
30
|
-
get: {
|
31
|
-
tags: ['beta'],
|
32
|
-
},
|
33
|
-
},
|
34
|
-
},
|
35
|
-
};
|
36
|
-
|
37
|
-
const serviceNode = transformOasToServiceNode(apiDocument);
|
38
|
-
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
|
39
|
-
groups: [
|
40
|
-
{
|
41
|
-
title: 'beta',
|
42
|
-
items: [
|
43
|
-
{
|
44
|
-
type: 'http_operation',
|
45
|
-
uri: '/paths/b/get',
|
46
|
-
data: {
|
47
|
-
id: '2b447d075652c',
|
48
|
-
method: 'get',
|
49
|
-
path: '/b',
|
50
|
-
responses: [],
|
51
|
-
servers: [],
|
52
|
-
request: {
|
53
|
-
body: {
|
54
|
-
id: '1b5f96cfcd9cb',
|
55
|
-
contents: [],
|
56
|
-
},
|
57
|
-
headers: [],
|
58
|
-
query: [],
|
59
|
-
cookie: [],
|
60
|
-
path: [],
|
61
|
-
},
|
62
|
-
tags: [
|
63
|
-
{
|
64
|
-
id: 'e01820f4e85ed',
|
65
|
-
name: 'beta',
|
66
|
-
},
|
67
|
-
],
|
68
|
-
security: [],
|
69
|
-
extensions: {},
|
70
|
-
},
|
71
|
-
name: '/b',
|
72
|
-
tags: ['beta'],
|
73
|
-
},
|
74
|
-
],
|
75
|
-
},
|
76
|
-
{
|
77
|
-
title: 'alpha',
|
78
|
-
items: [
|
79
|
-
{
|
80
|
-
type: 'http_operation',
|
81
|
-
uri: '/paths/a/get',
|
82
|
-
data: {
|
83
|
-
id: '2b547d0756761',
|
84
|
-
method: 'get',
|
85
|
-
path: '/a',
|
86
|
-
responses: [],
|
87
|
-
servers: [],
|
88
|
-
request: {
|
89
|
-
body: {
|
90
|
-
id: 'c9a24d63f1884',
|
91
|
-
contents: [],
|
92
|
-
},
|
93
|
-
headers: [],
|
94
|
-
query: [],
|
95
|
-
cookie: [],
|
96
|
-
path: [],
|
97
|
-
},
|
98
|
-
tags: [
|
99
|
-
{
|
100
|
-
id: '7d65d096f3728',
|
101
|
-
name: 'alpha',
|
102
|
-
},
|
103
|
-
],
|
104
|
-
security: [],
|
105
|
-
extensions: {},
|
106
|
-
},
|
107
|
-
name: '/a',
|
108
|
-
tags: ['alpha'],
|
109
|
-
},
|
110
|
-
],
|
111
|
-
},
|
112
|
-
],
|
113
|
-
ungrouped: [],
|
114
|
-
});
|
115
|
-
});
|
116
|
-
|
117
|
-
it("within the tags it doesn't reorder the endpoints", () => {
|
118
|
-
const apiDocument: OpenAPIObject = {
|
119
|
-
openapi: '3.0.0',
|
120
|
-
info: {
|
121
|
-
title: 'some api',
|
122
|
-
version: '1.0.0',
|
123
|
-
description: 'some description',
|
124
|
-
},
|
125
|
-
tags: [
|
126
|
-
{
|
127
|
-
name: 'beta',
|
128
|
-
},
|
129
|
-
{
|
130
|
-
name: 'alpha',
|
131
|
-
},
|
132
|
-
],
|
133
|
-
paths: {
|
134
|
-
'/a': {
|
135
|
-
get: {
|
136
|
-
tags: ['alpha'],
|
137
|
-
},
|
138
|
-
},
|
139
|
-
'/c': {
|
140
|
-
get: {
|
141
|
-
tags: ['beta'],
|
142
|
-
},
|
143
|
-
},
|
144
|
-
'/b': {
|
145
|
-
get: {
|
146
|
-
tags: ['beta'],
|
147
|
-
},
|
148
|
-
},
|
149
|
-
},
|
150
|
-
};
|
151
|
-
|
152
|
-
const serviceNode = transformOasToServiceNode(apiDocument);
|
153
|
-
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
|
154
|
-
groups: [
|
155
|
-
{
|
156
|
-
title: 'beta',
|
157
|
-
items: [
|
158
|
-
{
|
159
|
-
type: 'http_operation',
|
160
|
-
uri: '/paths/c/get',
|
161
|
-
data: {
|
162
|
-
id: '2b347d0756b9f',
|
163
|
-
method: 'get',
|
164
|
-
path: '/c',
|
165
|
-
responses: [],
|
166
|
-
servers: [],
|
167
|
-
request: { body: { id: '7dde7a4e80b0a', contents: [] }, headers: [], query: [], cookie: [], path: [] },
|
168
|
-
tags: [{ id: 'e01820f4e85ed', name: 'beta' }],
|
169
|
-
security: [],
|
170
|
-
extensions: {},
|
171
|
-
},
|
172
|
-
name: '/c',
|
173
|
-
tags: ['beta'],
|
174
|
-
},
|
175
|
-
{
|
176
|
-
type: 'http_operation',
|
177
|
-
uri: '/paths/b/get',
|
178
|
-
data: {
|
179
|
-
id: '2b447d075652c',
|
180
|
-
method: 'get',
|
181
|
-
path: '/b',
|
182
|
-
responses: [],
|
183
|
-
servers: [],
|
184
|
-
request: { body: { id: '1b5f96cfcd9cb', contents: [] }, headers: [], query: [], cookie: [], path: [] },
|
185
|
-
tags: [{ id: 'e01820f4e85ed', name: 'beta' }],
|
186
|
-
security: [],
|
187
|
-
extensions: {},
|
188
|
-
},
|
189
|
-
name: '/b',
|
190
|
-
tags: ['beta'],
|
191
|
-
},
|
192
|
-
],
|
193
|
-
},
|
194
|
-
{
|
195
|
-
title: 'alpha',
|
196
|
-
items: [
|
197
|
-
{
|
198
|
-
type: 'http_operation',
|
199
|
-
uri: '/paths/a/get',
|
200
|
-
data: {
|
201
|
-
id: '2b547d0756761',
|
202
|
-
method: 'get',
|
203
|
-
path: '/a',
|
204
|
-
responses: [],
|
205
|
-
servers: [],
|
206
|
-
request: { body: { id: 'c9a24d63f1884', contents: [] }, headers: [], query: [], cookie: [], path: [] },
|
207
|
-
tags: [{ id: '7d65d096f3728', name: 'alpha' }],
|
208
|
-
security: [],
|
209
|
-
extensions: {},
|
210
|
-
},
|
211
|
-
name: '/a',
|
212
|
-
tags: ['alpha'],
|
213
|
-
},
|
214
|
-
],
|
215
|
-
},
|
216
|
-
],
|
217
|
-
ungrouped: [],
|
218
|
-
});
|
219
|
-
});
|
220
|
-
|
221
|
-
it("within the tags it doesn't reorder the methods", () => {
|
222
|
-
const apiDocument: OpenAPIObject = {
|
223
|
-
openapi: '3.0.0',
|
224
|
-
info: {
|
225
|
-
title: 'some api',
|
226
|
-
version: '1.0.0',
|
227
|
-
description: 'some description',
|
228
|
-
},
|
229
|
-
tags: [
|
230
|
-
{
|
231
|
-
name: 'beta',
|
232
|
-
},
|
233
|
-
{
|
234
|
-
name: 'alpha',
|
235
|
-
},
|
236
|
-
],
|
237
|
-
paths: {
|
238
|
-
'/a': {
|
239
|
-
get: {
|
240
|
-
tags: ['alpha'],
|
241
|
-
},
|
242
|
-
},
|
243
|
-
'/b': {
|
244
|
-
get: {
|
245
|
-
tags: ['beta'],
|
246
|
-
},
|
247
|
-
delete: {
|
248
|
-
tags: ['beta'],
|
249
|
-
},
|
250
|
-
},
|
251
|
-
},
|
252
|
-
};
|
253
|
-
|
254
|
-
const serviceNode = transformOasToServiceNode(apiDocument);
|
255
|
-
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
|
256
|
-
groups: [
|
257
|
-
{
|
258
|
-
title: 'beta',
|
259
|
-
items: [
|
260
|
-
{
|
261
|
-
type: 'http_operation',
|
262
|
-
uri: '/paths/b/get',
|
263
|
-
data: {
|
264
|
-
id: '2b447d075652c',
|
265
|
-
method: 'get',
|
266
|
-
path: '/b',
|
267
|
-
responses: [],
|
268
|
-
servers: [],
|
269
|
-
request: { body: { id: '1b5f96cfcd9cb', contents: [] }, headers: [], query: [], cookie: [], path: [] },
|
270
|
-
tags: [{ id: 'e01820f4e85ed', name: 'beta' }],
|
271
|
-
security: [],
|
272
|
-
extensions: {},
|
273
|
-
},
|
274
|
-
name: '/b',
|
275
|
-
tags: ['beta'],
|
276
|
-
},
|
277
|
-
{
|
278
|
-
type: 'http_operation',
|
279
|
-
uri: '/paths/b/delete',
|
280
|
-
data: {
|
281
|
-
id: 'd646c34fd1825',
|
282
|
-
method: 'delete',
|
283
|
-
path: '/b',
|
284
|
-
responses: [],
|
285
|
-
servers: [],
|
286
|
-
request: { body: { id: '64c420fe39197', contents: [] }, headers: [], query: [], cookie: [], path: [] },
|
287
|
-
tags: [{ id: 'e01820f4e85ed', name: 'beta' }],
|
288
|
-
security: [],
|
289
|
-
extensions: {},
|
290
|
-
},
|
291
|
-
name: '/b',
|
292
|
-
tags: ['beta'],
|
293
|
-
},
|
294
|
-
],
|
295
|
-
},
|
296
|
-
{
|
297
|
-
title: 'alpha',
|
298
|
-
items: [
|
299
|
-
{
|
300
|
-
type: 'http_operation',
|
301
|
-
uri: '/paths/a/get',
|
302
|
-
data: {
|
303
|
-
id: '2b547d0756761',
|
304
|
-
method: 'get',
|
305
|
-
path: '/a',
|
306
|
-
responses: [],
|
307
|
-
servers: [],
|
308
|
-
request: { body: { id: 'c9a24d63f1884', contents: [] }, headers: [], query: [], cookie: [], path: [] },
|
309
|
-
tags: [{ id: '7d65d096f3728', name: 'alpha' }],
|
310
|
-
security: [],
|
311
|
-
extensions: {},
|
312
|
-
},
|
313
|
-
name: '/a',
|
314
|
-
tags: ['alpha'],
|
315
|
-
},
|
316
|
-
],
|
317
|
-
},
|
318
|
-
],
|
319
|
-
ungrouped: [],
|
320
|
-
});
|
321
|
-
});
|
322
|
-
|
323
|
-
it("doesn't throw with incorrect tags value", () => {
|
324
|
-
const apiDocument = {
|
325
|
-
openapi: '3.0.0',
|
326
|
-
info: {
|
327
|
-
title: 'some api',
|
328
|
-
version: '1.0.0',
|
329
|
-
description: 'some description',
|
330
|
-
},
|
331
|
-
paths: {},
|
332
|
-
tags: {
|
333
|
-
$ref: './tags',
|
334
|
-
},
|
335
|
-
};
|
336
|
-
|
337
|
-
const serviceNode = transformOasToServiceNode(apiDocument);
|
338
|
-
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({ groups: [], ungrouped: [] });
|
339
|
-
});
|
340
|
-
|
341
|
-
it('leaves tag casing unchanged', () => {
|
342
|
-
const apiDocument: OpenAPIObject = {
|
343
|
-
openapi: '3.0.0',
|
344
|
-
info: {
|
345
|
-
title: 'some api',
|
346
|
-
version: '1.0.0',
|
347
|
-
description: 'some description',
|
348
|
-
},
|
349
|
-
tags: [
|
350
|
-
{
|
351
|
-
name: 'Beta',
|
352
|
-
},
|
353
|
-
{
|
354
|
-
name: 'alpha',
|
355
|
-
},
|
356
|
-
],
|
357
|
-
paths: {
|
358
|
-
'/a': {
|
359
|
-
get: {
|
360
|
-
tags: ['alpha'],
|
361
|
-
},
|
362
|
-
},
|
363
|
-
'/b': {
|
364
|
-
get: {
|
365
|
-
tags: ['Beta'],
|
366
|
-
},
|
367
|
-
},
|
368
|
-
},
|
369
|
-
};
|
370
|
-
|
371
|
-
const serviceNode = transformOasToServiceNode(apiDocument);
|
372
|
-
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
|
373
|
-
groups: [
|
374
|
-
{
|
375
|
-
title: 'Beta',
|
376
|
-
items: [
|
377
|
-
{
|
378
|
-
type: 'http_operation',
|
379
|
-
uri: '/paths/b/get',
|
380
|
-
data: {
|
381
|
-
id: '2b447d075652c',
|
382
|
-
method: 'get',
|
383
|
-
path: '/b',
|
384
|
-
responses: [],
|
385
|
-
servers: [],
|
386
|
-
request: {
|
387
|
-
body: {
|
388
|
-
contents: [],
|
389
|
-
id: '1b5f96cfcd9cb',
|
390
|
-
},
|
391
|
-
headers: [],
|
392
|
-
query: [],
|
393
|
-
cookie: [],
|
394
|
-
path: [],
|
395
|
-
},
|
396
|
-
tags: [
|
397
|
-
{
|
398
|
-
name: 'Beta',
|
399
|
-
id: 'c028e10befb64',
|
400
|
-
},
|
401
|
-
],
|
402
|
-
security: [],
|
403
|
-
extensions: {},
|
404
|
-
},
|
405
|
-
name: '/b',
|
406
|
-
tags: ['Beta'],
|
407
|
-
},
|
408
|
-
],
|
409
|
-
},
|
410
|
-
{
|
411
|
-
title: 'alpha',
|
412
|
-
items: [
|
413
|
-
{
|
414
|
-
type: 'http_operation',
|
415
|
-
uri: '/paths/a/get',
|
416
|
-
data: {
|
417
|
-
id: '2b547d0756761',
|
418
|
-
method: 'get',
|
419
|
-
path: '/a',
|
420
|
-
responses: [],
|
421
|
-
servers: [],
|
422
|
-
request: {
|
423
|
-
body: {
|
424
|
-
contents: [],
|
425
|
-
id: 'c9a24d63f1884',
|
426
|
-
},
|
427
|
-
headers: [],
|
428
|
-
query: [],
|
429
|
-
cookie: [],
|
430
|
-
path: [],
|
431
|
-
},
|
432
|
-
tags: [
|
433
|
-
{
|
434
|
-
id: '7d65d096f3728',
|
435
|
-
name: 'alpha',
|
436
|
-
},
|
437
|
-
],
|
438
|
-
security: [],
|
439
|
-
extensions: {},
|
440
|
-
},
|
441
|
-
name: '/a',
|
442
|
-
tags: ['alpha'],
|
443
|
-
},
|
444
|
-
],
|
445
|
-
},
|
446
|
-
],
|
447
|
-
ungrouped: [],
|
448
|
-
});
|
449
|
-
});
|
450
|
-
|
451
|
-
it('matches mixed tag casing', () => {
|
452
|
-
const apiDocument: OpenAPIObject = {
|
453
|
-
openapi: '3.0.0',
|
454
|
-
info: {
|
455
|
-
title: 'some api',
|
456
|
-
version: '1.0.0',
|
457
|
-
description: 'some description',
|
458
|
-
},
|
459
|
-
tags: [
|
460
|
-
{
|
461
|
-
name: 'Beta',
|
462
|
-
},
|
463
|
-
{
|
464
|
-
name: 'alpha',
|
465
|
-
},
|
466
|
-
],
|
467
|
-
paths: {
|
468
|
-
'/a': {
|
469
|
-
get: {
|
470
|
-
tags: ['alpha'],
|
471
|
-
},
|
472
|
-
},
|
473
|
-
'/b': {
|
474
|
-
get: {
|
475
|
-
tags: ['beta'],
|
476
|
-
},
|
477
|
-
},
|
478
|
-
},
|
479
|
-
};
|
480
|
-
|
481
|
-
const serviceNode = transformOasToServiceNode(apiDocument);
|
482
|
-
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
|
483
|
-
groups: [
|
484
|
-
{
|
485
|
-
title: 'Beta',
|
486
|
-
items: [
|
487
|
-
{
|
488
|
-
type: 'http_operation',
|
489
|
-
uri: '/paths/b/get',
|
490
|
-
data: {
|
491
|
-
id: '2b447d075652c',
|
492
|
-
method: 'get',
|
493
|
-
path: '/b',
|
494
|
-
responses: [],
|
495
|
-
servers: [],
|
496
|
-
request: {
|
497
|
-
body: {
|
498
|
-
contents: [],
|
499
|
-
id: '1b5f96cfcd9cb',
|
500
|
-
},
|
501
|
-
headers: [],
|
502
|
-
query: [],
|
503
|
-
cookie: [],
|
504
|
-
path: [],
|
505
|
-
},
|
506
|
-
tags: [
|
507
|
-
{
|
508
|
-
id: 'e01820f4e85ed',
|
509
|
-
name: 'beta',
|
510
|
-
},
|
511
|
-
],
|
512
|
-
security: [],
|
513
|
-
extensions: {},
|
514
|
-
},
|
515
|
-
name: '/b',
|
516
|
-
tags: ['beta'],
|
517
|
-
},
|
518
|
-
],
|
519
|
-
},
|
520
|
-
{
|
521
|
-
title: 'alpha',
|
522
|
-
items: [
|
523
|
-
{
|
524
|
-
type: 'http_operation',
|
525
|
-
uri: '/paths/a/get',
|
526
|
-
data: {
|
527
|
-
id: '2b547d0756761',
|
528
|
-
method: 'get',
|
529
|
-
path: '/a',
|
530
|
-
responses: [],
|
531
|
-
servers: [],
|
532
|
-
request: {
|
533
|
-
body: {
|
534
|
-
contents: [],
|
535
|
-
id: 'c9a24d63f1884',
|
536
|
-
},
|
537
|
-
headers: [],
|
538
|
-
query: [],
|
539
|
-
cookie: [],
|
540
|
-
path: [],
|
541
|
-
},
|
542
|
-
tags: [
|
543
|
-
{
|
544
|
-
id: '7d65d096f3728',
|
545
|
-
name: 'alpha',
|
546
|
-
},
|
547
|
-
],
|
548
|
-
security: [],
|
549
|
-
extensions: {},
|
550
|
-
},
|
551
|
-
name: '/a',
|
552
|
-
tags: ['alpha'],
|
553
|
-
},
|
554
|
-
],
|
555
|
-
},
|
556
|
-
],
|
557
|
-
ungrouped: [],
|
558
|
-
});
|
559
|
-
});
|
560
|
-
});
|
561
|
-
|
562
|
-
describe('computeAPITree', () => {
|
563
|
-
it('generates API ToC tree', () => {
|
564
|
-
const apiDocument: OpenAPIObject = {
|
565
|
-
openapi: '3.0.0',
|
566
|
-
info: {
|
567
|
-
title: 'some api',
|
568
|
-
version: '1.0.0',
|
569
|
-
description: 'some description',
|
570
|
-
},
|
571
|
-
paths: {
|
572
|
-
'/something': {
|
573
|
-
get: {
|
574
|
-
responses: {
|
575
|
-
200: {
|
576
|
-
schema: { $ref: '#/definitions/schemas/ImportantSchema' },
|
577
|
-
},
|
578
|
-
},
|
579
|
-
},
|
580
|
-
},
|
581
|
-
},
|
582
|
-
components: {
|
583
|
-
schemas: {
|
584
|
-
ImportantSchema: {
|
585
|
-
type: 'object',
|
586
|
-
properties: {
|
587
|
-
a: { type: 'string' },
|
588
|
-
},
|
589
|
-
},
|
590
|
-
},
|
591
|
-
},
|
592
|
-
};
|
593
|
-
|
594
|
-
expect(computeAPITree(transformOasToServiceNode(apiDocument)!)).toEqual([
|
595
|
-
{
|
596
|
-
id: '/',
|
597
|
-
meta: '',
|
598
|
-
slug: '/',
|
599
|
-
title: 'Overview',
|
600
|
-
type: 'overview',
|
601
|
-
},
|
602
|
-
{
|
603
|
-
title: 'Endpoints',
|
604
|
-
},
|
605
|
-
{
|
606
|
-
id: '/paths/something/get',
|
607
|
-
meta: 'get',
|
608
|
-
slug: '/paths/something/get',
|
609
|
-
title: '/something',
|
610
|
-
type: 'http_operation',
|
611
|
-
},
|
612
|
-
{ title: 'Schemas' },
|
613
|
-
{
|
614
|
-
id: '/schemas/ImportantSchema',
|
615
|
-
slug: '/schemas/ImportantSchema',
|
616
|
-
title: 'ImportantSchema',
|
617
|
-
type: 'model',
|
618
|
-
meta: '',
|
619
|
-
},
|
620
|
-
]);
|
621
|
-
});
|
622
|
-
|
623
|
-
it('allows to hide schemas from ToC', () => {
|
624
|
-
const apiDocument: OpenAPIObject = {
|
625
|
-
openapi: '3.0.0',
|
626
|
-
info: {
|
627
|
-
title: 'some api',
|
628
|
-
version: '1.0.0',
|
629
|
-
description: 'some description',
|
630
|
-
},
|
631
|
-
paths: {
|
632
|
-
'/something': {
|
633
|
-
get: {
|
634
|
-
responses: {
|
635
|
-
200: {
|
636
|
-
schema: { $ref: '#/definitions/schemas/ImportantSchema' },
|
637
|
-
},
|
638
|
-
},
|
639
|
-
},
|
640
|
-
},
|
641
|
-
},
|
642
|
-
components: {
|
643
|
-
schemas: {
|
644
|
-
ImportantSchema: {
|
645
|
-
type: 'object',
|
646
|
-
properties: {
|
647
|
-
a: { type: 'string' },
|
648
|
-
},
|
649
|
-
},
|
650
|
-
},
|
651
|
-
},
|
652
|
-
};
|
653
|
-
|
654
|
-
expect(computeAPITree(transformOasToServiceNode(apiDocument)!, { hideSchemas: true })).toEqual([
|
655
|
-
{
|
656
|
-
id: '/',
|
657
|
-
meta: '',
|
658
|
-
slug: '/',
|
659
|
-
title: 'Overview',
|
660
|
-
type: 'overview',
|
661
|
-
},
|
662
|
-
{
|
663
|
-
title: 'Endpoints',
|
664
|
-
},
|
665
|
-
{
|
666
|
-
id: '/paths/something/get',
|
667
|
-
meta: 'get',
|
668
|
-
slug: '/paths/something/get',
|
669
|
-
title: '/something',
|
670
|
-
type: 'http_operation',
|
671
|
-
},
|
672
|
-
]);
|
673
|
-
});
|
674
|
-
|
675
|
-
it('allows to hide internal operations from ToC', () => {
|
676
|
-
const apiDocument: OpenAPIObject = {
|
677
|
-
openapi: '3.0.0',
|
678
|
-
info: {
|
679
|
-
title: 'some api',
|
680
|
-
version: '1.0.0',
|
681
|
-
description: 'some description',
|
682
|
-
},
|
683
|
-
paths: {
|
684
|
-
'/something': {
|
685
|
-
get: {},
|
686
|
-
post: {
|
687
|
-
'x-internal': true,
|
688
|
-
},
|
689
|
-
},
|
690
|
-
},
|
691
|
-
};
|
692
|
-
|
693
|
-
expect(computeAPITree(transformOasToServiceNode(apiDocument)!, { hideInternal: true })).toEqual([
|
694
|
-
{
|
695
|
-
id: '/',
|
696
|
-
meta: '',
|
697
|
-
slug: '/',
|
698
|
-
title: 'Overview',
|
699
|
-
type: 'overview',
|
700
|
-
},
|
701
|
-
{
|
702
|
-
title: 'Endpoints',
|
703
|
-
},
|
704
|
-
{
|
705
|
-
id: '/paths/something/get',
|
706
|
-
meta: 'get',
|
707
|
-
slug: '/paths/something/get',
|
708
|
-
title: '/something',
|
709
|
-
type: 'http_operation',
|
710
|
-
},
|
711
|
-
]);
|
712
|
-
});
|
713
|
-
|
714
|
-
it('allows to hide nested internal operations from ToC', () => {
|
715
|
-
const apiDocument: OpenAPIObject = {
|
716
|
-
openapi: '3.0.0',
|
717
|
-
info: {
|
718
|
-
title: 'some api',
|
719
|
-
version: '1.0.0',
|
720
|
-
description: 'some description',
|
721
|
-
},
|
722
|
-
tags: [
|
723
|
-
{
|
724
|
-
name: 'a',
|
725
|
-
},
|
726
|
-
],
|
727
|
-
paths: {
|
728
|
-
'/something': {
|
729
|
-
get: {
|
730
|
-
tags: ['a'],
|
731
|
-
},
|
732
|
-
post: {
|
733
|
-
'x-internal': true,
|
734
|
-
tags: ['a'],
|
735
|
-
},
|
736
|
-
},
|
737
|
-
},
|
738
|
-
};
|
739
|
-
|
740
|
-
expect(computeAPITree(transformOasToServiceNode(apiDocument)!, { hideInternal: true })).toEqual([
|
741
|
-
{
|
742
|
-
id: '/',
|
743
|
-
meta: '',
|
744
|
-
slug: '/',
|
745
|
-
title: 'Overview',
|
746
|
-
type: 'overview',
|
747
|
-
},
|
748
|
-
{
|
749
|
-
title: 'Endpoints',
|
750
|
-
},
|
751
|
-
{
|
752
|
-
title: 'a',
|
753
|
-
items: [
|
754
|
-
{
|
755
|
-
id: '/paths/something/get',
|
756
|
-
meta: 'get',
|
757
|
-
slug: '/paths/something/get',
|
758
|
-
title: '/something',
|
759
|
-
type: 'http_operation',
|
760
|
-
},
|
761
|
-
],
|
762
|
-
},
|
763
|
-
]);
|
764
|
-
});
|
765
|
-
|
766
|
-
it('allows to hide internal models from ToC', () => {
|
767
|
-
const apiDocument: OpenAPIObject = {
|
768
|
-
openapi: '3.0.0',
|
769
|
-
info: {
|
770
|
-
title: 'some api',
|
771
|
-
version: '1.0.0',
|
772
|
-
description: 'some description',
|
773
|
-
},
|
774
|
-
paths: {},
|
775
|
-
components: {
|
776
|
-
schemas: {
|
777
|
-
SomeInternalSchema: {
|
778
|
-
'x-internal': true,
|
779
|
-
},
|
780
|
-
},
|
781
|
-
},
|
782
|
-
};
|
783
|
-
|
784
|
-
expect(computeAPITree(transformOasToServiceNode(apiDocument)!, { hideInternal: true })).toEqual([
|
785
|
-
{
|
786
|
-
id: '/',
|
787
|
-
meta: '',
|
788
|
-
slug: '/',
|
789
|
-
title: 'Overview',
|
790
|
-
type: 'overview',
|
791
|
-
},
|
792
|
-
]);
|
793
|
-
});
|
794
|
-
|
795
|
-
it('excludes groups with no items', () => {
|
796
|
-
const apiDocument: OpenAPIObject = {
|
797
|
-
openapi: '3.0.0',
|
798
|
-
info: {
|
799
|
-
title: 'some api',
|
800
|
-
version: '1.0.0',
|
801
|
-
description: 'some description',
|
802
|
-
},
|
803
|
-
tags: [
|
804
|
-
{
|
805
|
-
name: 'a',
|
806
|
-
},
|
807
|
-
],
|
808
|
-
paths: {
|
809
|
-
'/something': {
|
810
|
-
post: {
|
811
|
-
'x-internal': true,
|
812
|
-
tags: ['a'],
|
813
|
-
},
|
814
|
-
},
|
815
|
-
'/something-else': {
|
816
|
-
post: {
|
817
|
-
tags: ['b'],
|
818
|
-
},
|
819
|
-
},
|
820
|
-
},
|
821
|
-
};
|
822
|
-
|
823
|
-
expect(computeAPITree(transformOasToServiceNode(apiDocument)!, { hideInternal: true })).toEqual([
|
824
|
-
{
|
825
|
-
id: '/',
|
826
|
-
meta: '',
|
827
|
-
slug: '/',
|
828
|
-
title: 'Overview',
|
829
|
-
type: 'overview',
|
830
|
-
},
|
831
|
-
{
|
832
|
-
title: 'Endpoints',
|
833
|
-
},
|
834
|
-
{
|
835
|
-
title: 'b',
|
836
|
-
items: [
|
837
|
-
{
|
838
|
-
id: '/paths/something-else/post',
|
839
|
-
meta: 'post',
|
840
|
-
slug: '/paths/something-else/post',
|
841
|
-
title: '/something-else',
|
842
|
-
type: 'http_operation',
|
843
|
-
},
|
844
|
-
],
|
845
|
-
},
|
846
|
-
]);
|
847
|
-
});
|
848
|
-
});
|