@schmock/schema 1.0.0 → 1.0.1
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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Plugin } from "@schmock/core";
|
|
1
2
|
import type { JSONSchema7 } from "json-schema";
|
|
2
3
|
interface SchemaGenerationContext {
|
|
3
4
|
schema: JSONSchema7;
|
|
@@ -12,7 +13,7 @@ interface SchemaPluginOptions {
|
|
|
12
13
|
count?: number;
|
|
13
14
|
overrides?: Record<string, any>;
|
|
14
15
|
}
|
|
15
|
-
export declare function schemaPlugin(options: SchemaPluginOptions):
|
|
16
|
+
export declare function schemaPlugin(options: SchemaPluginOptions): Plugin;
|
|
16
17
|
export declare function generateFromSchema(options: SchemaGenerationContext): any;
|
|
17
18
|
export {};
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAM3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgC/C,UAAU,uBAAuB;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,UAAU,mBAAmB;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA8CjE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,GAAG,CA4CxE"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference path="../../../types/schmock.d.ts" />
|
|
2
|
-
|
|
3
1
|
import { en, Faker } from "@faker-js/faker";
|
|
2
|
+
import type { Plugin, PluginContext } from "@schmock/core";
|
|
4
3
|
import {
|
|
5
4
|
ResourceLimitError,
|
|
6
5
|
SchemaGenerationError,
|
|
@@ -53,7 +52,7 @@ interface SchemaPluginOptions {
|
|
|
53
52
|
overrides?: Record<string, any>;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
export function schemaPlugin(options: SchemaPluginOptions):
|
|
55
|
+
export function schemaPlugin(options: SchemaPluginOptions): Plugin {
|
|
57
56
|
// Validate schema immediately when plugin is created
|
|
58
57
|
validateSchema(options.schema);
|
|
59
58
|
|
|
@@ -61,7 +60,7 @@ export function schemaPlugin(options: SchemaPluginOptions): Schmock.Plugin {
|
|
|
61
60
|
name: "schema",
|
|
62
61
|
version: "1.0.0",
|
|
63
62
|
|
|
64
|
-
process(context:
|
|
63
|
+
process(context: PluginContext, response?: any) {
|
|
65
64
|
// If response already exists, pass it through
|
|
66
65
|
if (response !== undefined && response !== null) {
|
|
67
66
|
return { context, response };
|