Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SchemaPrinter

Prints a JSON schema in a human-friendly format.

import chalk from 'chalk';
class MyPropertyRenderer extends SchemaPropertyRenderer {
  renderName(name) { return chalk.bold.blue(name); }
}

const printer = new SchemaPrinter(logger, schema, new MyPropertyRenderer());
printer.getLines().forEach(console.log);

Hierarchy

  • SchemaPrinter

Index

Constructors

Methods

Constructors

constructor

  • Constructs a new SchemaPrinter.

    Parameters

    • logger: Logger

      The logger to use when emitting the printed schema.

    • schema: JsonMap

      The schema to print.

    • Default value propertyRenderer: SchemaPropertyRenderer = new SchemaPropertyRenderer()

      The property renderer.

    Returns SchemaPrinter

Methods

getLine

  • getLine(index: number): string
  • Gets a ready-to-display line by index.

    Parameters

    • index: number

      The line index to get.

    Returns string

getLines

  • getLines(): ReadonlyArray<string>
  • Gets a read-only array of ready-to-display lines.

    Returns ReadonlyArray<string>

print

  • print(): void
  • Prints the accumulated set of schema lines as info log lines to the logger.

    Returns void