Skip to content

Commit 2eef98e

Browse files
Add httpResponseCode trait support
1 parent ee059ff commit 2eef98e

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
@@ -23,6 +23,7 @@
2323
import software.amazon.smithy.docgen.core.interceptors.HttpPrefixHeadersInterceptor;
2424
import software.amazon.smithy.docgen.core.interceptors.HttpQueryInterceptor;
2525
import software.amazon.smithy.docgen.core.interceptors.HttpQueryParamsInterceptor;
26+
import software.amazon.smithy.docgen.core.interceptors.HttpResponseCodeInterceptor;
2627
import software.amazon.smithy.docgen.core.interceptors.IdempotencyInterceptor;
2728
import software.amazon.smithy.docgen.core.interceptors.InternalInterceptor;
2829
import software.amazon.smithy.docgen.core.interceptors.JsonNameInterceptor;
@@ -95,6 +96,7 @@ public List<? extends CodeInterceptor<? extends CodeSection, DocWriter>> interce
9596
new XmlAttributeInterceptor(),
9697
new XmlNameInterceptor(),
9798
new XmlFlattenedInterceptor(),
99+
new HttpResponseCodeInterceptor(),
98100
new HttpPayloadInterceptor(),
99101
new HttpErrorInterceptor(),
100102
new HttpHeaderInterceptor(),
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.HttpResponseCodeTrait;
12+
import software.amazon.smithy.utils.SmithyInternalApi;
13+
14+
/**
15+
* Adds information about response code bindings from the
16+
* <a href="https://smithy.io/2.0/spec/http-bindings.html#httpresponsecode-trait">
17+
* httpResponseCode trait</a> if the protocol supports it.
18+
*/
19+
@SmithyInternalApi
20+
public final class HttpResponseCodeInterceptor extends ProtocolTraitInterceptor<HttpResponseCodeTrait> {
21+
@Override
22+
protected Class<HttpResponseCodeTrait> getTraitClass() {
23+
return HttpResponseCodeTrait.class;
24+
}
25+
26+
@Override
27+
protected ShapeId getTraitId() {
28+
return HttpResponseCodeTrait.ID;
29+
}
30+
31+
@Override
32+
void write(DocWriter writer, String previousText, ProtocolSection section, HttpResponseCodeTrait trait) {
33+
writer.write("""
34+
This value represents the HTTP response code for the operation invocation.
35+
36+
$L""", previousText);
37+
}
38+
}

0 commit comments

Comments
 (0)