From 6b1a4202f92759c9ef36d32d0960faf4f56cc8db Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Wed, 30 Jan 2019 14:18:10 +0100 Subject: [PATCH] fix: use tsconfig.json of project for schema generation Fixes #10 --- src/common.ts | 1 + {test => src}/resources/Foo.ts | 0 src/schema.ts | 4 ++-- test/Schema.spec.ts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) rename {test => src}/resources/Foo.ts (100%) diff --git a/src/common.ts b/src/common.ts index aaa344b6..bfcca2a2 100644 --- a/src/common.ts +++ b/src/common.ts @@ -123,6 +123,7 @@ export function getProjectReflection(srcPath: PathLike): ProjectReflection { excludeExternals: true, includeDeclarations: true, module: 'commonjs', + tsconfig: join(getTsconfigPath(srcPath.toString()), 'tsconfig.json'), }); // get input files diff --git a/test/resources/Foo.ts b/src/resources/Foo.ts similarity index 100% rename from test/resources/Foo.ts rename to src/resources/Foo.ts diff --git a/src/schema.ts b/src/schema.ts index ce6ed087..d9141431 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -21,7 +21,7 @@ import {createParser} from 'ts-json-schema-generator/dist/factory/parser'; import {createProgram} from 'ts-json-schema-generator/dist/factory/program'; import {ProjectReflection} from 'typedoc'; import * as ts from 'typescript'; -import {isSchemaWithDefinitions} from './common'; +import {getTsconfigPath, isSchemaWithDefinitions} from './common'; /** * StAppsCore converter @@ -43,7 +43,7 @@ export class Converter { ...DEFAULT_CONFIG, // expose: 'exported' as any, // jsDoc: 'extended' as any, - path: join(path, '**/*.ts'), + path: join(getTsconfigPath(path), 'tsconfig.json'), sortProps: true, topRef: false, type: 'SC', diff --git a/test/Schema.spec.ts b/test/Schema.spec.ts index 363c1917..56dc8066 100644 --- a/test/Schema.spec.ts +++ b/test/Schema.spec.ts @@ -29,7 +29,7 @@ process.on('unhandledRejection', (err) => { export class SchemaSpec { @test async getSchema() { - const converter = new Converter(join(__dirname, 'resources')); + const converter = new Converter(join(__dirname, '..', 'src', 'resources')); const schema = converter.getSchema('Foo', '0.0.1');