diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java index 0b37c181b40..b7cea6006c8 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java @@ -190,10 +190,11 @@ boolean writeShapeDocs(Shape shape, UnaryOperator preprocessor) { .replace("}", "\\}"); docs = preprocessor.apply(docs); if (shape.getTrait(DeprecatedTrait.class).isPresent()) { - DeprecatedTrait deprecatedTrait = shape.getTrait(DeprecatedTrait.class).get(); - String deprecationMessage = deprecatedTrait.getMessage().orElse(""); - String deprecationString = "@deprecated" - + (deprecationMessage.isEmpty() ? "" : " " + deprecationMessage); + DeprecatedTrait deprecatedTrait = shape.expectTrait(DeprecatedTrait.class); + String deprecationMessage = deprecatedTrait.getMessage() + .map(msg -> " " + msg) + .orElse(""); + String deprecationString = "@deprecated" + deprecationMessage; docs = deprecationString + "\n\n" + docs; } docs = addReleaseTag(shape, docs);