API Blueprint JSON Schema
Validates payloads against a specified JSON Schema within your API Blueprint.
- Validate request bodies in your route handlers or middleware
- Validate response bodies within tests
Installation
npm install api-blueprint-json-schema --save
Usage
// Dependenciesvar BlueprintSchema = ; var blueprintSchema; // Create instance of BlueprintSchema from Blueprint JSONblueprintSchema = myBlueprintJson defaultErrorSchema: errorJsonSchema // Response schema for 400+ status' (optional) ; // Create instance of BlueprintSchema from Blueprint markdown (parsing is async)BlueprintSchema; // Access the blueprint JSON, for whatever reasonvar blueprint = blueprintSchemablueprint; // Optionally set a response error schema laterblueprintSchemadefaultErrorSchema = errorJsonSchema; router; // Get a schema, for whatever reasonvar someSchema = blueprintSchema;