From 14b4e3c885dd34abcc885d8b76ef2d857db55e3c Mon Sep 17 00:00:00 2001 From: Arthur Fiorette Date: Mon, 1 Jul 2024 10:05:56 -0300 Subject: [PATCH 1/3] code --- src/Error/Errors.ts | 2 +- src/SchemaGenerator.ts | 4 ++-- test/valid-data-other.test.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Error/Errors.ts b/src/Error/Errors.ts index d0c11f80c..2d0413082 100644 --- a/src/Error/Errors.ts +++ b/src/Error/Errors.ts @@ -17,7 +17,7 @@ export class UnknownTypeError extends BaseError { constructor(readonly type: BaseType) { super({ code: 101, - messageText: `Unknown type "${type.getId()}"`, + messageText: `Unknown type "${type?.getId()}"`, }); } } diff --git a/src/SchemaGenerator.ts b/src/SchemaGenerator.ts index 9ea6d2cf0..910edc3f3 100644 --- a/src/SchemaGenerator.ts +++ b/src/SchemaGenerator.ts @@ -166,8 +166,8 @@ export class SchemaGenerator { ts.isTypeAliasDeclaration(node) ) { if ( - this.config?.expose === "all" || - (this.isExportType(node) && !this.isGenericType(node as ts.TypeAliasDeclaration)) + (this.config?.expose === "all" || this.isExportType(node)) && + !this.isGenericType(node as ts.TypeAliasDeclaration) ) { allTypes.set(this.getFullName(node, typeChecker), node); return; diff --git a/test/valid-data-other.test.ts b/test/valid-data-other.test.ts index 08cec2cb6..2b6ddd181 100644 --- a/test/valid-data-other.test.ts +++ b/test/valid-data-other.test.ts @@ -43,6 +43,7 @@ describe("valid-data-other", () => { it("import-anonymous", assertValidSchema("import-anonymous", "MyObject")); it("generic-simple", assertValidSchema("generic-simple", "MyObject")); + it("generic-simple", assertValidSchema("generic-simple", "*", { expose: "all" })); it("generic-arrays", assertValidSchema("generic-arrays", "MyObject")); it("generic-multiple", assertValidSchema("generic-multiple", "MyObject")); it("generic-multiargs", assertValidSchema("generic-multiargs", "MyObject")); From 357cb5adcc529866d06fe82755a9370a8121abdc Mon Sep 17 00:00:00 2001 From: Arthur Fiorette Date: Mon, 1 Jul 2024 10:16:45 -0300 Subject: [PATCH 2/3] feat: more tests --- src/NodeParser/InterfaceAndClassNodeParser.ts | 2 +- test/valid-data-other.test.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NodeParser/InterfaceAndClassNodeParser.ts b/src/NodeParser/InterfaceAndClassNodeParser.ts index ca8a715b9..cb8907abd 100644 --- a/src/NodeParser/InterfaceAndClassNodeParser.ts +++ b/src/NodeParser/InterfaceAndClassNodeParser.ts @@ -113,7 +113,7 @@ export class InterfaceAndClassNodeParser implements SubNodeParser { if (ts.isConstructorDeclaration(member)) { const params = member.parameters.filter((param) => ts.isParameterPropertyDeclaration(param, param.parent), - ) as ts.ParameterPropertyDeclaration[]; + ); members.push(...params); } else if (ts.isPropertySignature(member) || ts.isPropertyDeclaration(member)) { members.push(member); diff --git a/test/valid-data-other.test.ts b/test/valid-data-other.test.ts index 2b6ddd181..68a8fa209 100644 --- a/test/valid-data-other.test.ts +++ b/test/valid-data-other.test.ts @@ -46,10 +46,13 @@ describe("valid-data-other", () => { it("generic-simple", assertValidSchema("generic-simple", "*", { expose: "all" })); it("generic-arrays", assertValidSchema("generic-arrays", "MyObject")); it("generic-multiple", assertValidSchema("generic-multiple", "MyObject")); + it("generic-multiple", assertValidSchema("generic-multiple", "*", { expose: "all" })); it("generic-multiargs", assertValidSchema("generic-multiargs", "MyObject")); it("generic-anonymous", assertValidSchema("generic-anonymous", "MyObject")); + it("generic-anonymous", assertValidSchema("generic-anonymous", "*", { expose: "all" })); it("generic-recursive", assertValidSchema("generic-recursive", "MyObject")); it("generic-hell", assertValidSchema("generic-hell", "MyObject")); + it("generic-hell", assertValidSchema("generic-hell", "*", { expose: "all" })); it("generic-default-conditional", assertValidSchema("generic-default-conditional", "MyObject")); it("generic-default", assertValidSchema("generic-default", "MyObject")); it("generic-nested", assertValidSchema("generic-nested", "MyObject")); From 7311b7152d5912973891c4f12420d01b78dda831 Mon Sep 17 00:00:00 2001 From: Arthur Fiorette Date: Mon, 1 Jul 2024 10:26:40 -0300 Subject: [PATCH 3/3] removed other tests as they work but generate different results (as expected) --- test/valid-data-other.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/valid-data-other.test.ts b/test/valid-data-other.test.ts index 68a8fa209..2b6ddd181 100644 --- a/test/valid-data-other.test.ts +++ b/test/valid-data-other.test.ts @@ -46,13 +46,10 @@ describe("valid-data-other", () => { it("generic-simple", assertValidSchema("generic-simple", "*", { expose: "all" })); it("generic-arrays", assertValidSchema("generic-arrays", "MyObject")); it("generic-multiple", assertValidSchema("generic-multiple", "MyObject")); - it("generic-multiple", assertValidSchema("generic-multiple", "*", { expose: "all" })); it("generic-multiargs", assertValidSchema("generic-multiargs", "MyObject")); it("generic-anonymous", assertValidSchema("generic-anonymous", "MyObject")); - it("generic-anonymous", assertValidSchema("generic-anonymous", "*", { expose: "all" })); it("generic-recursive", assertValidSchema("generic-recursive", "MyObject")); it("generic-hell", assertValidSchema("generic-hell", "MyObject")); - it("generic-hell", assertValidSchema("generic-hell", "*", { expose: "all" })); it("generic-default-conditional", assertValidSchema("generic-default-conditional", "MyObject")); it("generic-default", assertValidSchema("generic-default", "MyObject")); it("generic-nested", assertValidSchema("generic-nested", "MyObject"));