@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,48 +0,0 @@
|
|
1
|
-
import { safeStringify } from '@stoplight/yaml';
|
2
|
-
import saver from 'file-saver';
|
3
|
-
import * as React from 'react';
|
4
|
-
|
5
|
-
import { isJson } from '../utils/oas';
|
6
|
-
|
7
|
-
export function useExportDocumentProps({
|
8
|
-
originalDocument,
|
9
|
-
bundledDocument,
|
10
|
-
}: {
|
11
|
-
originalDocument: string | object;
|
12
|
-
bundledDocument: unknown;
|
13
|
-
}) {
|
14
|
-
const isJsonDocument = typeof originalDocument === 'object' || (!!originalDocument && isJson(originalDocument));
|
15
|
-
|
16
|
-
const exportDocument = React.useCallback(
|
17
|
-
(document: string) => {
|
18
|
-
const type = isJsonDocument ? 'json' : 'yaml';
|
19
|
-
const blob = new Blob([document], {
|
20
|
-
type: `application/${type}`,
|
21
|
-
});
|
22
|
-
saver.saveAs(blob, `document.${type}`);
|
23
|
-
},
|
24
|
-
[isJsonDocument],
|
25
|
-
);
|
26
|
-
|
27
|
-
const exportOriginalDocument = React.useCallback(() => {
|
28
|
-
const stringifiedDocument =
|
29
|
-
typeof originalDocument === 'object' ? JSON.stringify(originalDocument, null, 2) : originalDocument || '';
|
30
|
-
exportDocument(stringifiedDocument);
|
31
|
-
}, [originalDocument, exportDocument]);
|
32
|
-
|
33
|
-
const exportBundledDocument = React.useCallback(() => {
|
34
|
-
const stringifiedDocument = isJsonDocument
|
35
|
-
? JSON.stringify(bundledDocument, null, 2)
|
36
|
-
: safeStringify(bundledDocument);
|
37
|
-
exportDocument(stringifiedDocument);
|
38
|
-
}, [bundledDocument, isJsonDocument, exportDocument]);
|
39
|
-
|
40
|
-
return {
|
41
|
-
original: {
|
42
|
-
onPress: exportOriginalDocument,
|
43
|
-
},
|
44
|
-
bundled: {
|
45
|
-
onPress: exportBundledDocument,
|
46
|
-
},
|
47
|
-
};
|
48
|
-
}
|
package/src/styles.css
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
@import "../../elements-core/src/styles.css";
|
@@ -1,272 +0,0 @@
|
|
1
|
-
import { transformOasToServiceNode } from '../';
|
2
|
-
|
3
|
-
const oas3Document = {
|
4
|
-
'x-stoplight': { id: 'abc' },
|
5
|
-
openapi: '3.0.0',
|
6
|
-
info: {
|
7
|
-
title: 'oas3',
|
8
|
-
version: '1.0.0',
|
9
|
-
},
|
10
|
-
tags: [{ name: 'operation-tag' }, { name: 'model-tag' }],
|
11
|
-
paths: {
|
12
|
-
'/todos': {
|
13
|
-
get: {
|
14
|
-
summary: 'Get Todos',
|
15
|
-
tags: ['operation-tag'],
|
16
|
-
},
|
17
|
-
},
|
18
|
-
},
|
19
|
-
components: {
|
20
|
-
schemas: {
|
21
|
-
Todo: {
|
22
|
-
type: 'object',
|
23
|
-
properties: {
|
24
|
-
id: {
|
25
|
-
type: 'integer',
|
26
|
-
},
|
27
|
-
},
|
28
|
-
title: 'Todo',
|
29
|
-
'x-tags': ['model-tag'],
|
30
|
-
},
|
31
|
-
},
|
32
|
-
},
|
33
|
-
};
|
34
|
-
|
35
|
-
const oas2Document = {
|
36
|
-
'x-stoplight': { id: 'abc' },
|
37
|
-
swagger: '2.0.0',
|
38
|
-
info: {
|
39
|
-
title: 'oas2',
|
40
|
-
version: '1.0.0',
|
41
|
-
},
|
42
|
-
tags: [{ name: 'operation-tag' }, { name: 'model-tag' }],
|
43
|
-
paths: {
|
44
|
-
'/todos': {
|
45
|
-
get: {
|
46
|
-
summary: 'Get Todos',
|
47
|
-
tags: ['operation-tag'],
|
48
|
-
},
|
49
|
-
},
|
50
|
-
},
|
51
|
-
definitions: {
|
52
|
-
Todo: {
|
53
|
-
type: 'object',
|
54
|
-
properties: {
|
55
|
-
id: {
|
56
|
-
type: 'integer',
|
57
|
-
},
|
58
|
-
},
|
59
|
-
title: 'Todo',
|
60
|
-
'x-tags': ['model-tag'],
|
61
|
-
},
|
62
|
-
},
|
63
|
-
};
|
64
|
-
|
65
|
-
describe('computeOasNodes', () => {
|
66
|
-
it('should return null for invalid document', () => {
|
67
|
-
expect(transformOasToServiceNode({})).toBeNull();
|
68
|
-
});
|
69
|
-
|
70
|
-
it('should return oas nodes for oas3 document', () => {
|
71
|
-
expect(transformOasToServiceNode(oas3Document)).toStrictEqual({
|
72
|
-
type: 'http_service',
|
73
|
-
uri: '/',
|
74
|
-
name: 'oas3',
|
75
|
-
data: {
|
76
|
-
id: 'abc',
|
77
|
-
version: '1.0.0',
|
78
|
-
name: 'oas3',
|
79
|
-
tags: [
|
80
|
-
{
|
81
|
-
id: 'd3404a8f3b495',
|
82
|
-
name: 'operation-tag',
|
83
|
-
},
|
84
|
-
{
|
85
|
-
id: 'd0460398c5f2b',
|
86
|
-
name: 'model-tag',
|
87
|
-
},
|
88
|
-
],
|
89
|
-
},
|
90
|
-
tags: ['operation-tag', 'model-tag'],
|
91
|
-
children: [
|
92
|
-
{
|
93
|
-
type: 'http_operation',
|
94
|
-
uri: '/paths/todos/get',
|
95
|
-
data: {
|
96
|
-
id: 'c35bc6b301d97',
|
97
|
-
method: 'get',
|
98
|
-
path: '/todos',
|
99
|
-
summary: 'Get Todos',
|
100
|
-
responses: [],
|
101
|
-
servers: [],
|
102
|
-
request: {
|
103
|
-
body: {
|
104
|
-
id: '704ac0beb3748',
|
105
|
-
contents: [],
|
106
|
-
},
|
107
|
-
headers: [],
|
108
|
-
query: [],
|
109
|
-
cookie: [],
|
110
|
-
path: [],
|
111
|
-
},
|
112
|
-
tags: [
|
113
|
-
{
|
114
|
-
id: 'd3404a8f3b495',
|
115
|
-
name: 'operation-tag',
|
116
|
-
},
|
117
|
-
],
|
118
|
-
security: [],
|
119
|
-
extensions: {},
|
120
|
-
},
|
121
|
-
name: 'Get Todos',
|
122
|
-
tags: ['operation-tag'],
|
123
|
-
},
|
124
|
-
{
|
125
|
-
type: 'model',
|
126
|
-
uri: '/schemas/Todo',
|
127
|
-
data: {
|
128
|
-
type: 'object',
|
129
|
-
properties: {
|
130
|
-
id: {
|
131
|
-
type: 'integer',
|
132
|
-
},
|
133
|
-
},
|
134
|
-
title: 'Todo',
|
135
|
-
'x-tags': ['model-tag'],
|
136
|
-
},
|
137
|
-
name: 'Todo',
|
138
|
-
tags: ['model-tag'],
|
139
|
-
},
|
140
|
-
],
|
141
|
-
});
|
142
|
-
});
|
143
|
-
|
144
|
-
it('should return oas nodes for oas2 document', () => {
|
145
|
-
expect(transformOasToServiceNode(oas2Document)).toStrictEqual({
|
146
|
-
type: 'http_service',
|
147
|
-
uri: '/',
|
148
|
-
name: 'oas2',
|
149
|
-
data: {
|
150
|
-
id: 'abc',
|
151
|
-
name: 'oas2',
|
152
|
-
tags: [
|
153
|
-
{
|
154
|
-
id: 'd3404a8f3b495',
|
155
|
-
name: 'operation-tag',
|
156
|
-
},
|
157
|
-
{
|
158
|
-
id: 'd0460398c5f2b',
|
159
|
-
name: 'model-tag',
|
160
|
-
},
|
161
|
-
],
|
162
|
-
version: '1.0.0',
|
163
|
-
},
|
164
|
-
tags: ['operation-tag', 'model-tag'],
|
165
|
-
children: [
|
166
|
-
{
|
167
|
-
type: 'http_operation',
|
168
|
-
uri: '/paths/todos/get',
|
169
|
-
data: {
|
170
|
-
id: 'c35bc6b301d97',
|
171
|
-
method: 'get',
|
172
|
-
path: '/todos',
|
173
|
-
summary: 'Get Todos',
|
174
|
-
responses: [],
|
175
|
-
servers: [],
|
176
|
-
request: {
|
177
|
-
cookie: [],
|
178
|
-
headers: [],
|
179
|
-
path: [],
|
180
|
-
query: [],
|
181
|
-
},
|
182
|
-
tags: [
|
183
|
-
{
|
184
|
-
id: 'd3404a8f3b495',
|
185
|
-
name: 'operation-tag',
|
186
|
-
},
|
187
|
-
],
|
188
|
-
security: [],
|
189
|
-
extensions: {},
|
190
|
-
},
|
191
|
-
name: 'Get Todos',
|
192
|
-
tags: ['operation-tag'],
|
193
|
-
},
|
194
|
-
{
|
195
|
-
type: 'model',
|
196
|
-
uri: '/schemas/Todo',
|
197
|
-
data: {
|
198
|
-
type: 'object',
|
199
|
-
properties: {
|
200
|
-
id: {
|
201
|
-
type: 'integer',
|
202
|
-
},
|
203
|
-
},
|
204
|
-
title: 'Todo',
|
205
|
-
'x-tags': ['model-tag'],
|
206
|
-
},
|
207
|
-
name: 'Todo',
|
208
|
-
tags: ['model-tag'],
|
209
|
-
},
|
210
|
-
],
|
211
|
-
});
|
212
|
-
});
|
213
|
-
|
214
|
-
it('should fallback to operationId', () => {
|
215
|
-
expect(
|
216
|
-
transformOasToServiceNode({
|
217
|
-
'x-stoplight': { id: 'def' },
|
218
|
-
openapi: '3.0.0',
|
219
|
-
info: {
|
220
|
-
title: 'oas3',
|
221
|
-
version: '1.0.0',
|
222
|
-
},
|
223
|
-
paths: {
|
224
|
-
'/todos': {
|
225
|
-
get: {
|
226
|
-
operationId: 'get-todos',
|
227
|
-
},
|
228
|
-
},
|
229
|
-
},
|
230
|
-
}),
|
231
|
-
).toEqual({
|
232
|
-
type: 'http_service',
|
233
|
-
uri: '/',
|
234
|
-
name: 'oas3',
|
235
|
-
tags: [],
|
236
|
-
data: {
|
237
|
-
id: 'def',
|
238
|
-
version: '1.0.0',
|
239
|
-
name: 'oas3',
|
240
|
-
},
|
241
|
-
children: [
|
242
|
-
{
|
243
|
-
type: 'http_operation',
|
244
|
-
uri: '/operations/get-todos',
|
245
|
-
data: {
|
246
|
-
id: 'a61f53c324669',
|
247
|
-
iid: 'get-todos',
|
248
|
-
method: 'get',
|
249
|
-
path: '/todos',
|
250
|
-
responses: [],
|
251
|
-
servers: [],
|
252
|
-
request: {
|
253
|
-
body: {
|
254
|
-
id: '67f97b0ec0ef8',
|
255
|
-
contents: [],
|
256
|
-
},
|
257
|
-
headers: [],
|
258
|
-
query: [],
|
259
|
-
cookie: [],
|
260
|
-
path: [],
|
261
|
-
},
|
262
|
-
tags: [],
|
263
|
-
security: [],
|
264
|
-
extensions: {},
|
265
|
-
},
|
266
|
-
tags: [],
|
267
|
-
name: 'get-todos',
|
268
|
-
},
|
269
|
-
],
|
270
|
-
});
|
271
|
-
});
|
272
|
-
});
|
package/src/utils/oas/index.ts
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
import { slugify } from '@stoplight/elements-core';
|
2
|
-
import type {
|
3
|
-
Oas2HttpOperationTransformer,
|
4
|
-
Oas2HttpServiceTransformer,
|
5
|
-
Oas3HttpOperationTransformer,
|
6
|
-
Oas3HttpServiceTransformer,
|
7
|
-
} from '@stoplight/http-spec/oas';
|
8
|
-
import { transformOas2Operation, transformOas2Service } from '@stoplight/http-spec/oas2';
|
9
|
-
import { transformOas3Operation, transformOas3Service } from '@stoplight/http-spec/oas3';
|
10
|
-
import { encodePointerFragment, pointerToPath } from '@stoplight/json';
|
11
|
-
import { NodeType } from '@stoplight/types';
|
12
|
-
import { get, isObject, last } from 'lodash';
|
13
|
-
import { OpenAPIObject } from 'openapi3-ts';
|
14
|
-
import { Spec } from 'swagger-schema-official';
|
15
|
-
|
16
|
-
import { oas2SourceMap } from './oas2';
|
17
|
-
import { oas3SourceMap } from './oas3';
|
18
|
-
import { ISourceNodeMap, NodeTypes, ServiceChildNode, ServiceNode } from './types';
|
19
|
-
|
20
|
-
const isOas2 = (parsed: unknown): parsed is Spec =>
|
21
|
-
isObject(parsed) &&
|
22
|
-
'swagger' in parsed &&
|
23
|
-
Number.parseInt(String((parsed as Partial<{ swagger: unknown }>).swagger)) === 2;
|
24
|
-
|
25
|
-
const isOas3 = (parsed: unknown): parsed is OpenAPIObject =>
|
26
|
-
isObject(parsed) &&
|
27
|
-
'openapi' in parsed &&
|
28
|
-
Number.parseFloat(String((parsed as Partial<{ openapi: unknown }>).openapi)) >= 3;
|
29
|
-
|
30
|
-
const isOas31 = (parsed: unknown): parsed is OpenAPIObject =>
|
31
|
-
isObject(parsed) &&
|
32
|
-
'openapi' in parsed &&
|
33
|
-
Number.parseFloat(String((parsed as Partial<{ openapi: unknown }>).openapi)) === 3.1;
|
34
|
-
|
35
|
-
const OAS_MODEL_REGEXP = /((definitions|components)\/?(schemas)?)\//;
|
36
|
-
|
37
|
-
export function transformOasToServiceNode(apiDescriptionDocument: unknown) {
|
38
|
-
if (isOas31(apiDescriptionDocument)) {
|
39
|
-
return computeServiceNode(
|
40
|
-
{ ...apiDescriptionDocument, jsonSchemaDialect: 'http://json-schema.org/draft-07/schema#' },
|
41
|
-
oas3SourceMap,
|
42
|
-
transformOas3Service,
|
43
|
-
transformOas3Operation,
|
44
|
-
);
|
45
|
-
}
|
46
|
-
if (isOas3(apiDescriptionDocument)) {
|
47
|
-
return computeServiceNode(apiDescriptionDocument, oas3SourceMap, transformOas3Service, transformOas3Operation);
|
48
|
-
} else if (isOas2(apiDescriptionDocument)) {
|
49
|
-
return computeServiceNode(apiDescriptionDocument, oas2SourceMap, transformOas2Service, transformOas2Operation);
|
50
|
-
}
|
51
|
-
|
52
|
-
return null;
|
53
|
-
}
|
54
|
-
|
55
|
-
function computeServiceNode(
|
56
|
-
document: Spec | OpenAPIObject,
|
57
|
-
map: ISourceNodeMap[],
|
58
|
-
transformService: Oas2HttpServiceTransformer | Oas3HttpServiceTransformer,
|
59
|
-
transformOperation: Oas2HttpOperationTransformer | Oas3HttpOperationTransformer,
|
60
|
-
) {
|
61
|
-
const serviceDocument = transformService({ document });
|
62
|
-
const serviceNode: ServiceNode = {
|
63
|
-
type: NodeType.HttpService,
|
64
|
-
uri: '/',
|
65
|
-
name: serviceDocument.name,
|
66
|
-
data: serviceDocument,
|
67
|
-
tags: serviceDocument.tags?.map(tag => tag.name) || [],
|
68
|
-
children: computeChildNodes(document, document, map, transformOperation),
|
69
|
-
};
|
70
|
-
|
71
|
-
return serviceNode;
|
72
|
-
}
|
73
|
-
|
74
|
-
function computeChildNodes(
|
75
|
-
document: Spec | OpenAPIObject,
|
76
|
-
data: unknown,
|
77
|
-
map: ISourceNodeMap[],
|
78
|
-
transformer: Oas2HttpOperationTransformer | Oas3HttpOperationTransformer,
|
79
|
-
parentUri: string = '',
|
80
|
-
) {
|
81
|
-
const nodes: ServiceChildNode[] = [];
|
82
|
-
|
83
|
-
if (!isObject(data)) return nodes;
|
84
|
-
|
85
|
-
for (const key of Object.keys(data)) {
|
86
|
-
const sanitizedKey = encodePointerFragment(key);
|
87
|
-
const match = findMapMatch(sanitizedKey, map);
|
88
|
-
if (match) {
|
89
|
-
const uri = `${parentUri}/${sanitizedKey}`;
|
90
|
-
|
91
|
-
const jsonPath = pointerToPath(`#${uri}`);
|
92
|
-
if (match.type === NodeTypes.Operation && jsonPath.length === 3) {
|
93
|
-
const path = String(jsonPath[1]);
|
94
|
-
const method = String(jsonPath[2]);
|
95
|
-
const operationDocument = transformer({ document, path, method });
|
96
|
-
let parsedUri;
|
97
|
-
const encodedPath = String(encodePointerFragment(path));
|
98
|
-
|
99
|
-
if (operationDocument.iid) {
|
100
|
-
parsedUri = `/operations/${operationDocument.iid}`;
|
101
|
-
} else {
|
102
|
-
parsedUri = uri.replace(encodedPath, slugify(path));
|
103
|
-
}
|
104
|
-
|
105
|
-
nodes.push({
|
106
|
-
type: NodeType.HttpOperation,
|
107
|
-
uri: parsedUri,
|
108
|
-
data: operationDocument,
|
109
|
-
name: operationDocument.summary || operationDocument.iid || operationDocument.path,
|
110
|
-
tags: operationDocument.tags?.map(tag => tag.name) || [],
|
111
|
-
});
|
112
|
-
} else if (match.type === NodeTypes.Model) {
|
113
|
-
const schemaDocument = get(document, jsonPath);
|
114
|
-
const parsedUri = uri.replace(OAS_MODEL_REGEXP, 'schemas/');
|
115
|
-
|
116
|
-
nodes.push({
|
117
|
-
type: NodeType.Model,
|
118
|
-
uri: parsedUri,
|
119
|
-
data: schemaDocument,
|
120
|
-
name: schemaDocument.title || last(uri.split('/')) || '',
|
121
|
-
tags: schemaDocument['x-tags'] || [],
|
122
|
-
});
|
123
|
-
}
|
124
|
-
|
125
|
-
if (match.children) {
|
126
|
-
nodes.push(...computeChildNodes(document, data[key], match.children, transformer, uri));
|
127
|
-
}
|
128
|
-
}
|
129
|
-
}
|
130
|
-
|
131
|
-
return nodes;
|
132
|
-
}
|
133
|
-
|
134
|
-
function findMapMatch(key: string | number, map: ISourceNodeMap[]): ISourceNodeMap | void {
|
135
|
-
if (typeof key === 'number') return;
|
136
|
-
for (const entry of map) {
|
137
|
-
if (!!entry.match?.match(key) || (entry.notMatch !== void 0 && !entry.notMatch.match(key))) {
|
138
|
-
return entry;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
}
|
142
|
-
|
143
|
-
export function isJson(value: string) {
|
144
|
-
try {
|
145
|
-
JSON.parse(value);
|
146
|
-
} catch (e) {
|
147
|
-
return false;
|
148
|
-
}
|
149
|
-
return true;
|
150
|
-
}
|
package/src/utils/oas/oas2.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import { ISourceNodeMap, NodeTypes } from './types';
|
2
|
-
|
3
|
-
export const oas2SourceMap: ISourceNodeMap[] = [
|
4
|
-
{
|
5
|
-
match: 'paths',
|
6
|
-
type: NodeTypes.Paths,
|
7
|
-
children: [
|
8
|
-
{
|
9
|
-
notMatch: '^x-',
|
10
|
-
type: NodeTypes.Path,
|
11
|
-
children: [
|
12
|
-
{
|
13
|
-
match: 'get|post|put|delete|options|head|patch|trace',
|
14
|
-
type: NodeTypes.Operation,
|
15
|
-
},
|
16
|
-
],
|
17
|
-
},
|
18
|
-
],
|
19
|
-
},
|
20
|
-
|
21
|
-
{
|
22
|
-
match: 'definitions',
|
23
|
-
type: NodeTypes.Models,
|
24
|
-
children: [
|
25
|
-
{
|
26
|
-
notMatch: '^x-',
|
27
|
-
type: NodeTypes.Model,
|
28
|
-
},
|
29
|
-
],
|
30
|
-
},
|
31
|
-
];
|
package/src/utils/oas/oas3.ts
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
import { ISourceNodeMap, NodeTypes } from './types';
|
2
|
-
|
3
|
-
export const oas3SourceMap: ISourceNodeMap[] = [
|
4
|
-
{
|
5
|
-
match: 'paths',
|
6
|
-
type: NodeTypes.Paths,
|
7
|
-
children: [
|
8
|
-
{
|
9
|
-
notMatch: '^x-',
|
10
|
-
type: NodeTypes.Path,
|
11
|
-
children: [
|
12
|
-
{
|
13
|
-
match: 'get|post|put|delete|options|head|patch|trace',
|
14
|
-
type: NodeTypes.Operation,
|
15
|
-
},
|
16
|
-
],
|
17
|
-
},
|
18
|
-
],
|
19
|
-
},
|
20
|
-
|
21
|
-
{
|
22
|
-
match: 'components',
|
23
|
-
type: NodeTypes.Components,
|
24
|
-
children: [
|
25
|
-
{
|
26
|
-
match: 'schemas',
|
27
|
-
type: NodeTypes.Models,
|
28
|
-
children: [
|
29
|
-
{
|
30
|
-
notMatch: '^x-',
|
31
|
-
type: NodeTypes.Model,
|
32
|
-
},
|
33
|
-
],
|
34
|
-
},
|
35
|
-
],
|
36
|
-
},
|
37
|
-
];
|
package/src/utils/oas/types.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import { IHttpOperation, IHttpService, NodeType } from '@stoplight/types';
|
2
|
-
import { JSONSchema7 } from 'json-schema';
|
3
|
-
|
4
|
-
export enum NodeTypes {
|
5
|
-
Paths = 'paths',
|
6
|
-
Path = 'path',
|
7
|
-
Operation = 'operation',
|
8
|
-
Components = 'components',
|
9
|
-
Models = 'models',
|
10
|
-
Model = 'model',
|
11
|
-
}
|
12
|
-
|
13
|
-
export interface ISourceNodeMap {
|
14
|
-
type: string;
|
15
|
-
match?: string;
|
16
|
-
notMatch?: string;
|
17
|
-
children?: ISourceNodeMap[];
|
18
|
-
}
|
19
|
-
|
20
|
-
type Node<T, D> = {
|
21
|
-
type: T;
|
22
|
-
uri: string;
|
23
|
-
name: string;
|
24
|
-
data: D;
|
25
|
-
tags: string[];
|
26
|
-
};
|
27
|
-
|
28
|
-
export type ServiceNode = Node<NodeType.HttpService, IHttpService> & { children: ServiceChildNode[] };
|
29
|
-
export type ServiceChildNode = OperationNode | SchemaNode;
|
30
|
-
export type OperationNode = Node<NodeType.HttpOperation, IHttpOperation>;
|
31
|
-
export type SchemaNode = Node<NodeType.Model, JSONSchema7>;
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import '../index';
|
2
|
-
|
3
|
-
import { parse } from '@stoplight/yaml';
|
4
|
-
import React from 'react';
|
5
|
-
|
6
|
-
import { zoomApiYaml } from '../../__fixtures__/api-descriptions/zoomApiYaml';
|
7
|
-
|
8
|
-
declare global {
|
9
|
-
namespace JSX {
|
10
|
-
interface IntrinsicElements {
|
11
|
-
'elements-api': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
const Template = (props: any) => <elements-api {...props} />;
|
17
|
-
|
18
|
-
export default {
|
19
|
-
title: 'web-components/API',
|
20
|
-
argTypes: {
|
21
|
-
apiDescriptionUrl: {
|
22
|
-
control: 'text',
|
23
|
-
},
|
24
|
-
apiDescriptionDocument: { control: 'text' },
|
25
|
-
layout: {
|
26
|
-
control: { type: 'inline-radio', options: ['sidebar', 'stacked'] },
|
27
|
-
defaultValue: 'sidebar',
|
28
|
-
},
|
29
|
-
},
|
30
|
-
};
|
31
|
-
|
32
|
-
export const TodosAPI = Template.bind({});
|
33
|
-
TodosAPI.args = {
|
34
|
-
apiDescriptionUrl: 'https://raw.githubusercontent.com/stoplightio/elements/main/demo/src/reference/todo.v1.yaml',
|
35
|
-
};
|
36
|
-
|
37
|
-
export const TodosAPIWithFixHeight = (props: any) => (
|
38
|
-
<div style={{ height: 400 }}>
|
39
|
-
<elements-api {...props} />
|
40
|
-
</div>
|
41
|
-
);
|
42
|
-
TodosAPIWithFixHeight.args = {
|
43
|
-
apiDescriptionUrl: 'https://raw.githubusercontent.com/stoplightio/elements/main/demo/src/reference/todo.v1.yaml',
|
44
|
-
};
|
45
|
-
TodosAPIWithFixHeight.storyName = 'TodosAPI with fixed height';
|
46
|
-
|
47
|
-
export const ZoomApi = Template.bind({});
|
48
|
-
ZoomApi.args = {
|
49
|
-
apiDescriptionUrl: 'https://raw.githubusercontent.com/stoplightio/Public-APIs/master/reference/zoom/openapi.yaml',
|
50
|
-
};
|
51
|
-
ZoomApi.storyName = 'Complex API with inline `$ref`s';
|
52
|
-
|
53
|
-
export const APIWithYamlProvidedDirectly = Template.bind({});
|
54
|
-
APIWithYamlProvidedDirectly.args = {
|
55
|
-
apiDescriptionDocument: zoomApiYaml,
|
56
|
-
};
|
57
|
-
APIWithYamlProvidedDirectly.storyName = 'API With Yaml Provided Directly';
|
58
|
-
|
59
|
-
export const APIWithJSONProvidedDirectly = Template.bind({});
|
60
|
-
APIWithJSONProvidedDirectly.args = {
|
61
|
-
apiDescriptionDocument: JSON.stringify(parse(zoomApiYaml), null, ' '),
|
62
|
-
};
|
63
|
-
APIWithJSONProvidedDirectly.storyName = 'API With JSON Provided Directly';
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { createElementClass } from '@stoplight/elements-core';
|
2
|
-
|
3
|
-
import { API } from '../index';
|
4
|
-
|
5
|
-
export const ApiElement = createElementClass(API, {
|
6
|
-
apiDescriptionUrl: { type: 'string', defaultValue: '' },
|
7
|
-
apiDescriptionDocument: { type: 'string', defaultValue: '' },
|
8
|
-
basePath: { type: 'string' },
|
9
|
-
staticRouterPath: { type: 'string' },
|
10
|
-
router: { type: 'string' },
|
11
|
-
layout: { type: 'string' },
|
12
|
-
hideTryIt: { type: 'boolean' },
|
13
|
-
hideSchemas: { type: 'boolean' },
|
14
|
-
hideInternal: { type: 'boolean' },
|
15
|
-
hideExport: { type: 'boolean' },
|
16
|
-
logo: { type: 'string' },
|
17
|
-
tryItCredentialsPolicy: { type: 'string' },
|
18
|
-
tryItCorsProxy: { type: 'string' },
|
19
|
-
tryItOutDefaultServer: { type: 'string' },
|
20
|
-
});
|
package/tsconfig.build.json
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": "./tsconfig.json",
|
3
|
-
"include": [
|
4
|
-
"src"
|
5
|
-
],
|
6
|
-
"exclude": [
|
7
|
-
"**/__*__/**"
|
8
|
-
],
|
9
|
-
"compilerOptions": {
|
10
|
-
"baseUrl": "./",
|
11
|
-
"outDir": "dist",
|
12
|
-
"moduleResolution": "node",
|
13
|
-
"paths": {
|
14
|
-
"@stoplight/elements-core": ["../elements-core/dist"],
|
15
|
-
"@stoplight/elements-core/*": ["../elements-core/dist/*"],
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
package/tsconfig.json
DELETED
package/web-components.config.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require('../../web-components.webpack.config');
|
File without changes
|