Skip to content

Commit ee059ff

Browse files
Add httpPayload trait support
1 parent 22a712a commit ee059ff

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-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
@@ -19,6 +19,7 @@
1919
import software.amazon.smithy.docgen.core.interceptors.HttpHeaderInterceptor;
2020
import software.amazon.smithy.docgen.core.interceptors.HttpInterceptor;
2121
import software.amazon.smithy.docgen.core.interceptors.HttpLabelInterceptor;
22+
import software.amazon.smithy.docgen.core.interceptors.HttpPayloadInterceptor;
2223
import software.amazon.smithy.docgen.core.interceptors.HttpPrefixHeadersInterceptor;
2324
import software.amazon.smithy.docgen.core.interceptors.HttpQueryInterceptor;
2425
import software.amazon.smithy.docgen.core.interceptors.HttpQueryParamsInterceptor;
@@ -94,6 +95,7 @@ public List<? extends CodeInterceptor<? extends CodeSection, DocWriter>> interce
9495
new XmlAttributeInterceptor(),
9596
new XmlNameInterceptor(),
9697
new XmlFlattenedInterceptor(),
98+
new HttpPayloadInterceptor(),
9799
new HttpErrorInterceptor(),
98100
new HttpHeaderInterceptor(),
99101
new HttpPrefixHeadersInterceptor(),
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.model.shapes.ShapeId;
11+
import software.amazon.smithy.model.traits.HttpPayloadTrait;
12+
import software.amazon.smithy.utils.SmithyInternalApi;
13+
14+
/**
15+
* Adds information about payload bindings from the
16+
* <a href="https://smithy.io/2.0/spec/http-bindings.html#httppayload-trait">
17+
* httpPayload trait</a> if the protocol supports it.
18+
*/
19+
@SmithyInternalApi
20+
public final class HttpPayloadInterceptor extends ProtocolTraitInterceptor<HttpPayloadTrait> {
21+
@Override
22+
protected Class<HttpPayloadTrait> getTraitClass() {
23+
return HttpPayloadTrait.class;
24+
}
25+
26+
@Override
27+
protected ShapeId getTraitId() {
28+
return HttpPayloadTrait.ID;
29+
}
30+
31+
@Override
32+
void write(DocWriter writer, String previousText, ProtocolSection section, HttpPayloadTrait trait) {
33+
writer.write("""
34+
This is bound directly to the HTTP message body without wrapping.
35+
36+
$L""", previousText);
37+
}
38+
}

0 commit comments

Comments
 (0)