@schmock/cli 2.1.4 → 2.1.6

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/bin.js CHANGED
@@ -24607,7 +24607,7 @@ function schmock(config) {
24607
24607
  return callableInstance;
24608
24608
  }
24609
24609
  // ../openapi/package.json
24610
- var version = "2.1.4";
24610
+ var version = "2.1.6";
24611
24611
 
24612
24612
  // ../openapi/src/utils.ts
24613
24613
  function isRecord(value) {
@@ -29920,7 +29920,7 @@ function findBestMapping(fieldName, schema, mappings = ALL_FIELD_MAPPINGS) {
29920
29920
  score: 1
29921
29921
  };
29922
29922
  }
29923
- if (schemaAny.pattern || schemaAny.enum || schemaAny.faker || schemaAny.$ref) {
29923
+ if (schemaAny.pattern || schemaAny.enum || schemaAny.faker || schemaAny.$ref || schemaType === "string" && (schema.minLength !== undefined || schema.maxLength !== undefined)) {
29924
29924
  return;
29925
29925
  }
29926
29926
  const hasNumericConstraints = schema.minimum !== undefined || schema.maximum !== undefined || schema.exclusiveMinimum !== undefined || schema.exclusiveMaximum !== undefined;
@@ -30500,10 +30500,12 @@ function createDeleteGenerator(resource, meta) {
30500
30500
  }
30501
30501
  function createStaticGenerator(parsedPath, seed, onSchema) {
30502
30502
  let responseSchema;
30503
+ let responseStatus = 200;
30503
30504
  for (const code of [200, 201]) {
30504
30505
  const resp = parsedPath.responses.get(code);
30505
30506
  if (resp?.schema) {
30506
30507
  responseSchema = resp.schema;
30508
+ responseStatus = code;
30507
30509
  break;
30508
30510
  }
30509
30511
  }
@@ -30511,6 +30513,7 @@ function createStaticGenerator(parsedPath, seed, onSchema) {
30511
30513
  for (const [code, resp] of parsedPath.responses) {
30512
30514
  if (code >= 200 && code < 300 && resp.schema) {
30513
30515
  responseSchema = resp.schema;
30516
+ responseStatus = code;
30514
30517
  break;
30515
30518
  }
30516
30519
  }
@@ -30530,10 +30533,11 @@ function createStaticGenerator(parsedPath, seed, onSchema) {
30530
30533
  schema = patched;
30531
30534
  }
30532
30535
  try {
30533
- return await generateFromSchema({ schema, seed });
30536
+ const body = await generateFromSchema({ schema, seed });
30537
+ return toTuple(responseStatus, body);
30534
30538
  } catch (error) {
30535
30539
  console.warn(`[@schmock/openapi] Schema generation failed for ${parsedPath.method} ${parsedPath.path}:`, error instanceof Error ? error.message : error);
30536
- return {};
30540
+ return toTuple(responseStatus, {});
30537
30541
  }
30538
30542
  }
30539
30543
  return toTuple(200, {});
package/dist/index.js CHANGED
@@ -24606,7 +24606,7 @@ function schmock(config) {
24606
24606
  return callableInstance;
24607
24607
  }
24608
24608
  // ../openapi/package.json
24609
- var version = "2.1.4";
24609
+ var version = "2.1.6";
24610
24610
 
24611
24611
  // ../openapi/src/utils.ts
24612
24612
  function isRecord(value) {
@@ -29919,7 +29919,7 @@ function findBestMapping(fieldName, schema, mappings = ALL_FIELD_MAPPINGS) {
29919
29919
  score: 1
29920
29920
  };
29921
29921
  }
29922
- if (schemaAny.pattern || schemaAny.enum || schemaAny.faker || schemaAny.$ref) {
29922
+ if (schemaAny.pattern || schemaAny.enum || schemaAny.faker || schemaAny.$ref || schemaType === "string" && (schema.minLength !== undefined || schema.maxLength !== undefined)) {
29923
29923
  return;
29924
29924
  }
29925
29925
  const hasNumericConstraints = schema.minimum !== undefined || schema.maximum !== undefined || schema.exclusiveMinimum !== undefined || schema.exclusiveMaximum !== undefined;
@@ -30499,10 +30499,12 @@ function createDeleteGenerator(resource, meta) {
30499
30499
  }
30500
30500
  function createStaticGenerator(parsedPath, seed, onSchema) {
30501
30501
  let responseSchema;
30502
+ let responseStatus = 200;
30502
30503
  for (const code of [200, 201]) {
30503
30504
  const resp = parsedPath.responses.get(code);
30504
30505
  if (resp?.schema) {
30505
30506
  responseSchema = resp.schema;
30507
+ responseStatus = code;
30506
30508
  break;
30507
30509
  }
30508
30510
  }
@@ -30510,6 +30512,7 @@ function createStaticGenerator(parsedPath, seed, onSchema) {
30510
30512
  for (const [code, resp] of parsedPath.responses) {
30511
30513
  if (code >= 200 && code < 300 && resp.schema) {
30512
30514
  responseSchema = resp.schema;
30515
+ responseStatus = code;
30513
30516
  break;
30514
30517
  }
30515
30518
  }
@@ -30529,10 +30532,11 @@ function createStaticGenerator(parsedPath, seed, onSchema) {
30529
30532
  schema = patched;
30530
30533
  }
30531
30534
  try {
30532
- return await generateFromSchema({ schema, seed });
30535
+ const body = await generateFromSchema({ schema, seed });
30536
+ return toTuple(responseStatus, body);
30533
30537
  } catch (error) {
30534
30538
  console.warn(`[@schmock/openapi] Schema generation failed for ${parsedPath.method} ${parsedPath.path}:`, error instanceof Error ? error.message : error);
30535
- return {};
30539
+ return toTuple(responseStatus, {});
30536
30540
  }
30537
30541
  }
30538
30542
  return toTuple(200, {});
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": "2.1.4",
4
+ "version": "2.1.6",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@schmock/core": "^2.1.4",
36
- "@schmock/openapi": "^2.1.4"
35
+ "@schmock/core": "^2.1.6",
36
+ "@schmock/openapi": "^2.1.6"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@amiceli/vitest-cucumber": "^6.5.0",