@schmock/cli 1.8.0 → 1.9.0
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/dist/cli.js +1 -1
- package/dist/index.js +24 -8
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -56,7 +56,7 @@ function handleAdminRequest(method, path, mock, res, headers) {
|
|
|
56
56
|
res.end(JSON.stringify({ error: "Unknown admin endpoint", code: "NOT_FOUND" }));
|
|
57
57
|
}
|
|
58
58
|
export async function createCliServer(options) {
|
|
59
|
-
const mock = schmock({ debug: options.debug });
|
|
59
|
+
const mock = schmock({ debug: options.debug, state: {} });
|
|
60
60
|
const openapiOptions = {
|
|
61
61
|
spec: options.spec,
|
|
62
62
|
fakerSeed: options.fakerSeed,
|
package/dist/index.js
CHANGED
|
@@ -23849,11 +23849,11 @@ function schmock(config) {
|
|
|
23849
23849
|
reset: instance.reset.bind(instance),
|
|
23850
23850
|
resetHistory: instance.resetHistory.bind(instance),
|
|
23851
23851
|
resetState: instance.resetState.bind(instance),
|
|
23852
|
-
on
|
|
23852
|
+
on(event, listener) {
|
|
23853
23853
|
instance.on(event, listener);
|
|
23854
23854
|
return callableInstance;
|
|
23855
23855
|
},
|
|
23856
|
-
off
|
|
23856
|
+
off(event, listener) {
|
|
23857
23857
|
instance.off(event, listener);
|
|
23858
23858
|
return callableInstance;
|
|
23859
23859
|
},
|
|
@@ -33421,6 +33421,22 @@ function loadSeed(config, resources) {
|
|
|
33421
33421
|
}
|
|
33422
33422
|
|
|
33423
33423
|
// ../openapi/src/plugin.ts
|
|
33424
|
+
function getRouteCallbacks(route) {
|
|
33425
|
+
const value = route["openapi:callbacks"];
|
|
33426
|
+
return Array.isArray(value) ? value : undefined;
|
|
33427
|
+
}
|
|
33428
|
+
function getRouteSecurity(route) {
|
|
33429
|
+
const value = route["openapi:security"];
|
|
33430
|
+
return Array.isArray(value) ? value : undefined;
|
|
33431
|
+
}
|
|
33432
|
+
function getRouteResponses(route) {
|
|
33433
|
+
const value = route["openapi:responses"];
|
|
33434
|
+
return value instanceof Map ? value : undefined;
|
|
33435
|
+
}
|
|
33436
|
+
function getRouteRequestBody(route) {
|
|
33437
|
+
const value = route["openapi:requestBody"];
|
|
33438
|
+
return isRecord(value) ? value : undefined;
|
|
33439
|
+
}
|
|
33424
33440
|
async function openapi(options) {
|
|
33425
33441
|
const spec = await parseSpec(options.spec);
|
|
33426
33442
|
const { resources, nonCrudPaths } = detectCrudResources(spec.paths);
|
|
@@ -33476,7 +33492,7 @@ async function openapi(options) {
|
|
|
33476
33492
|
}
|
|
33477
33493
|
}
|
|
33478
33494
|
const result = processPreferHeader(context, response, options.fakerSeed);
|
|
33479
|
-
const callbacks = context.route
|
|
33495
|
+
const callbacks = getRouteCallbacks(context.route);
|
|
33480
33496
|
if (callbacks && callbacks.length > 0) {
|
|
33481
33497
|
fireCallbacks(callbacks, context, result.response);
|
|
33482
33498
|
}
|
|
@@ -33485,7 +33501,7 @@ async function openapi(options) {
|
|
|
33485
33501
|
};
|
|
33486
33502
|
}
|
|
33487
33503
|
function validateSecurity(context, schemes, globalSecurity) {
|
|
33488
|
-
const routeSecurity = context.route
|
|
33504
|
+
const routeSecurity = getRouteSecurity(context.route);
|
|
33489
33505
|
const security = routeSecurity ?? globalSecurity;
|
|
33490
33506
|
if (!security || security.length === 0)
|
|
33491
33507
|
return;
|
|
@@ -33567,7 +33583,7 @@ function processContentNegotiation(context) {
|
|
|
33567
33583
|
const accept = context.headers.accept ?? context.headers.Accept;
|
|
33568
33584
|
if (!accept || accept === "*/*")
|
|
33569
33585
|
return;
|
|
33570
|
-
const responses = context.route
|
|
33586
|
+
const responses = getRouteResponses(context.route);
|
|
33571
33587
|
if (!responses)
|
|
33572
33588
|
return;
|
|
33573
33589
|
const allContentTypes = new Set;
|
|
@@ -33602,7 +33618,7 @@ function processPreferHeader(context, response, fakerSeed) {
|
|
|
33602
33618
|
return { context, response };
|
|
33603
33619
|
}
|
|
33604
33620
|
const prefer = parsePreferHeader(preferValue);
|
|
33605
|
-
const responses = context.route
|
|
33621
|
+
const responses = getRouteResponses(context.route);
|
|
33606
33622
|
if (!responses) {
|
|
33607
33623
|
return { context, response };
|
|
33608
33624
|
}
|
|
@@ -33635,7 +33651,7 @@ function processPreferHeader(context, response, fakerSeed) {
|
|
|
33635
33651
|
}
|
|
33636
33652
|
var ajv = new import_ajv.default({ allErrors: true });
|
|
33637
33653
|
function validateRequestBody(context) {
|
|
33638
|
-
const requestBodySchema = context.route
|
|
33654
|
+
const requestBodySchema = getRouteRequestBody(context.route);
|
|
33639
33655
|
if (!requestBodySchema || context.body === undefined) {
|
|
33640
33656
|
return;
|
|
33641
33657
|
}
|
|
@@ -33955,7 +33971,7 @@ function handleAdminRequest(method, path, mock, res, headers) {
|
|
|
33955
33971
|
res.end(JSON.stringify({ error: "Unknown admin endpoint", code: "NOT_FOUND" }));
|
|
33956
33972
|
}
|
|
33957
33973
|
async function createCliServer(options) {
|
|
33958
|
-
const mock = schmock({ debug: options.debug });
|
|
33974
|
+
const mock = schmock({ debug: options.debug, state: {} });
|
|
33959
33975
|
const openapiOptions = {
|
|
33960
33976
|
spec: options.spec,
|
|
33961
33977
|
fakerSeed: options.fakerSeed,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schmock/cli",
|
|
3
3
|
"description": "CLI for running Schmock mock servers from OpenAPI specs",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@schmock/core": "^1.
|
|
36
|
-
"@schmock/openapi": "^1.
|
|
35
|
+
"@schmock/core": "^1.9.0",
|
|
36
|
+
"@schmock/openapi": "^1.9.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@amiceli/vitest-cucumber": "^6.2.0",
|
|
40
|
-
"@types/node": "^25.2.
|
|
40
|
+
"@types/node": "^25.2.3",
|
|
41
41
|
"vitest": "^4.0.18"
|
|
42
42
|
}
|
|
43
43
|
}
|