@schmock/validation
v2.4.0
Published
Request/response validation plugin for Schmock
Readme
@schmock/validation
Request and response validation for Schmock, backed by AJV and JSON Schema.
Part of Schmock — mock APIs from OpenAPI specs or hand-crafted routes.
Install
bun add -d @schmock/validationUsage
import { schmock } from "@schmock/core";
import { validationPlugin } from "@schmock/validation";
const mock = schmock();
mock("POST /users", ({ body }) => [201, body]).pipe(
validationPlugin({
request: {
body: {
type: "object",
properties: { name: { type: "string" } },
required: ["name"],
},
},
}),
);
// A body without `name` never reaches the generator — it returns 400.Documentation
License
MIT © Khalic Lab
