@jpmorganchase/elemental 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/.storybook/main.js +1 -0
  2. package/.storybook/manager.js +1 -0
  3. package/.storybook/preview.jsx +3 -0
  4. package/LICENSE +190 -0
  5. package/README.md +19 -0
  6. package/jest.config.js +7 -0
  7. package/package.json +111 -0
  8. package/src/__fixtures__/api-descriptions/Instagram.ts +1859 -0
  9. package/src/__fixtures__/api-descriptions/badgesForSchema.ts +36 -0
  10. package/src/__fixtures__/api-descriptions/simpleApiWithInternalOperations.ts +253 -0
  11. package/src/__fixtures__/api-descriptions/simpleApiWithoutDescription.ts +243 -0
  12. package/src/__fixtures__/api-descriptions/todosApiBundled.ts +430 -0
  13. package/src/__fixtures__/api-descriptions/zoomApiYaml.ts +6083 -0
  14. package/src/components/API/APIWithSidebarLayout.tsx +111 -0
  15. package/src/components/API/APIWithStackedLayout.tsx +220 -0
  16. package/src/components/API/__tests__/utils.test.ts +848 -0
  17. package/src/components/API/utils.ts +174 -0
  18. package/src/containers/API.spec.tsx +131 -0
  19. package/src/containers/API.stories.tsx +99 -0
  20. package/src/containers/API.tsx +200 -0
  21. package/src/hooks/useExportDocumentProps.spec.tsx +68 -0
  22. package/src/hooks/useExportDocumentProps.tsx +48 -0
  23. package/src/index.ts +2 -0
  24. package/src/styles.css +1 -0
  25. package/src/utils/oas/__tests__/oas.spec.ts +272 -0
  26. package/src/utils/oas/index.ts +150 -0
  27. package/src/utils/oas/oas2.ts +31 -0
  28. package/src/utils/oas/oas3.ts +37 -0
  29. package/src/utils/oas/types.ts +31 -0
  30. package/src/web-components/__stories__/Api.stories.tsx +63 -0
  31. package/src/web-components/components.ts +20 -0
  32. package/src/web-components/index.ts +3 -0
  33. package/tsconfig.build.json +18 -0
  34. package/tsconfig.json +7 -0
  35. package/web-components.config.js +1 -0
@@ -0,0 +1,36 @@
1
+ export const badgesForSchema = /* language=yaml */ `
2
+ openapi: 3.1.0
3
+ info:
4
+ title: Schema Badges Sample
5
+ description: 'Sample with deprecated and internal badges on schema component'
6
+ contact:
7
+ url: 'https://example.com'
8
+ email: example@example.com
9
+ name: John Johnson
10
+ version: 0.0.0
11
+ components:
12
+ schemas:
13
+ ValidationParams:
14
+ description: Validation parameters
15
+ deprecated: true
16
+ properties:
17
+ groupName:
18
+ type: string
19
+ version:
20
+ type: string
21
+ enum:
22
+ - ok
23
+ - error
24
+ ValidationReport:
25
+ description: Validation report
26
+ deprecated: true
27
+ x-internal: true
28
+ properties:
29
+ validationId:
30
+ type: string
31
+ status:
32
+ type: string
33
+ enum:
34
+ - ok
35
+ - error
36
+ `;
@@ -0,0 +1,253 @@
1
+ export const simpleApiWithInternalOperations = {
2
+ swagger: '2.0',
3
+ info: {
4
+ title: 'To-dos',
5
+ description: 'Great API, but has internal operations.',
6
+ version: '1.0',
7
+ contact: {
8
+ name: 'Stoplight',
9
+ url: 'https://stoplight.io',
10
+ },
11
+ license: {
12
+ name: 'MIT',
13
+ },
14
+ },
15
+ host: 'todos.stoplight.io',
16
+ schemes: ['https', 'http'],
17
+ consumes: ['application/json'],
18
+ produces: ['application/json'],
19
+ securityDefinitions: {
20
+ apikey: {
21
+ name: 'apikey',
22
+ type: 'apiKey',
23
+ in: 'query',
24
+ description: "Use `?apikey=123` to authenticate requests. It's super secure.",
25
+ },
26
+ },
27
+ tags: [
28
+ {
29
+ name: 'Todos',
30
+ },
31
+ ],
32
+ paths: {
33
+ '/todos/{todoId}': {
34
+ parameters: [
35
+ {
36
+ name: 'todoId',
37
+ in: 'path',
38
+ required: true,
39
+ type: 'string',
40
+ },
41
+ ],
42
+ get: {
43
+ operationId: 'GET_todo',
44
+ summary: 'Get Todo',
45
+ tags: ['Todos'],
46
+ 'x-internal': true,
47
+ responses: {
48
+ '200': {
49
+ description: '',
50
+ schema: {
51
+ $ref: './models/todo-full.v1.json',
52
+ },
53
+ examples: {
54
+ 'application/json': {
55
+ id: 1,
56
+ name: 'get food',
57
+ completed: false,
58
+ completed_at: '1955-04-23T13:22:52.685Z',
59
+ created_at: '1994-11-05T03:26:51.471Z',
60
+ updated_at: '1989-07-29T11:30:06.701Z',
61
+ },
62
+ },
63
+ },
64
+ '404': {
65
+ $ref: '../common/openapi.v1.yaml#/responses/404',
66
+ },
67
+ '500': {
68
+ $ref: '../common/openapi.v1.yaml#/responses/500',
69
+ },
70
+ },
71
+ },
72
+ put: {
73
+ operationId: 'PUT_todos',
74
+ summary: 'Update Todo',
75
+ tags: ['Todos'],
76
+ parameters: [
77
+ {
78
+ name: 'body',
79
+ in: 'body',
80
+ schema: {
81
+ $ref: './models/todo-partial.v1.json',
82
+ example: {
83
+ name: "my todo's new name",
84
+ completed: false,
85
+ },
86
+ },
87
+ },
88
+ ],
89
+ responses: {
90
+ '200': {
91
+ description: '',
92
+ schema: {
93
+ $ref: './models/todo-full.v1.json',
94
+ },
95
+ examples: {
96
+ 'application/json': {
97
+ id: 9000,
98
+ name: "It's Over 9000!!!",
99
+ completed: true,
100
+ completed_at: null,
101
+ created_at: '2014-08-28T14:14:28.494Z',
102
+ updated_at: '2015-08-28T14:14:28.494Z',
103
+ },
104
+ },
105
+ },
106
+ '401': {
107
+ $ref: '../common/openapi.v1.yaml#/responses/401',
108
+ },
109
+ '404': {
110
+ $ref: '../common/openapi.v1.yaml#/responses/404',
111
+ },
112
+ '500': {
113
+ $ref: '../common/openapi.v1.yaml#/responses/500',
114
+ },
115
+ },
116
+ security: [
117
+ {
118
+ apikey: [],
119
+ },
120
+ ],
121
+ },
122
+ delete: {
123
+ operationId: 'DELETE_todo',
124
+ summary: 'Delete Todo',
125
+ tags: ['Todos'],
126
+ responses: {
127
+ '204': {
128
+ description: '',
129
+ },
130
+ '401': {
131
+ $ref: '../common/openapi.v1.yaml#/responses/401',
132
+ },
133
+ '404': {
134
+ $ref: '../common/openapi.v1.yaml#/responses/404',
135
+ },
136
+ '500': {
137
+ $ref: '../common/openapi.v1.yaml#/responses/500',
138
+ },
139
+ },
140
+ security: [
141
+ {
142
+ apikey: [],
143
+ },
144
+ ],
145
+ },
146
+ },
147
+ '/todos': {
148
+ post: {
149
+ operationId: 'POST_todos',
150
+ summary: 'Create Todo',
151
+ tags: ['Todos'],
152
+ parameters: [
153
+ {
154
+ name: 'body',
155
+ in: 'body',
156
+ schema: {
157
+ $ref: './models/todo-partial.v1.json',
158
+ example: {
159
+ name: "my todo's name",
160
+ completed: false,
161
+ },
162
+ },
163
+ },
164
+ ],
165
+ responses: {
166
+ '201': {
167
+ description: '',
168
+ schema: {
169
+ $ref: './models/todo-full.v1.json',
170
+ },
171
+ examples: {
172
+ 'application/json': {
173
+ id: 9000,
174
+ name: "It's Over 9000!!!",
175
+ completed: null,
176
+ completed_at: null,
177
+ created_at: '2014-08-28T14:14:28.494Z',
178
+ updated_at: '2014-08-28T14:14:28.494Z',
179
+ },
180
+ },
181
+ },
182
+ '401': {
183
+ $ref: '../common/openapi.v1.yaml#/responses/401',
184
+ },
185
+ '500': {
186
+ $ref: '../common/openapi.v1.yaml#/responses/500',
187
+ },
188
+ },
189
+ security: [
190
+ {
191
+ apikey: [],
192
+ },
193
+ ],
194
+ description: 'This creates a Todo object.\n\nTesting `inline code`.',
195
+ },
196
+ get: {
197
+ operationId: 'GET_todos',
198
+ summary: 'List Todos',
199
+ tags: ['Todos'],
200
+ parameters: [
201
+ {
202
+ $ref: '../common/openapi.v1.yaml#/parameters/limit',
203
+ },
204
+ {
205
+ $ref: '../common/openapi.v1.yaml#/parameters/skip',
206
+ },
207
+ ],
208
+ responses: {
209
+ '200': {
210
+ description: 'wefwefwef',
211
+ schema: {
212
+ type: 'array',
213
+ items: {
214
+ $ref: './models/todo-full.v1.json',
215
+ },
216
+ },
217
+ examples: {
218
+ 'application/json': [
219
+ {
220
+ id: 1,
221
+ name: 'design the thingz',
222
+ completed: true,
223
+ },
224
+ {
225
+ id: 2,
226
+ name: 'mock the thingz',
227
+ completed: true,
228
+ },
229
+ {
230
+ id: 3,
231
+ name: 'code the thingz',
232
+ completed: false,
233
+ },
234
+ ],
235
+ },
236
+ },
237
+ '500': {
238
+ $ref: '../common/openapi.v1.yaml#/responses/500',
239
+ },
240
+ },
241
+ description: 'This returns a list of todos.',
242
+ },
243
+ },
244
+ },
245
+ definitions: {
246
+ InternalSchema: {
247
+ title: 'Internal Schema',
248
+ description: 'Fun Internal Schema',
249
+ schema: { type: 'object' },
250
+ 'x-internal': true,
251
+ },
252
+ },
253
+ };
@@ -0,0 +1,243 @@
1
+ export const simpleApiWithoutDescription = {
2
+ swagger: '2.0',
3
+ info: {
4
+ title: 'To-dos',
5
+ version: '1.0',
6
+ contact: {
7
+ name: 'Stoplight',
8
+ url: 'https://stoplight.io',
9
+ },
10
+ license: {
11
+ name: 'MIT',
12
+ },
13
+ },
14
+ host: 'todos.stoplight.io',
15
+ schemes: ['https', 'http'],
16
+ consumes: ['application/json'],
17
+ produces: ['application/json'],
18
+ securityDefinitions: {
19
+ apikey: {
20
+ name: 'apikey',
21
+ type: 'apiKey',
22
+ in: 'query',
23
+ description: "Use `?apikey=123` to authenticate requests. It's super secure.",
24
+ },
25
+ },
26
+ tags: [
27
+ {
28
+ name: 'Todos',
29
+ },
30
+ ],
31
+ paths: {
32
+ '/todos/{todoId}': {
33
+ parameters: [
34
+ {
35
+ name: 'todoId',
36
+ in: 'path',
37
+ required: true,
38
+ type: 'string',
39
+ },
40
+ ],
41
+ get: {
42
+ operationId: 'GET_todo',
43
+ summary: 'Get Todo',
44
+ tags: ['Todos'],
45
+ responses: {
46
+ '200': {
47
+ description: '',
48
+ schema: {
49
+ $ref: './models/todo-full.v1.json',
50
+ },
51
+ examples: {
52
+ 'application/json': {
53
+ id: 1,
54
+ name: 'get food',
55
+ completed: false,
56
+ completed_at: '1955-04-23T13:22:52.685Z',
57
+ created_at: '1994-11-05T03:26:51.471Z',
58
+ updated_at: '1989-07-29T11:30:06.701Z',
59
+ },
60
+ },
61
+ },
62
+ '404': {
63
+ $ref: '../common/openapi.v1.yaml#/responses/404',
64
+ },
65
+ '500': {
66
+ $ref: '../common/openapi.v1.yaml#/responses/500',
67
+ },
68
+ },
69
+ },
70
+ put: {
71
+ operationId: 'PUT_todos',
72
+ summary: 'Update Todo',
73
+ tags: ['Todos'],
74
+ parameters: [
75
+ {
76
+ name: 'body',
77
+ in: 'body',
78
+ schema: {
79
+ $ref: './models/todo-partial.v1.json',
80
+ example: {
81
+ name: "my todo's new name",
82
+ completed: false,
83
+ },
84
+ },
85
+ },
86
+ ],
87
+ responses: {
88
+ '200': {
89
+ description: '',
90
+ schema: {
91
+ $ref: './models/todo-full.v1.json',
92
+ },
93
+ examples: {
94
+ 'application/json': {
95
+ id: 9000,
96
+ name: "It's Over 9000!!!",
97
+ completed: true,
98
+ completed_at: null,
99
+ created_at: '2014-08-28T14:14:28.494Z',
100
+ updated_at: '2015-08-28T14:14:28.494Z',
101
+ },
102
+ },
103
+ },
104
+ '401': {
105
+ $ref: '../common/openapi.v1.yaml#/responses/401',
106
+ },
107
+ '404': {
108
+ $ref: '../common/openapi.v1.yaml#/responses/404',
109
+ },
110
+ '500': {
111
+ $ref: '../common/openapi.v1.yaml#/responses/500',
112
+ },
113
+ },
114
+ security: [
115
+ {
116
+ apikey: [],
117
+ },
118
+ ],
119
+ },
120
+ delete: {
121
+ operationId: 'DELETE_todo',
122
+ summary: 'Delete Todo',
123
+ tags: ['Todos'],
124
+ responses: {
125
+ '204': {
126
+ description: '',
127
+ },
128
+ '401': {
129
+ $ref: '../common/openapi.v1.yaml#/responses/401',
130
+ },
131
+ '404': {
132
+ $ref: '../common/openapi.v1.yaml#/responses/404',
133
+ },
134
+ '500': {
135
+ $ref: '../common/openapi.v1.yaml#/responses/500',
136
+ },
137
+ },
138
+ security: [
139
+ {
140
+ apikey: [],
141
+ },
142
+ ],
143
+ },
144
+ },
145
+ '/todos': {
146
+ post: {
147
+ operationId: 'POST_todos',
148
+ summary: 'Create Todo',
149
+ tags: ['Todos'],
150
+ parameters: [
151
+ {
152
+ name: 'body',
153
+ in: 'body',
154
+ schema: {
155
+ $ref: './models/todo-partial.v1.json',
156
+ example: {
157
+ name: "my todo's name",
158
+ completed: false,
159
+ },
160
+ },
161
+ },
162
+ ],
163
+ responses: {
164
+ '201': {
165
+ description: '',
166
+ schema: {
167
+ $ref: './models/todo-full.v1.json',
168
+ },
169
+ examples: {
170
+ 'application/json': {
171
+ id: 9000,
172
+ name: "It's Over 9000!!!",
173
+ completed: null,
174
+ completed_at: null,
175
+ created_at: '2014-08-28T14:14:28.494Z',
176
+ updated_at: '2014-08-28T14:14:28.494Z',
177
+ },
178
+ },
179
+ },
180
+ '401': {
181
+ $ref: '../common/openapi.v1.yaml#/responses/401',
182
+ },
183
+ '500': {
184
+ $ref: '../common/openapi.v1.yaml#/responses/500',
185
+ },
186
+ },
187
+ security: [
188
+ {
189
+ apikey: [],
190
+ },
191
+ ],
192
+ description: 'This creates a Todo object.\n\nTesting `inline code`.',
193
+ },
194
+ get: {
195
+ operationId: 'GET_todos',
196
+ summary: 'List Todos',
197
+ tags: ['Todos'],
198
+ parameters: [
199
+ {
200
+ $ref: '../common/openapi.v1.yaml#/parameters/limit',
201
+ },
202
+ {
203
+ $ref: '../common/openapi.v1.yaml#/parameters/skip',
204
+ },
205
+ ],
206
+ responses: {
207
+ '200': {
208
+ description: 'wefwefwef',
209
+ schema: {
210
+ type: 'array',
211
+ items: {
212
+ $ref: './models/todo-full.v1.json',
213
+ },
214
+ },
215
+ examples: {
216
+ 'application/json': [
217
+ {
218
+ id: 1,
219
+ name: 'design the thingz',
220
+ completed: true,
221
+ },
222
+ {
223
+ id: 2,
224
+ name: 'mock the thingz',
225
+ completed: true,
226
+ },
227
+ {
228
+ id: 3,
229
+ name: 'code the thingz',
230
+ completed: false,
231
+ },
232
+ ],
233
+ },
234
+ },
235
+ '500': {
236
+ $ref: '../common/openapi.v1.yaml#/responses/500',
237
+ },
238
+ },
239
+ description: 'This returns a list of todos.',
240
+ },
241
+ },
242
+ },
243
+ };