Skip to content

Commit a17478e

Browse files
authored
Use map instead of isEmpty when writing shape docs (#1210)
1 parent ae49717 commit a17478e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ boolean writeShapeDocs(Shape shape, UnaryOperator<String> preprocessor) {
190190
.replace("}", "\\}");
191191
docs = preprocessor.apply(docs);
192192
if (shape.getTrait(DeprecatedTrait.class).isPresent()) {
193-
DeprecatedTrait deprecatedTrait = shape.getTrait(DeprecatedTrait.class).get();
194-
String deprecationMessage = deprecatedTrait.getMessage().orElse("");
195-
String deprecationString = "@deprecated"
196-
+ (deprecationMessage.isEmpty() ? "" : " " + deprecationMessage);
193+
DeprecatedTrait deprecatedTrait = shape.expectTrait(DeprecatedTrait.class);
194+
String deprecationMessage = deprecatedTrait.getMessage()
195+
.map(msg -> " " + msg)
196+
.orElse("");
197+
String deprecationString = "@deprecated" + deprecationMessage;
197198
docs = deprecationString + "\n\n" + docs;
198199
}
199200
docs = addReleaseTag(shape, docs);

0 commit comments

Comments
 (0)