From 763bae5e66f68679054bf94ef7140484aeab35a4 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Wed, 9 Aug 2023 21:45:42 +0200 Subject: [PATCH] filter deprecated properties in TS generator --- .../io/vrap/codegen/languages/typescript/TsExtensions.kt | 6 +++++- .../languages/typescript/model/TypeScriptModuleRenderer.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/TsExtensions.kt b/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/TsExtensions.kt index 4102969ba..2f3986b31 100644 --- a/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/TsExtensions.kt +++ b/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/TsExtensions.kt @@ -120,7 +120,11 @@ fun AnyType.deprecated() : Boolean { fun Property.deprecated() : Boolean { val anno = this.getAnnotation("deprecated") - return (anno != null && (anno.value as BooleanInstance).value) + if (anno != null) { + return (anno.value as BooleanInstance).value + } + val typeAnno = this.type.getAnnotation("deprecated") + return (typeAnno != null && (typeAnno.value as BooleanInstance).value) } fun ResourceContainer.allMethods(): List = this diff --git a/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/model/TypeScriptModuleRenderer.kt b/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/model/TypeScriptModuleRenderer.kt index b29312a5e..7dc23c377 100644 --- a/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/model/TypeScriptModuleRenderer.kt +++ b/languages/typescript/src/main/kotlin/io/vrap/codegen/languages/typescript/model/TypeScriptModuleRenderer.kt @@ -110,7 +110,7 @@ class TypeScriptModuleRenderer constructor(override val vrapTypeProvider: VrapTy val renderProperties = if (all) allProperties else properties return renderProperties .filter { !it.isPatternProperty() && it.name != discriminator() } - .filter { !it.deprecated() } + .filterNot { it.deprecated() } .map { val comments = it.type.toTsCommentList().plus(it.markDeprecated()) val comment = if (comments.isEmpty()) "" else comments.joinToString("\n*\t", "/**\n*\t", "\n*/").escapeAll()