Skip to content

Commit 73283df

Browse files
Add list context to query traits
1 parent b09bff0 commit 73283df

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/interceptors/HttpQueryInterceptor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ protected ShapeId getTraitId() {
3030

3131
@Override
3232
void write(DocWriter writer, String previousText, ProtocolSection section, HttpQueryTrait trait) {
33+
var target = section.context().model().expectShape(section.shape().asMemberShape().get().getTarget());
3334
writer.putContext("param", trait.getValue());
35+
writer.putContext("list", target.isListShape());
3436
writer.write("""
35-
This is bound to the HTTP query parameter ${param:`}.
37+
This is bound to the HTTP query parameter ${param:`}.${?list} Each element in \
38+
the list is represented by its own key-value pair, each instance using the \
39+
same key.${/list}
3640
3741
$L""", previousText);
3842
}

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/interceptors/HttpQueryParamsInterceptor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import software.amazon.smithy.docgen.core.sections.ProtocolSection;
99
import software.amazon.smithy.docgen.core.writers.DocWriter;
10+
import software.amazon.smithy.model.shapes.MapShape;
1011
import software.amazon.smithy.model.shapes.ShapeId;
1112
import software.amazon.smithy.model.traits.HttpQueryParamsTrait;
1213
import software.amazon.smithy.utils.SmithyInternalApi;
@@ -30,8 +31,14 @@ protected ShapeId getTraitId() {
3031

3132
@Override
3233
void write(DocWriter writer, String previousText, ProtocolSection section, HttpQueryParamsTrait trait) {
34+
var memberTarget = section.shape().asMemberShape().get().getTarget();
35+
var map = section.context().model().expectShape(memberTarget, MapShape.class);
36+
var valueTarget = section.context().model().expectShape(map.getValue().getTarget());
37+
writer.putContext("list", valueTarget.isListShape());
3338
writer.write("""
34-
Each pair in this map represents an HTTP query parameter.
39+
Each pair in this map represents an HTTP query parameter.${?list} Each element in \
40+
the value lists is represented by its own key-value pair, each instance using the \
41+
same key.${/list}
3542
3643
$L""", previousText);
3744
}

0 commit comments

Comments
 (0)