Skip to content

Commit

Permalink
fix(codegen): add doc trait conditionally (#6002)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Apr 15, 2024
1 parent 0ad6f05 commit a61bf71
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.logging.Logger;
Expand Down Expand Up @@ -158,7 +159,11 @@ public Model preprocessModel(Model model, TypeScriptSettings settings) {
String memberName = entry.getKey();
MemberShape memberShape = entry.getValue();

if (memberShape.getTarget().equals(expiresShape.getId())) {
Optional<HttpHeaderTrait> httpHeader = memberShape.getTrait(HttpHeaderTrait.class);
Optional<DocumentationTrait> doc = memberShape.getTrait(DocumentationTrait.class);

if (memberShape.getTarget().equals(expiresShape.getId())
&& httpHeader.isPresent()) {
structureShapeBuilder
.removeMember(memberName)
.addMember(
Expand All @@ -167,17 +172,16 @@ public Model preprocessModel(Model model, TypeScriptSettings settings) {
(m) -> {
m
.addTrait(new DocumentationTrait("Deprecated in favor of ExpiresString."))
.addTrait(memberShape.getTrait(HttpHeaderTrait.class).get())
.addTrait(httpHeader.get())
.addTrait(DeprecatedTrait.builder().build());
}
)
.addMember(
"ExpiresString",
expiresStringShape.getId(),
(m) -> {
m
.addTrait(memberShape.getTrait(DocumentationTrait.class).get())
.addTrait(new HttpHeaderTrait("ExpiresString"));
m.addTrait(new HttpHeaderTrait("ExpiresString"));
doc.ifPresent(m::addTrait);
}
);
} else {
Expand Down

0 comments on commit a61bf71

Please sign in to comment.