Skip to content

Commit b09bff0

Browse files
Add httpPrefixHeaders trait support
1 parent 848ec83 commit b09bff0

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-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
@@ -17,6 +17,7 @@
1717
import software.amazon.smithy.docgen.core.interceptors.ExternalDocsInterceptor;
1818
import software.amazon.smithy.docgen.core.interceptors.HttpInterceptor;
1919
import software.amazon.smithy.docgen.core.interceptors.HttpLabelInterceptor;
20+
import software.amazon.smithy.docgen.core.interceptors.HttpPrefixHeadersInterceptor;
2021
import software.amazon.smithy.docgen.core.interceptors.HttpQueryInterceptor;
2122
import software.amazon.smithy.docgen.core.interceptors.HttpQueryParamsInterceptor;
2223
import software.amazon.smithy.docgen.core.interceptors.IdempotencyInterceptor;
@@ -91,6 +92,7 @@ public List<? extends CodeInterceptor<? extends CodeSection, DocWriter>> interce
9192
new XmlAttributeInterceptor(),
9293
new XmlNameInterceptor(),
9394
new XmlFlattenedInterceptor(),
95+
new HttpPrefixHeadersInterceptor(),
9496
new HttpQueryParamsInterceptor(),
9597
new HttpQueryInterceptor(),
9698
new HttpLabelInterceptor(),
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.HttpPrefixHeadersTrait;
12+
import software.amazon.smithy.utils.SmithyInternalApi;
13+
14+
/**
15+
* Adds information about header bindings from the
16+
* <a href="https://smithy.io/2.0/spec/http-bindings.html#httpprefixheaders-trait">
17+
* httpPrefixHeaders trait</a> if the protocol supports it.
18+
*/
19+
@SmithyInternalApi
20+
public final class HttpPrefixHeadersInterceptor extends ProtocolTraitInterceptor<HttpPrefixHeadersTrait> {
21+
@Override
22+
protected Class<HttpPrefixHeadersTrait> getTraitClass() {
23+
return HttpPrefixHeadersTrait.class;
24+
}
25+
26+
@Override
27+
protected ShapeId getTraitId() {
28+
return HttpPrefixHeadersTrait.ID;
29+
}
30+
31+
@Override
32+
void write(DocWriter writer, String previousText, ProtocolSection section, HttpPrefixHeadersTrait trait) {
33+
writer.putContext("prefix", trait.getValue());
34+
writer.write("""
35+
Each pair in this map represents an HTTP header${?prefix} with the prefix \
36+
${prefix:`}${/prefix}.
37+
38+
$L""", previousText);
39+
}
40+
}

0 commit comments

Comments
 (0)