Skip to content

Commit 6be6b21

Browse files
Add base httpQuery trait support
1 parent b2019bf commit 6be6b21

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-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
@@ -16,6 +16,7 @@
1616
import software.amazon.smithy.docgen.core.interceptors.ErrorFaultInterceptor;
1717
import software.amazon.smithy.docgen.core.interceptors.ExternalDocsInterceptor;
1818
import software.amazon.smithy.docgen.core.interceptors.HttpInterceptor;
19+
import software.amazon.smithy.docgen.core.interceptors.HttpQueryInterceptor;
1920
import software.amazon.smithy.docgen.core.interceptors.IdempotencyInterceptor;
2021
import software.amazon.smithy.docgen.core.interceptors.InternalInterceptor;
2122
import software.amazon.smithy.docgen.core.interceptors.JsonNameInterceptor;
@@ -88,6 +89,7 @@ public List<? extends CodeInterceptor<? extends CodeSection, DocWriter>> interce
8889
new XmlAttributeInterceptor(),
8990
new XmlNameInterceptor(),
9091
new XmlFlattenedInterceptor(),
92+
new HttpQueryInterceptor(),
9193
new HttpInterceptor(),
9294
new PaginationInterceptor(),
9395
new RequestCompressionInterceptor(),
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.HttpQueryTrait;
12+
import software.amazon.smithy.utils.SmithyInternalApi;
13+
14+
/**
15+
* Adds information about query bindings from the
16+
* <a href="https://smithy.io/2.0/spec/http-bindings.html#httpquery-trait">
17+
* httpQuery trait</a> if the protocol supports it.
18+
*/
19+
@SmithyInternalApi
20+
public final class HttpQueryInterceptor extends ProtocolTraitInterceptor<HttpQueryTrait> {
21+
@Override
22+
protected Class<HttpQueryTrait> getTraitClass() {
23+
return HttpQueryTrait.class;
24+
}
25+
26+
@Override
27+
protected ShapeId getTraitId() {
28+
return HttpQueryTrait.ID;
29+
}
30+
31+
@Override
32+
void write(DocWriter writer, String previousText, ProtocolSection section, HttpQueryTrait trait) {
33+
writer.putContext("param", trait.getValue());
34+
writer.write("""
35+
This is bound to the HTTP query parameter ${param:`}.
36+
37+
$L""", previousText);
38+
}
39+
}

0 commit comments

Comments
 (0)