mastra 0.1.57-unstable.35 → 0.1.57-unstable.36

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 (97) hide show
  1. package/package.json +2 -16
  2. package/node_modules/express/History.md +0 -3647
  3. package/node_modules/express/LICENSE +0 -24
  4. package/node_modules/express/Readme.md +0 -260
  5. package/node_modules/express/index.js +0 -11
  6. package/node_modules/express/lib/application.js +0 -661
  7. package/node_modules/express/lib/express.js +0 -116
  8. package/node_modules/express/lib/middleware/init.js +0 -43
  9. package/node_modules/express/lib/middleware/query.js +0 -47
  10. package/node_modules/express/lib/request.js +0 -525
  11. package/node_modules/express/lib/response.js +0 -1179
  12. package/node_modules/express/lib/router/index.js +0 -673
  13. package/node_modules/express/lib/router/layer.js +0 -181
  14. package/node_modules/express/lib/router/route.js +0 -230
  15. package/node_modules/express/lib/utils.js +0 -303
  16. package/node_modules/express/lib/view.js +0 -182
  17. package/node_modules/express/package.json +0 -98
  18. package/node_modules/express-jsdoc-swagger/.all-contributorsrc +0 -168
  19. package/node_modules/express-jsdoc-swagger/.eslintignore +0 -6
  20. package/node_modules/express-jsdoc-swagger/.eslintrc.json +0 -37
  21. package/node_modules/express-jsdoc-swagger/CODE_OF_CONDUCT.md +0 -76
  22. package/node_modules/express-jsdoc-swagger/CONTRIBUTING.md +0 -55
  23. package/node_modules/express-jsdoc-swagger/LICENSE.md +0 -21
  24. package/node_modules/express-jsdoc-swagger/README.md +0 -376
  25. package/node_modules/express-jsdoc-swagger/commitlint.config.js +0 -24
  26. package/node_modules/express-jsdoc-swagger/config/default.js +0 -18
  27. package/node_modules/express-jsdoc-swagger/config/swaggerEvents.js +0 -5
  28. package/node_modules/express-jsdoc-swagger/consumers/getOnlyComments.js +0 -21
  29. package/node_modules/express-jsdoc-swagger/consumers/globFilesMatches.js +0 -50
  30. package/node_modules/express-jsdoc-swagger/consumers/jsdocInfo.js +0 -20
  31. package/node_modules/express-jsdoc-swagger/consumers/readFiles.js +0 -9
  32. package/node_modules/express-jsdoc-swagger/consumers/utils/getComments.js +0 -13
  33. package/node_modules/express-jsdoc-swagger/consumers/utils/readFile.js +0 -15
  34. package/node_modules/express-jsdoc-swagger/index.d.ts +0 -65
  35. package/node_modules/express-jsdoc-swagger/index.js +0 -60
  36. package/node_modules/express-jsdoc-swagger/package.json +0 -59
  37. package/node_modules/express-jsdoc-swagger/processSwagger.js +0 -45
  38. package/node_modules/express-jsdoc-swagger/swaggerEvents.js +0 -35
  39. package/node_modules/express-jsdoc-swagger/transforms/basic/contact.js +0 -18
  40. package/node_modules/express-jsdoc-swagger/transforms/basic/index.js +0 -10
  41. package/node_modules/express-jsdoc-swagger/transforms/basic/info.js +0 -26
  42. package/node_modules/express-jsdoc-swagger/transforms/basic/license.js +0 -14
  43. package/node_modules/express-jsdoc-swagger/transforms/basic/servers.js +0 -20
  44. package/node_modules/express-jsdoc-swagger/transforms/components/index.js +0 -130
  45. package/node_modules/express-jsdoc-swagger/transforms/index.js +0 -13
  46. package/node_modules/express-jsdoc-swagger/transforms/paths/content.js +0 -18
  47. package/node_modules/express-jsdoc-swagger/transforms/paths/examples.js +0 -98
  48. package/node_modules/express-jsdoc-swagger/transforms/paths/formParams.js +0 -40
  49. package/node_modules/express-jsdoc-swagger/transforms/paths/index.js +0 -127
  50. package/node_modules/express-jsdoc-swagger/transforms/paths/parameters.js +0 -80
  51. package/node_modules/express-jsdoc-swagger/transforms/paths/requestBody.js +0 -65
  52. package/node_modules/express-jsdoc-swagger/transforms/paths/responses.js +0 -55
  53. package/node_modules/express-jsdoc-swagger/transforms/paths/schema.js +0 -33
  54. package/node_modules/express-jsdoc-swagger/transforms/paths/security.js +0 -31
  55. package/node_modules/express-jsdoc-swagger/transforms/paths/validStatusCodes.js +0 -64
  56. package/node_modules/express-jsdoc-swagger/transforms/security/index.js +0 -18
  57. package/node_modules/express-jsdoc-swagger/transforms/tags/index.js +0 -41
  58. package/node_modules/express-jsdoc-swagger/transforms/utils/arrays.js +0 -12
  59. package/node_modules/express-jsdoc-swagger/transforms/utils/combineSchema.js +0 -67
  60. package/node_modules/express-jsdoc-swagger/transforms/utils/enumValues.js +0 -6
  61. package/node_modules/express-jsdoc-swagger/transforms/utils/errorMessage.js +0 -8
  62. package/node_modules/express-jsdoc-swagger/transforms/utils/formatDescription.js +0 -35
  63. package/node_modules/express-jsdoc-swagger/transforms/utils/formatExamples.js +0 -25
  64. package/node_modules/express-jsdoc-swagger/transforms/utils/generator.js +0 -6
  65. package/node_modules/express-jsdoc-swagger/transforms/utils/httpMethods.js +0 -18
  66. package/node_modules/express-jsdoc-swagger/transforms/utils/mapDescription.js +0 -5
  67. package/node_modules/express-jsdoc-swagger/transforms/utils/refSchema.js +0 -48
  68. package/node_modules/express-jsdoc-swagger/transforms/utils/setProperty.js +0 -25
  69. package/node_modules/express-jsdoc-swagger/transforms/utils/tags.js +0 -16
  70. package/node_modules/express-jsdoc-swagger/transforms/utils/validateTypes.js +0 -11
  71. package/node_modules/serverless-http/LICENSE.txt +0 -33
  72. package/node_modules/serverless-http/README.md +0 -117
  73. package/node_modules/serverless-http/lib/finish.js +0 -42
  74. package/node_modules/serverless-http/lib/framework/get-framework.js +0 -79
  75. package/node_modules/serverless-http/lib/provider/aws/clean-up-event.js +0 -98
  76. package/node_modules/serverless-http/lib/provider/aws/create-request.js +0 -110
  77. package/node_modules/serverless-http/lib/provider/aws/format-response.js +0 -45
  78. package/node_modules/serverless-http/lib/provider/aws/index.js +0 -15
  79. package/node_modules/serverless-http/lib/provider/aws/is-binary.js +0 -42
  80. package/node_modules/serverless-http/lib/provider/aws/sanitize-headers.js +0 -21
  81. package/node_modules/serverless-http/lib/provider/azure/clean-up-request.js +0 -41
  82. package/node_modules/serverless-http/lib/provider/azure/create-request.js +0 -45
  83. package/node_modules/serverless-http/lib/provider/azure/format-response.js +0 -18
  84. package/node_modules/serverless-http/lib/provider/azure/index.js +0 -13
  85. package/node_modules/serverless-http/lib/provider/azure/is-binary.js +0 -42
  86. package/node_modules/serverless-http/lib/provider/azure/sanitize-headers.js +0 -23
  87. package/node_modules/serverless-http/lib/provider/azure/set-cookie.json +0 -1
  88. package/node_modules/serverless-http/lib/provider/get-provider.js +0 -17
  89. package/node_modules/serverless-http/lib/request.js +0 -38
  90. package/node_modules/serverless-http/lib/response.js +0 -135
  91. package/node_modules/serverless-http/package.json +0 -93
  92. package/node_modules/serverless-http/serverless-http.d.ts +0 -41
  93. package/node_modules/serverless-http/serverless-http.js +0 -23
  94. package/node_modules/swagger-ui-express/LICENSE +0 -22
  95. package/node_modules/swagger-ui-express/README.md +0 -360
  96. package/node_modules/swagger-ui-express/index.js +0 -311
  97. package/node_modules/swagger-ui-express/package.json +0 -58
@@ -1,360 +0,0 @@
1
- # Swagger UI Express
2
-
3
- | Statements | Branches | Functions | Lines |
4
- | --------------------------- | ----------------------- | ------------------------- | -------------------- |
5
- | ![Statements](https://img.shields.io/badge/Coverage-89.87%25-yellow.svg) | ![Branches](https://img.shields.io/badge/Coverage-78.57%25-red.svg) | ![Functions](https://img.shields.io/badge/Coverage-91.67%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-89.74%25-yellow.svg) |
6
-
7
- This module allows you to serve auto-generated [swagger-ui](https://swagger.io/tools/swagger-ui/) generated API docs from express, based on a `swagger.json` file. The result is living documentation for your API hosted from your API server via a route.
8
-
9
- Swagger version is pulled from npm module swagger-ui-dist. Please use a lock file or specify the version of swagger-ui-dist you want to ensure it is consistent across environments.
10
-
11
- You may be also interested in:
12
-
13
- * [swagger-jsdoc](https://github.com/Surnet/swagger-jsdoc): Allows you to markup routes
14
- with jsdoc comments. It then produces a full swagger yml config dynamically, which you can pass to this module to produce documentation. See below under the usage section for more info.
15
- * [swagger tools](https://github.com/swagger-api): Various tools, including swagger editor, swagger code gen etc.
16
-
17
- ## Usage
18
-
19
- Install using npm:
20
-
21
- ```bash
22
- $ npm install swagger-ui-express
23
- ```
24
-
25
- Express setup `app.js`
26
- ```javascript
27
- const express = require('express');
28
- const app = express();
29
- const swaggerUi = require('swagger-ui-express');
30
- const swaggerDocument = require('./swagger.json');
31
-
32
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
33
- ```
34
-
35
- or if you are using Express router
36
-
37
- ```javascript
38
- const router = require('express').Router();
39
- const swaggerUi = require('swagger-ui-express');
40
- const swaggerDocument = require('./swagger.json');
41
-
42
- router.use('/api-docs', swaggerUi.serve);
43
- router.get('/api-docs', swaggerUi.setup(swaggerDocument));
44
- ```
45
-
46
- Open http://`<app_host>`:`<app_port>`/api-docs in your browser to view the documentation.
47
-
48
- If you want to set up routing based on the swagger document checkout [swagger-express-router](https://www.npmjs.com/package/swagger-express-router)
49
-
50
- ### [swagger-jsdoc](https://www.npmjs.com/package/swagger-jsdoc)
51
-
52
- If you are using swagger-jsdoc simply pass the swaggerSpec into the setup function:
53
-
54
- ```javascript
55
- // Initialize swagger-jsdoc -> returns validated swagger spec in json format
56
- const swaggerSpec = swaggerJSDoc(options);
57
-
58
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
59
- ```
60
-
61
- ### Swagger Explorer
62
-
63
- By default the Swagger Explorer bar is hidden, to display it pass true as the 'explorer' property of the options to the setup function:
64
-
65
- ```javascript
66
- const express = require('express');
67
- const app = express();
68
- const swaggerUi = require('swagger-ui-express');
69
- const swaggerDocument = require('./swagger.json');
70
-
71
- var options = {
72
- explorer: true
73
- };
74
-
75
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
76
- ```
77
-
78
- ### Custom swagger options
79
-
80
- To pass custom options e.g. validatorUrl, to the SwaggerUi client pass an object as the 'swaggerOptions' property of the options to the setup function:
81
-
82
- ```javascript
83
- const express = require('express');
84
- const app = express();
85
- const swaggerUi = require('swagger-ui-express');
86
- const swaggerDocument = require('./swagger.json');
87
-
88
- var options = {
89
- swaggerOptions: {
90
- validatorUrl: null
91
- }
92
- };
93
-
94
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
95
- ```
96
-
97
- For all the available options, refer to [Swagger UI Configuration](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md)
98
-
99
- ### Custom CSS styles
100
-
101
- To customize the style of the swagger page, you can pass custom CSS as the 'customCss' property of the options to the setup function.
102
-
103
- E.g. to hide the swagger header:
104
-
105
- ```javascript
106
- const express = require('express');
107
- const app = express();
108
- const swaggerUi = require('swagger-ui-express');
109
- const swaggerDocument = require('./swagger.json');
110
-
111
- var options = {
112
- customCss: '.swagger-ui .topbar { display: none }'
113
- };
114
-
115
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
116
- ```
117
-
118
- ### Custom CSS styles from Url
119
-
120
- You can also pass the url to a custom css file, the value must be the public url of the file and can be relative or absolute to the swagger path.
121
-
122
- ```javascript
123
- const express = require('express');
124
- const app = express();
125
- const swaggerUi = require('swagger-ui-express');
126
- const swaggerDocument = require('./swagger.json');
127
-
128
- var options = {
129
- customCssUrl: '/custom.css'
130
- };
131
-
132
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
133
- ```
134
-
135
- You can also pass an array of css urls to load multiple css files.
136
-
137
- ```javascript
138
- const express = require('express');
139
- const app = express();
140
- const swaggerUi = require('swagger-ui-express');
141
- const swaggerDocument = require('./swagger.json');
142
-
143
- var options = {
144
- customCssUrl: [
145
- '/custom.css',
146
- 'https://example.com/other-custom.css'
147
- ]
148
- };
149
-
150
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
151
- ```
152
-
153
- ### Custom JS
154
-
155
- If you would like to have full control over your HTML you can provide your own javascript file, value accepts absolute or relative path. Value must be the public url of the js file.
156
-
157
- ```javascript
158
- const express = require('express');
159
- const app = express();
160
- const swaggerUi = require('swagger-ui-express');
161
- const swaggerDocument = require('./swagger.json');
162
-
163
- var options = {
164
- customJs: '/custom.js'
165
- };
166
-
167
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
168
- ```
169
-
170
- You can also pass an array of js urls to load multiple js files.
171
-
172
- ```javascript
173
- const express = require('express');
174
- const app = express();
175
- const swaggerUi = require('swagger-ui-express');
176
- const swaggerDocument = require('./swagger.json');
177
-
178
- var options = {
179
- customJs: [
180
- '/custom.js',
181
- 'https://example.com/other-custom.js'
182
- ]
183
- };
184
-
185
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
186
- ```
187
-
188
- It is also possible to add inline javascript, either as string or array of string.
189
-
190
- ```javascript
191
- const express = require('express');
192
- const app = express();
193
- const swaggerUi = require('swagger-ui-express');
194
- const swaggerDocument = require('./swagger.json');
195
-
196
- var options = {
197
- customJsStr: 'console.log("Hello World")'
198
- };
199
-
200
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
201
- ```
202
-
203
- ```javascript
204
- const express = require('express');
205
- const app = express();
206
- const swaggerUi = require('swagger-ui-express');
207
- const swaggerDocument = require('./swagger.json');
208
-
209
- var options = {
210
- customJsStr: [
211
- 'console.log("Hello World")',
212
- `
213
- var x = 1
214
- console.log(x)
215
- `
216
- ]
217
- };
218
-
219
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
220
- ```
221
-
222
- ### Load swagger from url
223
-
224
- To load your swagger from a url instead of injecting the document, pass `null` as the first parameter, and pass the relative or absolute URL as the 'url' property to 'swaggerOptions' in the setup function.
225
-
226
- ```javascript
227
- const express = require('express');
228
- const app = express();
229
- const swaggerUi = require('swagger-ui-express');
230
-
231
- var options = {
232
- swaggerOptions: {
233
- url: 'http://petstore.swagger.io/v2/swagger.json'
234
- }
235
- }
236
-
237
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(null, options));
238
- ```
239
-
240
- To load multiple swagger documents from urls as a dropdown in the explorer bar, pass an array of object with `name` and `url` to 'urls' property to 'swaggerOptions' in the setup function.
241
-
242
- ```javascript
243
- const express = require('express');
244
- const app = express();
245
- const swaggerUi = require('swagger-ui-express');
246
-
247
- var options = {
248
- explorer: true,
249
- swaggerOptions: {
250
- urls: [
251
- {
252
- url: 'http://petstore.swagger.io/v2/swagger.json',
253
- name: 'Spec1'
254
- },
255
- {
256
- url: 'http://petstore.swagger.io/v2/swagger.json',
257
- name: 'Spec2'
258
- }
259
- ]
260
- }
261
- }
262
-
263
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(null, options));
264
- ```
265
-
266
- Make sure 'explorer' option is set to 'true' in your setup options for the dropdown to be visible.
267
-
268
-
269
- ### Load swagger from yaml file
270
-
271
- To load your swagger specification yaml file you need to use a module able to convert yaml to json; for instance `yaml`.
272
-
273
- npm install yaml
274
-
275
- ```javascript
276
- const express = require('express');
277
- const app = express();
278
- const swaggerUi = require('swagger-ui-express');
279
- const fs = require("fs")
280
- const YAML = require('yaml')
281
-
282
- const file = fs.readFileSync('./swagger.yaml', 'utf8')
283
- const swaggerDocument = YAML.parse(file)
284
-
285
- app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
286
- ```
287
-
288
-
289
- ### Modify swagger file on the fly before load
290
-
291
- To dynamically set the host, or any other content, in the swagger file based on the incoming request object you may pass the json via the req object; to achieve this just do not pass the the swagger json to the setup function and it will look for `swaggerDoc` in the `req` object.
292
-
293
- ```javascript
294
- const express = require('express');
295
- const app = express();
296
- const swaggerUi = require('swagger-ui-express');
297
- const swaggerDocument = require('./swagger.json');
298
-
299
- var options = {}
300
-
301
- app.use('/api-docs', function(req, res, next){
302
- swaggerDocument.host = req.get('host');
303
- req.swaggerDoc = swaggerDocument;
304
- next();
305
- }, swaggerUi.serveFiles(swaggerDocument, options), swaggerUi.setup());
306
- ```
307
-
308
- ### Two swagger documents
309
-
310
- To run 2 swagger ui instances with different swagger documents, use the serveFiles function instead of the serve function. The serveFiles function has the same signature as the setup function.
311
-
312
- ```javascript
313
- const express = require('express');
314
- const app = express();
315
- const swaggerUi = require('swagger-ui-express');
316
- const swaggerDocumentOne = require('./swagger-one.json');
317
- const swaggerDocumentTwo = require('./swagger-two.json');
318
-
319
- var options = {}
320
-
321
- app.use('/api-docs-one', swaggerUi.serveFiles(swaggerDocumentOne, options), swaggerUi.setup(swaggerDocumentOne));
322
-
323
- app.use('/api-docs-two', swaggerUi.serveFiles(swaggerDocumentTwo, options), swaggerUi.setup(swaggerDocumentTwo));
324
-
325
- app.use('/api-docs-dynamic', function(req, res, next){
326
- req.swaggerDoc = swaggerDocument;
327
- next();
328
- }, swaggerUi.serveFiles(), swaggerUi.setup());
329
- ```
330
-
331
- ### Link to Swagger document
332
-
333
- To render a link to the swagger document for downloading within the swagger ui - then serve the swagger doc as an endpoint and use the url option to point to it:
334
-
335
- ```javascript
336
- const express = require('express');
337
- const app = express();
338
- const swaggerUi = require('swagger-ui-express');
339
- const swaggerDocument = require('./swagger.json');
340
-
341
- var options = {
342
- swaggerOptions: {
343
- url: "/api-docs/swagger.json",
344
- },
345
- }
346
- app.get("/api-docs/swagger.json", (req, res) => res.json(swaggerDocument));
347
- app.use('/api-docs', swaggerUi.serveFiles(null, options), swaggerUi.setup(null, options));
348
- ```
349
-
350
-
351
- ## Requirements
352
-
353
- * Node v0.10.32 or above
354
- * Express 4 or above
355
-
356
- ## Testing
357
-
358
- * Install phantom
359
- * `npm install`
360
- * `npm test`
@@ -1,311 +0,0 @@
1
- 'use strict'
2
-
3
- var express = require('express')
4
- var getAbsoluteSwaggerFsPath = require('swagger-ui-dist/absolute-path')
5
- var favIconHtml = '<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />' +
6
- '<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />'
7
- var swaggerInit = ''
8
-
9
- function trimQuery(q) {
10
- return q && q.split('?')[0]
11
- }
12
-
13
- var htmlTplString = `
14
- <!-- HTML for static distribution bundle build -->
15
- <!DOCTYPE html>
16
- <html lang="en">
17
- <head>
18
- <meta charset="UTF-8">
19
- <% robotsMetaString %>
20
- <title><% title %></title>
21
- <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
22
- <% favIconString %>
23
- <style>
24
- html
25
- {
26
- box-sizing: border-box;
27
- overflow: -moz-scrollbars-vertical;
28
- overflow-y: scroll;
29
- }
30
- *,
31
- *:before,
32
- *:after
33
- {
34
- box-sizing: inherit;
35
- }
36
-
37
- body {
38
- margin:0;
39
- background: #fafafa;
40
- }
41
- </style>
42
- </head>
43
-
44
- <body>
45
-
46
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
47
- <defs>
48
- <symbol viewBox="0 0 20 20" id="unlocked">
49
- <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
50
- </symbol>
51
-
52
- <symbol viewBox="0 0 20 20" id="locked">
53
- <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
54
- </symbol>
55
-
56
- <symbol viewBox="0 0 20 20" id="close">
57
- <path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
58
- </symbol>
59
-
60
- <symbol viewBox="0 0 20 20" id="large-arrow">
61
- <path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
62
- </symbol>
63
-
64
- <symbol viewBox="0 0 20 20" id="large-arrow-down">
65
- <path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
66
- </symbol>
67
-
68
-
69
- <symbol viewBox="0 0 24 24" id="jump-to">
70
- <path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
71
- </symbol>
72
-
73
- <symbol viewBox="0 0 24 24" id="expand">
74
- <path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
75
- </symbol>
76
-
77
- </defs>
78
- </svg>
79
-
80
- <div id="swagger-ui"></div>
81
-
82
- <script src="./swagger-ui-bundle.js"> </script>
83
- <script src="./swagger-ui-standalone-preset.js"> </script>
84
- <script src="./swagger-ui-init.js"> </script>
85
- <% customJs %>
86
- <% customJsStr %>
87
- <% customCssUrl %>
88
- <style>
89
- <% customCss %>
90
- </style>
91
- </body>
92
-
93
- </html>
94
- `
95
-
96
- var jsTplString = `
97
- window.onload = function() {
98
- // Build a system
99
- var url = window.location.search.match(/url=([^&]+)/);
100
- if (url && url.length > 1) {
101
- url = decodeURIComponent(url[1]);
102
- } else {
103
- url = window.location.origin;
104
- }
105
- <% swaggerOptions %>
106
- url = options.swaggerUrl || url
107
- var urls = options.swaggerUrls
108
- var customOptions = options.customOptions
109
- var spec1 = options.swaggerDoc
110
- var swaggerOptions = {
111
- spec: spec1,
112
- url: url,
113
- urls: urls,
114
- dom_id: '#swagger-ui',
115
- deepLinking: true,
116
- presets: [
117
- SwaggerUIBundle.presets.apis,
118
- SwaggerUIStandalonePreset
119
- ],
120
- plugins: [
121
- SwaggerUIBundle.plugins.DownloadUrl
122
- ],
123
- layout: "StandaloneLayout"
124
- }
125
- for (var attrname in customOptions) {
126
- swaggerOptions[attrname] = customOptions[attrname];
127
- }
128
- var ui = SwaggerUIBundle(swaggerOptions)
129
-
130
- if (customOptions.oauth) {
131
- ui.initOAuth(customOptions.oauth)
132
- }
133
-
134
- if (customOptions.preauthorizeApiKey) {
135
- const key = customOptions.preauthorizeApiKey.authDefinitionKey;
136
- const value = customOptions.preauthorizeApiKey.apiKeyValue;
137
- if (!!key && !!value) {
138
- const pid = setInterval(() => {
139
- const authorized = ui.preauthorizeApiKey(key, value);
140
- if(!!authorized) clearInterval(pid);
141
- }, 500)
142
-
143
- }
144
- }
145
-
146
- if (customOptions.authAction) {
147
- ui.authActions.authorize(customOptions.authAction)
148
- }
149
-
150
- window.ui = ui
151
- }
152
- `
153
-
154
- function toExternalScriptTag(url) {
155
- return `<script src='${url}'></script>`
156
- }
157
-
158
- function toInlineScriptTag(jsCode) {
159
- return `<script>${jsCode}</script>`
160
- }
161
-
162
- function toExternalStylesheetTag(url) {
163
- return `<link href='${url}' rel='stylesheet'>`
164
- }
165
-
166
- function toTags(customCode, toScript) {
167
- if (typeof customCode === 'string') {
168
- return toScript(customCode)
169
- } else if (Array.isArray(customCode)) {
170
- return customCode.map(toScript).join('\n')
171
- } else {
172
- return ''
173
- }
174
- }
175
-
176
- var generateHTML = function (swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, _htmlTplString, _jsTplString) {
177
- var isExplorer
178
- var customJs
179
- var customJsStr
180
- var swaggerUrls
181
- var customCssUrl
182
- var customRobots
183
- if (opts && typeof opts === 'object') {
184
- options = opts.swaggerOptions
185
- customCss = opts.customCss
186
- customJs = opts.customJs
187
- customJsStr = opts.customJsStr
188
- customfavIcon = opts.customfavIcon
189
- customRobots = opts.customRobots
190
- swaggerUrl = opts.swaggerUrl
191
- swaggerUrls = opts.swaggerUrls
192
- isExplorer = opts.explorer || !!swaggerUrls
193
- customSiteTitle = opts.customSiteTitle
194
- customCssUrl = opts.customCssUrl
195
- } else {
196
- //support legacy params based function
197
- isExplorer = opts
198
- }
199
- options = options || {}
200
- var explorerString = isExplorer ? '' : '.swagger-ui .topbar .download-url-wrapper { display: none }'
201
- customCss = explorerString + ' ' + customCss || explorerString
202
- customfavIcon = customfavIcon || false
203
- customSiteTitle = customSiteTitle || 'Swagger UI'
204
- _htmlTplString = _htmlTplString || htmlTplString
205
- _jsTplString = _jsTplString || jsTplString
206
-
207
- var robotsMetaString = customRobots ? '<meta name="robots" content="' + customRobots + '" />' : ''
208
- var favIconString = customfavIcon ? '<link rel="icon" href="' + customfavIcon + '" />' : favIconHtml
209
- var htmlWithCustomCss = _htmlTplString.toString().replace('<% customCss %>', customCss)
210
- var htmlWithCustomRobots = htmlWithCustomCss.replace('<% robotsMetaString %>', robotsMetaString)
211
- var htmlWithFavIcon = htmlWithCustomRobots.replace('<% favIconString %>', favIconString)
212
- var htmlWithCustomJsUrl = htmlWithFavIcon.replace('<% customJs %>', toTags(customJs, toExternalScriptTag))
213
- var htmlWithCustomJs = htmlWithCustomJsUrl.replace('<% customJsStr %>', toTags(customJsStr, toInlineScriptTag))
214
- var htmlWithCustomCssUrl = htmlWithCustomJs.replace('<% customCssUrl %>', toTags(customCssUrl, toExternalStylesheetTag))
215
-
216
- var initOptions = {
217
- swaggerDoc: swaggerDoc || undefined,
218
- customOptions: options,
219
- swaggerUrl: swaggerUrl || undefined,
220
- swaggerUrls: swaggerUrls || undefined
221
- }
222
-
223
- swaggerInit = _jsTplString.toString().replace('<% swaggerOptions %>', stringify(initOptions))
224
- return htmlWithCustomCssUrl.replace('<% title %>', customSiteTitle)
225
- }
226
-
227
- var setup = function (swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
228
- var html = generateHTML(swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, htmlTplString, jsTplString)
229
- return function (req, res) {
230
- if (req.swaggerDoc) {
231
- var reqHtml = generateHTML(req.swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, htmlTplString, jsTplString)
232
- res.send(reqHtml)
233
- } else {
234
- res.send(html)
235
- }
236
- }
237
- }
238
-
239
- function swaggerInitFn(req, res, next) {
240
- if (trimQuery(req.url).endsWith('/package.json')) {
241
- res.sendStatus(404)
242
- } else if (trimQuery(req.url).endsWith('/swagger-ui-init.js')) {
243
- res.set('Content-Type', 'application/javascript')
244
- res.send(swaggerInit)
245
- } else {
246
- next()
247
- }
248
- }
249
-
250
- var swaggerInitFunction = function (swaggerDoc, opts) {
251
- var swaggerInitFile = jsTplString.toString().replace('<% swaggerOptions %>', stringify(opts))
252
- return function (req, res, next) {
253
- if (trimQuery(req.url).endsWith('/package.json')) {
254
- res.sendStatus(404)
255
- } else if (trimQuery(req.url).endsWith('/swagger-ui-init.js')) {
256
- if (req.swaggerDoc) {
257
- opts.swaggerDoc = req.swaggerDoc
258
- swaggerInitFile = jsTplString.toString().replace('<% swaggerOptions %>', stringify(opts))
259
- }
260
- res.set('Content-Type', 'application/javascript')
261
- res.send(swaggerInitFile)
262
- } else {
263
- next()
264
- }
265
- }
266
- }
267
-
268
- var swaggerAssetMiddleware = options => {
269
- var opts = options || {}
270
- opts.index = false
271
- return express.static(getAbsoluteSwaggerFsPath(), opts)
272
- }
273
-
274
- var serveFiles = function (swaggerDoc, opts) {
275
- opts = opts || {}
276
- var initOptions = {
277
- swaggerDoc: swaggerDoc || undefined,
278
- customOptions: opts.swaggerOptions || {},
279
- swaggerUrl: opts.swaggerUrl || {},
280
- swaggerUrls: opts.swaggerUrls || undefined
281
- }
282
- var swaggerInitWithOpts = swaggerInitFunction(swaggerDoc, initOptions)
283
- return [swaggerInitWithOpts, swaggerAssetMiddleware()]
284
- }
285
-
286
- var serve = [swaggerInitFn, swaggerAssetMiddleware()]
287
- var serveWithOptions = options => [swaggerInitFn, swaggerAssetMiddleware(options)]
288
-
289
- var stringify = function (obj, prop) {
290
- var placeholder = '____FUNCTIONPLACEHOLDER____'
291
- var fns = []
292
- var json = JSON.stringify(obj, function (key, value) {
293
- if (typeof value === 'function') {
294
- fns.push(value)
295
- return placeholder
296
- }
297
- return value
298
- }, 2)
299
- json = json.replace(new RegExp('"' + placeholder + '"', 'g'), function (_) {
300
- return fns.shift()
301
- })
302
- return 'var options = ' + json + ';'
303
- }
304
-
305
- module.exports = {
306
- setup: setup,
307
- serve: serve,
308
- serveWithOptions: serveWithOptions,
309
- generateHTML: generateHTML,
310
- serveFiles: serveFiles
311
- }