Function: morphioSchema()
morphioSchema(
type,properties,parentTypes?):MorphioSchema
Defined in: schema/operations/SchemaOps.ts:125
Creates and registers a schema for an interface or class.
Parameters
type
ObjectType
The class constructor or interface type
properties
Record<string, PropertyMetadata>
Map of property names to their metadata
parentTypes?
TypeIdentifier[]
Optional array of types this schema extends from
Returns
The created and registered schema
Example
interface Person {
name: string;
age: number;
}
// Using interface name
morphioSchema({ interface: 'Person' }, {
name: { type: 'string', required: true },
age: { type: 'number', required: true }
});
// Using class constructor with inheritance
morphioSchema(Employee, {
salary: { type: 'number', required: true }
}, [Person]);
// Using interface with inheritance
morphioSchema({ interface: 'Admin' }, {
permissions: { type: 'string', required: true }
}, [{ interface: 'Employee' }]);