UNPKG

2.11 kBTypeScriptView Raw
1import { JSONSchema4 } from 'json-schema';
2import { Options as $RefOptions } from 'json-schema-ref-parser';
3import { Options as PrettierOptions } from 'prettier';
4export { EnumJSONSchema, JSONSchema, NamedEnumJSONSchema, CustomTypeJSONSchema } from './types/JSONSchema';
5export interface Options {
6 /**
7 * Disclaimer comment prepended to the top of each generated file.
8 */
9 bannerComment: string;
10 /**
11 * Root directory for resolving [`$ref`](https://tools.ietf.org/id/draft-pbryan-zyp-json-ref-03.html)s.
12 */
13 cwd: string;
14 /**
15 * Declare external schemas referenced via `$ref`?
16 */
17 declareExternallyReferenced: boolean;
18 /**
19 * Prepend enums with [`const`](https://www.typescriptlang.org/docs/handbook/enums.html#computed-and-constant-members)?
20 */
21 enableConstEnums: boolean;
22 /**
23 * Format code? Set this to `false` to improve performance.
24 */
25 format: boolean;
26 /**
27 * Ignore maxItems and minItems for `array` types, preventing tuples being generated.
28 */
29 ignoreMinAndMaxItems: boolean;
30 /**
31 * Append all index signatures with `| undefined` so that they are strictly typed.
32 *
33 * This is required to be compatible with `strictNullChecks`.
34 */
35 strictIndexSignatures: boolean;
36 /**
37 * A [Prettier](https://prettier.io/docs/en/options.html) configuration.
38 */
39 style: PrettierOptions;
40 /**
41 * Generate code for `definitions` that aren't referenced by the schema?
42 */
43 unreachableDefinitions: boolean;
44 /**
45 * Generate unknown type instead of any
46 */
47 unknownAny: boolean;
48 /**
49 * [$RefParser](https://github.com/BigstickCarpet/json-schema-ref-parser) Options, used when resolving `$ref`s
50 */
51 $refOptions: $RefOptions;
52}
53export declare const DEFAULT_OPTIONS: Options;
54export declare function compileFromFile(filename: string, options?: Partial<Options>): Promise<string>;
55export declare function compile(schema: JSONSchema4, name: string, options?: Partial<Options>): Promise<string>;
56export declare class ValidationError extends Error {
57}