@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,430 @@
1
+ export const todosApiBundled = `
2
+ openapi: 3.0.0
3
+ info:
4
+ title: To-dos
5
+ version: 1.0.0
6
+ description: "![](https://i.ibb.co/v3Yt03v/todo-api-background.png)\n\n## \U0001F4AB Overview\n\nTo Do API provides a simple way for people to manage their tasks and plan their day. This API can be used to create mobile and web applications.This API is documented using **OpenAPI 3.0**. The implementation lives in this [GitHub repo](https://github.com/stoplightio/studio-demo/blob/master/reference/todos/todo.v1.yaml).\n\n### \U0001F9F0 Cross-Origin Resource Sharing\nThis API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). CORS support is necessary to make calls from the request maker within the API docs.\n\n### \U0001F3C1 Trying out your own API Specification\nElements can be used to generate API docs for any OpenAPI document. Replace this OpenAPI with a URL to your own OpenAPI document to get started. "
7
+ contact:
8
+ name: Stoplight Support
9
+ email: support@stoplight.io
10
+ url: 'https://www.stoplight.io'
11
+ license:
12
+ name: MIT
13
+ url: 'https://spdx.org/licenses/MIT'
14
+ termsOfService: 'https://stoplight.io/terms/'
15
+ servers:
16
+ - url: 'https://todos.stoplight.io'
17
+ description: Production
18
+ - description: Sandbox
19
+ url: 'https://todos-sandbox.stoplight.io'
20
+ paths:
21
+ /todos:
22
+ get:
23
+ summary: List Todos
24
+ responses:
25
+ '200':
26
+ description: Returns a list of Todos
27
+ content:
28
+ application/json:
29
+ schema:
30
+ type: array
31
+ items:
32
+ $ref: '#/components/schemas/Todos'
33
+ examples:
34
+ List of Todos:
35
+ $ref: '#/components/examples/multiple-todos'
36
+ '403':
37
+ $ref: '#/components/responses/Unauthorized'
38
+ '404':
39
+ $ref: '#/components/responses/NotFound'
40
+ operationId: get-todos
41
+ description: >-
42
+ Returns a list of todos
43
+
44
+
45
+ *Markdown is supported in descriptions. Add information here for users
46
+ to get accustomed to endpoints*
47
+ parameters:
48
+ - $ref: '#/components/parameters/limit'
49
+ - $ref: '#/components/parameters/contentType'
50
+ security: []
51
+ post:
52
+ summary: Create Todo
53
+ operationId: post-todos
54
+ responses:
55
+ '201':
56
+ description: New Todo Created
57
+ content:
58
+ multipart/form-data:
59
+ schema:
60
+ $ref: '#/components/schemas/Todos'
61
+ examples:
62
+ Example Todo:
63
+ $ref: '#/components/examples/todo'
64
+ '403':
65
+ $ref: '#/components/responses/Unauthorized'
66
+ '404':
67
+ $ref: '#/components/responses/NotFound'
68
+ description: >-
69
+ This creates a Todo object
70
+
71
+
72
+ *Markdown is supported in descriptions. Add information here for users
73
+ to get accustomed to endpoints*
74
+ requestBody:
75
+ content:
76
+ application/json:
77
+ schema:
78
+ $ref: '#/components/schemas/Todos'
79
+ description: Name of the Todo
80
+ parameters:
81
+ - $ref: '#/components/parameters/contentType'
82
+ security:
83
+ - API Key: []
84
+ '/todos/{id}':
85
+ get:
86
+ summary: Get Todo
87
+ responses:
88
+ '200':
89
+ description: Returns the Todo for the ID
90
+ content:
91
+ application/json:
92
+ schema:
93
+ $ref: '#/components/schemas/Todos'
94
+ examples:
95
+ Example Todo:
96
+ $ref: '#/components/examples/todo'
97
+ '403':
98
+ $ref: '#/components/responses/Unauthorized'
99
+ '404':
100
+ $ref: '#/components/responses/NotFound'
101
+ operationId: get-todos-id
102
+ description: >-
103
+ Get a single todo using an ID
104
+
105
+
106
+ *Markdown is supported in descriptions. Add information here for users
107
+ to get accustomed to endpoints*
108
+ parameters: []
109
+ security: []
110
+ put:
111
+ summary: Replace Todo
112
+ operationId: put-todos-id
113
+ responses:
114
+ '200':
115
+ description: Todo Updated
116
+ '403':
117
+ $ref: '#/components/responses/Unauthorized'
118
+ '404':
119
+ $ref: '#/components/responses/NotFound'
120
+ requestBody:
121
+ content:
122
+ application/json:
123
+ schema:
124
+ $ref: '#/components/schemas/Todos'
125
+ description: ''
126
+ description: >-
127
+ Update a single todo using an ID
128
+
129
+
130
+ *Markdown is supported in descriptions. Add information here for users
131
+ to get accustomed to endpoints*
132
+ parameters:
133
+ - $ref: '#/components/parameters/contentType'
134
+ security:
135
+ - API Key: []
136
+ delete:
137
+ summary: Delete Todo
138
+ operationId: delete-todos-id
139
+ responses:
140
+ '200':
141
+ description: Todo Deleted
142
+ content:
143
+ application/json:
144
+ schema:
145
+ $ref: '#/components/schemas/Todos'
146
+ examples:
147
+ Example Todo:
148
+ $ref: '#/components/examples/todo'
149
+ '403':
150
+ $ref: '#/components/responses/Unauthorized'
151
+ '404':
152
+ $ref: '#/components/responses/NotFound'
153
+ description: >-
154
+ Delete a todo using an ID
155
+
156
+
157
+ *Markdown is supported in descriptions. Add information here for users
158
+ to get accustomed to endpoints*
159
+ security:
160
+ - API Key: []
161
+ patch:
162
+ summary: Update Todo
163
+ operationId: patch-todos-id
164
+ responses:
165
+ '200':
166
+ description: Todo Updated
167
+ '403':
168
+ $ref: '#/components/responses/Unauthorized'
169
+ '404':
170
+ $ref: '#/components/responses/NotFound'
171
+ deprecated: true
172
+ description: >-
173
+ Don't use this endpoint. Notice it's deprecated.
174
+
175
+
176
+ *Markdown is supported in descriptions. Add information here for users
177
+ to get accustomed to endpoints*
178
+ requestBody:
179
+ content:
180
+ application/json:
181
+ schema:
182
+ $ref: '#/components/schemas/Todos'
183
+ security:
184
+ - API Key: []
185
+ parameters:
186
+ - $ref: '#/components/parameters/ID'
187
+ /users:
188
+ get:
189
+ summary: Get User
190
+ tags:
191
+ - Users
192
+ responses:
193
+ '200':
194
+ description: OK
195
+ content:
196
+ application/json:
197
+ schema:
198
+ type: array
199
+ items:
200
+ $ref: '#/components/schemas/User'
201
+ '404':
202
+ $ref: '#/components/responses/NotFound'
203
+ operationId: get-users
204
+ description: >-
205
+ Get a user by ID
206
+
207
+
208
+ *Markdown is supported in descriptions. Add information here for users
209
+ to get accustomed to endpoints*
210
+ parameters:
211
+ - $ref: '#/components/parameters/contentType'
212
+ security: []
213
+ parameters: []
214
+ delete:
215
+ summary: Delete User
216
+ operationId: delete-users-userID
217
+ responses:
218
+ '200':
219
+ description: OK
220
+ content:
221
+ application/json:
222
+ schema:
223
+ $ref: '#/components/schemas/User'
224
+ description: Delete a user by ID
225
+ tags:
226
+ - Users
227
+ security:
228
+ - API Key: []
229
+ post:
230
+ summary: Create User
231
+ operationId: post-users-userID
232
+ responses:
233
+ '201':
234
+ description: User Created
235
+ content:
236
+ application/json:
237
+ schema:
238
+ $ref: '#/components/schemas/User'
239
+ examples:
240
+ Example User:
241
+ $ref: '#/components/examples/user'
242
+ description: Create a User
243
+ requestBody:
244
+ content:
245
+ application/json:
246
+ schema:
247
+ $ref: '#/components/schemas/User'
248
+ examples: {}
249
+ tags:
250
+ - Users
251
+ parameters:
252
+ - $ref: '#/components/parameters/contentType'
253
+ security:
254
+ - API Key: []
255
+ components:
256
+ schemas:
257
+ Todos:
258
+ description: I'm a model's description.
259
+ type: object
260
+ x-examples: {}
261
+ title: Todo
262
+ properties:
263
+ id:
264
+ type: number
265
+ minimum: 0
266
+ maximum: 9999
267
+ description: ID of the task
268
+ readOnly: true
269
+ name:
270
+ type: string
271
+ minLength: 1
272
+ maxLength: 100
273
+ description: Name of the task
274
+ completed:
275
+ type: boolean
276
+ default: false
277
+ description: Boolean indicating if the task has been completed or not
278
+ completed_at:
279
+ type: string
280
+ format: date-time
281
+ description: Time when the task was completed
282
+ readOnly: true
283
+ created_at:
284
+ type: string
285
+ format: date-time
286
+ description: Time when the task was created
287
+ readOnly: true
288
+ updated_at:
289
+ type: string
290
+ format: date-time
291
+ description: Time when the task was updated
292
+ readOnly: true
293
+ required:
294
+ - id
295
+ - name
296
+ - completed_at
297
+ - created_at
298
+ - updated_at
299
+ User:
300
+ description: ''
301
+ type: object
302
+ title: User
303
+ properties:
304
+ userId:
305
+ type: number
306
+ description: ID of the user
307
+ readOnly: true
308
+ firstName:
309
+ type: string
310
+ minLength: 1
311
+ description: ''
312
+ lastName:
313
+ type: string
314
+ minLength: 1
315
+ description: ''
316
+ phoneNumber:
317
+ type: string
318
+ minLength: 1
319
+ description: Official Phone Number
320
+ emailAddress:
321
+ type: string
322
+ minLength: 1
323
+ description: Work Email Address
324
+ required:
325
+ - userId
326
+ - firstName
327
+ - lastName
328
+ - phoneNumber
329
+ - emailAddress
330
+ securitySchemes:
331
+ API Key:
332
+ name: apikey
333
+ type: apiKey
334
+ in: query
335
+ description: Just use \`123\`. It's super secure ;)
336
+ parameters:
337
+ limit:
338
+ name: limit
339
+ in: query
340
+ required: false
341
+ schema:
342
+ type: number
343
+ description: >-
344
+ Return a limited set of results *I'm a shared parameter. I can be reused
345
+ in multiple endpoints!*
346
+ contentType:
347
+ name: Content-Type
348
+ in: header
349
+ required: true
350
+ schema:
351
+ type: string
352
+ default: application/json
353
+ description: application/json
354
+ ID:
355
+ name: id
356
+ in: path
357
+ required: true
358
+ schema:
359
+ type: string
360
+ description: ID of the Todo
361
+ responses:
362
+ NotFound:
363
+ description: Resource not found
364
+ content:
365
+ application/json:
366
+ schema:
367
+ title: Error
368
+ type: object
369
+ description: A standard error object.
370
+ x-tags:
371
+ - Common
372
+ properties:
373
+ status:
374
+ type: string
375
+ description: A code.
376
+ error:
377
+ type: string
378
+ required:
379
+ - status
380
+ - error
381
+ Unauthorized:
382
+ description: Action not allowed
383
+ content:
384
+ application/json:
385
+ schema:
386
+ type: object
387
+ properties:
388
+ message:
389
+ type: string
390
+ required:
391
+ - message
392
+ examples:
393
+ todo:
394
+ value:
395
+ id: 0
396
+ name: string
397
+ completed: true
398
+ completed_at: '2019-08-24T14:15:22Z'
399
+ created_at: '2019-08-24T14:15:22Z'
400
+ updated_at: '2019-08-24T14:15:22Z'
401
+ multiple-todos:
402
+ value:
403
+ - id: 0
404
+ name: my todo
405
+ completed: true
406
+ completed_at: '2019-08-24T14:15:22Z'
407
+ created_at: '2019-08-24T14:15:22Z'
408
+ updated_at: '2019-08-24T14:15:22Z'
409
+ - id: 1
410
+ name: another todo
411
+ completed: false
412
+ completed_at: '2019-08-24T14:15:22Z'
413
+ created_at: '2019-08-24T14:15:22Z'
414
+ updated_at: '2019-08-24T14:15:22Z'
415
+ - id: 2
416
+ name: yet another todo
417
+ completed: false
418
+ completed_at: '2019-08-24T14:15:22Z'
419
+ created_at: '2019-08-24T14:15:22Z'
420
+ updated_at: '2019-08-24T14:15:22Z'
421
+ user:
422
+ value:
423
+ userId: 2
424
+ firstName: racks
425
+ lastName: jacson
426
+ phoneNumber: '123456'
427
+ emailAddress: racks.jacson@learningcontainer.com
428
+ tags:
429
+ - name: Todos
430
+ `;