@nrfcloud/ts-json-schema-transformer
Version:
A TypeScript transformer that generates JSON schemas and validators from TypeScript interfaces
47 lines (46 loc) • 1.6 kB
TypeScript
import type { Options } from "ajv";
import { Config, NodeParser, SchemaGenerator, TypeFormatter } from "ts-json-schema-generator";
import * as ts from "typescript";
export interface IProject {
program: ts.Program;
options: {
schema: SchemaConfig;
validation: AJVOptions;
mock: {
seed: string | false;
};
};
checker: ts.TypeChecker;
schemaGenerator: SchemaGenerator;
typeFormatter: TypeFormatter;
nodeParser: NodeParser;
}
export type AJVOptions = Pick<Options, "useDefaults" | "coerceTypes" | "removeAdditional" | "loopRequired" | "loopEnum" | "allErrors">;
export type SchemaConfig = Pick<Config, "sortProps" | "expose" | "jsDoc" | "strictTuples" | "encodeRefs" | "additionalProperties">;
export declare const DEFAULT_SEED = "emerson";
export declare const AJV_DEFAULTS: {
readonly useDefaults: true;
readonly coerceTypes: false;
readonly loopRequired: 20;
readonly allErrors: true;
readonly removeAdditional: false;
readonly strict: false;
};
export declare const SCHEMA_DEFAULTS: {
readonly expose: "export";
readonly jsDoc: "extended";
readonly sortProps: true;
readonly strictTuples: false;
readonly encodeRefs: true;
readonly additionalProperties: false;
readonly minify: true;
readonly topRef: true;
readonly markdownDescription: true;
readonly extraTags: [];
readonly skipTypeCheck: true;
readonly discriminatorType: "json-schema";
readonly functions: "fail";
};
export type IOptions = AJVOptions & SchemaConfig & {
seed?: string | false;
};