Skip to content

Commit 5b4708f

Browse files
Add httpChecksumRequired trait support
1 parent 2eef98e commit 5b4708f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/integrations/BuiltinsIntegration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import software.amazon.smithy.docgen.core.interceptors.DeprecatedInterceptor;
1616
import software.amazon.smithy.docgen.core.interceptors.ErrorFaultInterceptor;
1717
import software.amazon.smithy.docgen.core.interceptors.ExternalDocsInterceptor;
18+
import software.amazon.smithy.docgen.core.interceptors.HttpChecksumRequiredInterceptor;
1819
import software.amazon.smithy.docgen.core.interceptors.HttpErrorInterceptor;
1920
import software.amazon.smithy.docgen.core.interceptors.HttpHeaderInterceptor;
2021
import software.amazon.smithy.docgen.core.interceptors.HttpInterceptor;
@@ -96,6 +97,7 @@ public List<? extends CodeInterceptor<? extends CodeSection, DocWriter>> interce
9697
new XmlAttributeInterceptor(),
9798
new XmlNameInterceptor(),
9899
new XmlFlattenedInterceptor(),
100+
new HttpChecksumRequiredInterceptor(),
99101
new HttpResponseCodeInterceptor(),
100102
new HttpPayloadInterceptor(),
101103
new HttpErrorInterceptor(),
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package software.amazon.smithy.docgen.core.interceptors;
7+
8+
import software.amazon.smithy.docgen.core.sections.ProtocolSection;
9+
import software.amazon.smithy.docgen.core.writers.DocWriter;
10+
import software.amazon.smithy.docgen.core.writers.DocWriter.AdmonitionType;
11+
import software.amazon.smithy.model.shapes.ShapeId;
12+
import software.amazon.smithy.model.traits.HttpChecksumRequiredTrait;
13+
import software.amazon.smithy.utils.Pair;
14+
import software.amazon.smithy.utils.SmithyInternalApi;
15+
16+
/**
17+
* Adds information about query bindings from the
18+
* <a href="https://smithy.io/2.0/spec/http-bindings.html#httpquery-trait">
19+
* httpQuery trait</a> if the protocol supports it.
20+
*/
21+
@SmithyInternalApi
22+
public final class HttpChecksumRequiredInterceptor extends ProtocolTraitInterceptor<HttpChecksumRequiredTrait> {
23+
private static final Pair<String, String> CONTENT_MD5 = Pair.of(
24+
"Content-MD5", "https://datatracker.ietf.org/doc/html/rfc1864.html"
25+
);
26+
27+
@Override
28+
protected Class<HttpChecksumRequiredTrait> getTraitClass() {
29+
return HttpChecksumRequiredTrait.class;
30+
}
31+
32+
@Override
33+
protected ShapeId getTraitId() {
34+
return HttpChecksumRequiredTrait.ID;
35+
}
36+
37+
@Override
38+
void write(DocWriter writer, String previousText, ProtocolSection section, HttpChecksumRequiredTrait trait) {
39+
writer.writeWithNoFormatting(previousText + "\n");
40+
writer.openAdmonition(AdmonitionType.IMPORTANT);
41+
writer.write("This operation REQUIRES a checksum, such as $R.", CONTENT_MD5);
42+
writer.closeAdmonition();
43+
}
44+
}

0 commit comments

Comments
 (0)