Libraries
    Preparing search index...

    Type Alias ToJsonSchemaOptions

    Options accepted by toJsonSchema.

    type ToJsonSchemaOptions = {
        $schema?: boolean;
        draft?: "2020-12" | "07";
        nameResolver?: (schema: SchemaBuilder) => string | null;
    }
    Index

    Properties

    $schema?: boolean

    Whether to include the $schema header in the output. Set to false when embedding in an OpenAPI spec.

    true
    
    draft?: "2020-12" | "07"

    JSON Schema draft version to reference in the $schema header.

    '2020-12'
    
    nameResolver?: (schema: SchemaBuilder) => string | null

    Optional hook called for every schema node before conversion.

    When provided, the function receives each SchemaBuilder instance encountered during recursive conversion (including nested ones inside objects, arrays, and unions). If the function returns a non-null string, conversion of that node is short-circuited and a { $ref: '#/components/schemas/<name>' } object is returned instead of the full inline JSON Schema.

    Return null to let conversion proceed normally.

    Primarily used by @cleverbrush/server-openapi to emit $ref pointers for schemas registered via .schemaName().

    Type Declaration

      • (schema: SchemaBuilder): string | null
      • Parameters

        Returns string | null

        The component name to reference, or null to inline.