Any @cleverbrush/schema builder instance.
The same schema instance, now also conforming to StandardJSONSchemaV1.
import { object, string, number } from '@cleverbrush/schema';
import { withStandardJsonSchema } from '@cleverbrush/schema-json';
const schema = object({ name: string(), age: number().optional() });
const wrapped = withStandardJsonSchema(schema);
// Access standard JSON Schema properties
wrapped['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
wrapped['~standard'].jsonSchema.output({ target: 'draft-07' });
Wraps a
@cleverbrush/schemabuilder with the Standard JSON Schema v1 interface.The returned schema object's
~standardproperty is enriched with ajsonSchemaconverter. Because@cleverbrush/schemadoes not distinguish between input and output types, bothinput()andoutput()produce the same JSON Schema document.Note: this mutates the schema instance by overriding the
~standardproperty. The returned reference is the same schema object.