@scalar/mock-server 0.1.61 → 0.1.63

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,494 @@
1
+ # @scalar/mock-server
2
+
3
+ ## 0.1.63
4
+
5
+ ### Patch Changes
6
+
7
+ - 670156e: chore: bump packages
8
+
9
+ ## 0.1.62
10
+
11
+ ### Patch Changes
12
+
13
+ - 09b38c4: fix: openapi.json returns yaml string
14
+ - ea0eed3: fix: types not available
15
+
16
+ ## 0.1.61
17
+
18
+ ### Patch Changes
19
+
20
+ - 5a2f0c9: fix: release workflow fails
21
+
22
+ ## 0.1.60
23
+
24
+ ### Patch Changes
25
+
26
+ - 17841a8: fix: wrong repository URL in the package.json
27
+
28
+ ## 0.1.59
29
+
30
+ ### Patch Changes
31
+
32
+ - 45dc04b: fix: can’t release packages
33
+ - Updated dependencies [9ba838b]
34
+ - Updated dependencies [45dc04b]
35
+ - @scalar/api-reference@1.22.24
36
+ - @scalar/oas-utils@0.1.10
37
+ - @scalar/galaxy@0.1.2
38
+
39
+ ## 0.1.58
40
+
41
+ ### Patch Changes
42
+
43
+ - 05e2e27: chore: add provenance statement
44
+ - Updated dependencies [05e2e27]
45
+ - @scalar/api-reference@1.22.23
46
+ - @scalar/galaxy@0.1.1
47
+ - @scalar/oas-utils@0.1.9
48
+
49
+ ## 0.1.57
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [f1bf5bc]
54
+ - Updated dependencies [085a0c2]
55
+ - Updated dependencies [fa10d45]
56
+ - @scalar/api-reference@1.22.22
57
+ - @scalar/oas-utils@0.1.8
58
+
59
+ ## 0.1.56
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [07211ad]
64
+ - Updated dependencies [801ad65]
65
+ - Updated dependencies [d4fa19b]
66
+ - Updated dependencies [b234d1d]
67
+ - @scalar/api-reference@1.22.21
68
+ - @scalar/oas-utils@0.1.7
69
+
70
+ ## 0.1.55
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [a8c3045]
75
+ - Updated dependencies [1324378]
76
+ - Updated dependencies [9201802]
77
+ - @scalar/api-reference@1.22.20
78
+
79
+ ## 0.1.54
80
+
81
+ ### Patch Changes
82
+
83
+ - @scalar/api-reference@1.22.19
84
+
85
+ ## 0.1.53
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [45dccb0]
90
+ - Updated dependencies [abff1f4]
91
+ - @scalar/api-reference@1.22.18
92
+
93
+ ## 0.1.52
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [53ba90d]
98
+ - Updated dependencies [b42479c]
99
+ - Updated dependencies [4c38ac1]
100
+ - @scalar/galaxy@0.1.0
101
+ - @scalar/api-reference@1.22.17
102
+
103
+ ## 0.1.51
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [7e1d318]
108
+ - @scalar/api-reference@1.22.16
109
+
110
+ ## 0.1.50
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [fc2c90f]
115
+ - @scalar/api-reference@1.22.15
116
+
117
+ ## 0.1.49
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [b8e3f09]
122
+ - @scalar/api-reference@1.22.14
123
+
124
+ ## 0.1.48
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies [c05c90e]
129
+ - Updated dependencies [2700c5c]
130
+ - @scalar/api-reference@1.22.13
131
+
132
+ ## 0.1.47
133
+
134
+ ### Patch Changes
135
+
136
+ - Updated dependencies [55398db]
137
+ - @scalar/api-reference@1.22.12
138
+
139
+ ## 0.1.46
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [b24b455]
144
+ - Updated dependencies [43e1217]
145
+ - @scalar/api-reference@1.22.11
146
+
147
+ ## 0.1.45
148
+
149
+ ### Patch Changes
150
+
151
+ - @scalar/api-reference@1.22.10
152
+
153
+ ## 0.1.44
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies [6f68b40]
158
+ - Updated dependencies [4d31b19]
159
+ - @scalar/api-reference@1.22.9
160
+
161
+ ## 0.1.43
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies [24662c3]
166
+ - @scalar/api-reference@1.22.8
167
+
168
+ ## 0.1.42
169
+
170
+ ### Patch Changes
171
+
172
+ - Updated dependencies [c408cf5]
173
+ - @scalar/api-reference@1.22.7
174
+
175
+ ## 0.1.41
176
+
177
+ ### Patch Changes
178
+
179
+ - Updated dependencies [cf12a95]
180
+ - Updated dependencies [7b37c63]
181
+ - @scalar/api-reference@1.22.6
182
+
183
+ ## 0.1.40
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies [d03ab0f]
188
+ - @scalar/api-reference@1.22.5
189
+
190
+ ## 0.1.39
191
+
192
+ ### Patch Changes
193
+
194
+ - Updated dependencies [adc0693]
195
+ - @scalar/api-reference@1.22.4
196
+
197
+ ## 0.1.38
198
+
199
+ ### Patch Changes
200
+
201
+ - @scalar/api-reference@1.22.3
202
+
203
+ ## 0.1.37
204
+
205
+ ### Patch Changes
206
+
207
+ - @scalar/api-reference@1.22.2
208
+
209
+ ## 0.1.36
210
+
211
+ ### Patch Changes
212
+
213
+ - Updated dependencies [8dc1640]
214
+ - @scalar/api-reference@1.22.1
215
+
216
+ ## 0.1.35
217
+
218
+ ### Patch Changes
219
+
220
+ - 22f2858: chore: ran syncpack to update packages
221
+ - Updated dependencies [22f2858]
222
+ - Updated dependencies [ced76e5]
223
+ - Updated dependencies [0e64a36]
224
+ - Updated dependencies [3afec45]
225
+ - @scalar/api-reference@1.22.0
226
+ - @scalar/oas-utils@0.1.6
227
+
228
+ ## 0.1.34
229
+
230
+ ### Patch Changes
231
+
232
+ - Updated dependencies [851017a]
233
+ - @scalar/api-reference@1.21.2
234
+
235
+ ## 0.1.33
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies [b4abb34]
240
+ - @scalar/api-reference@1.21.1
241
+
242
+ ## 0.1.32
243
+
244
+ ### Patch Changes
245
+
246
+ - Updated dependencies [51d4997]
247
+ - @scalar/api-reference@1.20.32
248
+
249
+ ## 0.1.31
250
+
251
+ ### Patch Changes
252
+
253
+ - Updated dependencies [b903a2f]
254
+ - @scalar/api-reference@1.20.31
255
+
256
+ ## 0.1.30
257
+
258
+ ### Patch Changes
259
+
260
+ - Updated dependencies [deabe4c]
261
+ - Updated dependencies [3ba9774]
262
+ - Updated dependencies [a14fc32]
263
+ - Updated dependencies [3d4d83e]
264
+ - @scalar/api-reference@1.20.30
265
+ - @scalar/oas-utils@0.1.5
266
+
267
+ ## 0.1.29
268
+
269
+ ### Patch Changes
270
+
271
+ - Updated dependencies [24b3c2a]
272
+ - @scalar/oas-utils@0.1.4
273
+ - @scalar/api-reference@1.20.29
274
+
275
+ ## 0.1.28
276
+
277
+ ### Patch Changes
278
+
279
+ - Updated dependencies [622f31b]
280
+ - Updated dependencies [f2c2ce8]
281
+ - @scalar/api-reference@1.20.28
282
+
283
+ ## 0.1.27
284
+
285
+ ### Patch Changes
286
+
287
+ - Updated dependencies [605f522]
288
+ - @scalar/api-reference@1.20.27
289
+
290
+ ## 0.1.26
291
+
292
+ ### Patch Changes
293
+
294
+ - Updated dependencies [050410a]
295
+ - @scalar/api-reference@1.20.26
296
+
297
+ ## 0.1.25
298
+
299
+ ### Patch Changes
300
+
301
+ - Updated dependencies [1504d3b]
302
+ - @scalar/api-reference@1.20.25
303
+
304
+ ## 0.1.24
305
+
306
+ ### Patch Changes
307
+
308
+ - Updated dependencies [ab58747]
309
+ - @scalar/api-reference@1.20.24
310
+
311
+ ## 0.1.23
312
+
313
+ ### Patch Changes
314
+
315
+ - @scalar/api-reference@1.20.23
316
+
317
+ ## 0.1.22
318
+
319
+ ### Patch Changes
320
+
321
+ - Updated dependencies [4089634]
322
+ - @scalar/api-reference@1.20.22
323
+
324
+ ## 0.1.21
325
+
326
+ ### Patch Changes
327
+
328
+ - @scalar/api-reference@1.20.21
329
+
330
+ ## 0.1.20
331
+
332
+ ### Patch Changes
333
+
334
+ - Updated dependencies [c14568f]
335
+ - @scalar/oas-utils@0.1.3
336
+ - @scalar/api-reference@1.20.20
337
+
338
+ ## 0.1.19
339
+
340
+ ### Patch Changes
341
+
342
+ - Updated dependencies [c99f6ff]
343
+ - @scalar/api-reference@1.20.18
344
+
345
+ ## 0.1.18
346
+
347
+ ### Patch Changes
348
+
349
+ - Updated dependencies [5b4c8a5]
350
+ - @scalar/api-reference@1.20.17
351
+
352
+ ## 0.1.17
353
+
354
+ ### Patch Changes
355
+
356
+ - Updated dependencies [5232eab]
357
+ - @scalar/api-reference@1.20.16
358
+
359
+ ## 0.1.16
360
+
361
+ ### Patch Changes
362
+
363
+ - Updated dependencies [8f03345]
364
+ - @scalar/api-reference@1.20.15
365
+
366
+ ## 0.1.15
367
+
368
+ ### Patch Changes
369
+
370
+ - Updated dependencies [78f2ab3]
371
+ - @scalar/api-reference@1.20.14
372
+
373
+ ## 0.1.14
374
+
375
+ ### Patch Changes
376
+
377
+ - Updated dependencies [8b0691b]
378
+ - @scalar/api-reference@1.20.13
379
+ - @scalar/oas-utils@0.1.2
380
+
381
+ ## 0.1.13
382
+
383
+ ### Patch Changes
384
+
385
+ - Updated dependencies [999dfc9]
386
+ - @scalar/api-reference@1.20.12
387
+
388
+ ## 0.1.12
389
+
390
+ ### Patch Changes
391
+
392
+ - Updated dependencies [d70bda7]
393
+ - @scalar/api-reference@1.20.11
394
+
395
+ ## 0.1.11
396
+
397
+ ### Patch Changes
398
+
399
+ - Updated dependencies [ae193a8]
400
+ - Updated dependencies [bec8e52]
401
+ - @scalar/api-reference@1.20.10
402
+
403
+ ## 0.1.10
404
+
405
+ ### Patch Changes
406
+
407
+ - Updated dependencies [5260d07]
408
+ - Updated dependencies [f861efa]
409
+ - @scalar/api-reference@1.20.9
410
+
411
+ ## 0.1.9
412
+
413
+ ### Patch Changes
414
+
415
+ - @scalar/api-reference@1.20.8
416
+
417
+ ## 0.1.8
418
+
419
+ ### Patch Changes
420
+
421
+ - Updated dependencies [1e658b0]
422
+ - Updated dependencies [06c57ca]
423
+ - @scalar/api-reference@1.20.7
424
+
425
+ ## 0.1.7
426
+
427
+ ### Patch Changes
428
+
429
+ - @scalar/api-reference@1.20.6
430
+
431
+ ## 0.1.6
432
+
433
+ ### Patch Changes
434
+
435
+ - Updated dependencies [0c5e22c]
436
+ - @scalar/api-reference@1.20.5
437
+
438
+ ## 0.1.5
439
+
440
+ ### Patch Changes
441
+
442
+ - @scalar/api-reference@1.20.4
443
+
444
+ ## 0.1.4
445
+
446
+ ### Patch Changes
447
+
448
+ - Updated dependencies [61a97e2]
449
+ - @scalar/api-reference@1.20.3
450
+
451
+ ## 0.1.3
452
+
453
+ ### Patch Changes
454
+
455
+ - Updated dependencies [9fe930c]
456
+ - @scalar/api-reference@1.20.2
457
+
458
+ ## 0.1.2
459
+
460
+ ### Patch Changes
461
+
462
+ - Updated dependencies [4b5a136]
463
+ - Updated dependencies [1fb2eac]
464
+ - Updated dependencies [01476a9]
465
+ - Updated dependencies [083e0a1]
466
+ - @scalar/api-reference@1.20.1
467
+
468
+ ## 0.1.1
469
+
470
+ ### Patch Changes
471
+
472
+ - 31aae5e: chore: moved shared types and methods into oas-utils
473
+ - Updated dependencies [6dc67c1]
474
+ - Updated dependencies [c4500f6]
475
+ - Updated dependencies [41f0d86]
476
+ - Updated dependencies [31aae5e]
477
+ - @scalar/api-reference@1.20.0
478
+ - @scalar/oas-utils@0.1.1
479
+
480
+ ## 0.1.0
481
+
482
+ ### Minor Changes
483
+
484
+ - a866e91: refactor: switch to @scalar/openapi-parser
485
+
486
+ ### Patch Changes
487
+
488
+ - 0399390: chore: update dependencies
489
+
490
+ ## 0.0.2
491
+
492
+ ### Patch Changes
493
+
494
+ - 96b85ef: feat: new @scalar/mock-server package
package/dist/index.cjs ADDED
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var oasUtils = require('@scalar/oas-utils');
4
+ var openapiParser = require('@scalar/openapi-parser');
5
+ var hono = require('hono');
6
+
7
+ function normalize(openapi) {
8
+ if (typeof openapi === "string") {
9
+ openapi = JSON.parse(openapi);
10
+ }
11
+ return openapi;
12
+ }
13
+
14
+ function routeFromPath(path) {
15
+ return path.replace(/{/g, ":").replace(/}/g, "");
16
+ }
17
+
18
+ async function createMockServer(options) {
19
+ const app = new hono.Hono();
20
+ const result = await openapiParser.openapi().load(options?.specification ?? {}).resolve();
21
+ app.get("/openapi.json", (c) => {
22
+ if (!options?.specification) {
23
+ return c.text("Not found", 404);
24
+ }
25
+ return c.json(openapiParser.openapi().load(options.specification).get());
26
+ });
27
+ app.get("/openapi.yaml", (c) => {
28
+ if (!options?.specification) {
29
+ return c.text("Not found", 404);
30
+ }
31
+ return c.text(openapiParser.openapi().load(options.specification).toYaml());
32
+ });
33
+ Object.keys(result.schema?.paths ?? {}).forEach((path) => {
34
+ Object.keys(result.schema?.paths?.[path] ?? {}).forEach((method) => {
35
+ const route = routeFromPath(path);
36
+ app[method](route, (c) => {
37
+ if (options?.onRequest) {
38
+ options.onRequest({
39
+ context: c,
40
+ // @ts-expect-error Needs a proper type
41
+ operation: result.schema.paths[path][method]
42
+ });
43
+ }
44
+ const operation = result.schema?.paths?.[path]?.[method];
45
+ const jsonResponseConfiguration = operation.responses?.["200"]?.content["application/json"];
46
+ const response = jsonResponseConfiguration?.example ? jsonResponseConfiguration.example : jsonResponseConfiguration?.schema ? oasUtils.getExampleFromSchema(jsonResponseConfiguration.schema, {
47
+ emptyString: "\u2026"
48
+ }) : null;
49
+ return c.json(response);
50
+ });
51
+ });
52
+ });
53
+ return app;
54
+ }
55
+
56
+ exports.createMockServer = createMockServer;
57
+ exports.normalize = normalize;
58
+ exports.routeFromPath = routeFromPath;
59
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils/normalize.ts","../src/utils/routeFromPath.ts","../src/createMockServer.ts"],"sourcesContent":["/**\n * Normalize OpenAPI JSON string, YAML string … to object\n */\nexport function normalize(openapi: string | Record<string, any>) {\n if (typeof openapi === 'string') {\n openapi = JSON.parse(openapi)\n }\n\n return openapi\n}\n","/**\n * Convert path to route\n * Example: /posts/{id} -> /posts/:id\n */\nexport function routeFromPath(path: string) {\n return path.replace(/{/g, ':').replace(/}/g, '')\n}\n","import { type Operation, getExampleFromSchema } from '@scalar/oas-utils'\nimport { openapi } from '@scalar/openapi-parser'\nimport { type Context, Hono } from 'hono'\n\nimport { routeFromPath } from './utils'\n\n/**\n * Create a mock server instance\n */\nexport async function createMockServer(options?: {\n specification: string | Record<string, any>\n onRequest?: (data: { context: Context; operation: Operation }) => void\n}) {\n const app = new Hono()\n\n // Resolve references\n const result = await openapi()\n .load(options?.specification ?? {})\n .resolve()\n\n // OpenAPI JSON file\n app.get('/openapi.json', (c) => {\n if (!options?.specification) {\n return c.text('Not found', 404)\n }\n\n return c.json(openapi().load(options.specification).get())\n })\n\n // OpenAPI YAML file\n app.get('/openapi.yaml', (c) => {\n if (!options?.specification) {\n return c.text('Not found', 404)\n }\n\n return c.text(openapi().load(options.specification).toYaml())\n })\n\n // Paths\n Object.keys(result.schema?.paths ?? {}).forEach((path) => {\n // Request methods\n Object.keys(result.schema?.paths?.[path] ?? {}).forEach((method) => {\n const route = routeFromPath(path)\n\n // Route\n // @ts-expect-error Needs a proper type\n app[method](route, (c: Context) => {\n // Call onRequest callback\n if (options?.onRequest) {\n options.onRequest({\n context: c,\n // @ts-expect-error Needs a proper type\n operation: result.schema.paths[path][method],\n })\n }\n\n // Response\n // @ts-expect-error Needs a proper type\n const operation = result.schema?.paths?.[path]?.[method]\n\n const jsonResponseConfiguration =\n operation.responses?.['200']?.content['application/json']\n\n const response = jsonResponseConfiguration?.example\n ? jsonResponseConfiguration.example\n : jsonResponseConfiguration?.schema\n ? getExampleFromSchema(jsonResponseConfiguration.schema, {\n emptyString: '…',\n })\n : null\n\n return c.json(response)\n })\n })\n })\n\n return app\n}\n"],"names":["Hono","openapi","getExamp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types';
2
+ import * as hono from 'hono';
3
+ import { Context, Hono } from 'hono';
4
+ import { Operation } from '@scalar/oas-utils';
5
+
6
+ /**
7
+ * Create a mock server instance
8
+ */
9
+ declare function createMockServer(options?: {
10
+ specification: string | Record<string, any>;
11
+ onRequest?: (data: {
12
+ context: Context;
13
+ operation: Operation;
14
+ }) => void;
15
+ }): Promise<Hono<hono.Env, hono_types.BlankSchema, "/">>;
16
+
17
+ /**
18
+ * Normalize OpenAPI JSON string, YAML string … to object
19
+ */
20
+ declare function normalize(openapi: string | Record<string, any>): string | Record<string, any>;
21
+
22
+ /**
23
+ * Convert path to route
24
+ * Example: /posts/{id} -> /posts/:id
25
+ */
26
+ declare function routeFromPath(path: string): string;
27
+
28
+ export { createMockServer, normalize, routeFromPath };