fix: generate schemas for type aliases

This commit is contained in:
Wieland Schöbl
2021-08-30 15:23:19 +02:00
parent 32fc24f986
commit 96e3acf9ba

View File

@@ -14,13 +14,13 @@
*/
import Ajv from 'ajv';
import {JSONSchema7 as JSONSchema} from 'json-schema';
import {filter} from 'lodash';
import {chain} from 'lodash';
import {Config, DEFAULT_CONFIG, Definition, SchemaGenerator} from 'ts-json-schema-generator';
import {createFormatter} from 'ts-json-schema-generator/dist/factory/formatter';
import {createParser} from 'ts-json-schema-generator/dist/factory/parser';
import {createProgram} from 'ts-json-schema-generator/dist/factory/program';
import {getTsconfigPath} from './common';
import {definitionsOf, isLightweightClass} from './easy-ast/ast-util';
import {definitionsOf} from './easy-ast/ast-util';
import {lightweightProjectFromPath} from './easy-ast/easy-ast';
import {isSchemaWithDefinitions} from './util/guards';
import path from 'path';
@@ -113,7 +113,8 @@ export class Converter {
* Get a list of validatable types from an API extractor file
*/
export function getValidatableTypesInPath(path: string): string[] {
return filter(definitionsOf(lightweightProjectFromPath(path)), isLightweightClass)
.filter(type => type.comment?.tags?.find(it => it.name === 'validatable'))
.map(type => type.name);
return chain(definitionsOf(lightweightProjectFromPath(path)))
.filter(type => !!type.comment?.tags?.find(it => it.name === 'validatable'))
.map(type => type.name)
.value();
}