Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,13 @@ public void testConvertCommonmarkToRstWithNestedList() {
String result = markdownToRstDocConverter.convertCommonmarkToRst(html);
assertEquals(expected, result.trim());
}

@Test
public void testConvertCommonmarkToRstWithFormatSpecifierCharacters() {
// Test that Smithy format specifier characters ($) are properly escaped and treated as literal text
String html = "<html><body><p>Testing $placeholder_one and $placeholder_two</p></body></html>";
String expected = "Testing $placeholder_one and $placeholder_two";
String result = markdownToRstDocConverter.convertCommonmarkToRst(html);
assertEquals(expected, result.trim());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ private void generateOperation(PythonWriter writer, OperationShape operation) {
var outputSymbol = symbolProvider.toSymbol(output);

writer.pushState(new OperationSection(service, operation));
writer.addStdlibImport("copy", "deepcopy");
writer.putContext("input", inputSymbol);
writer.putContext("output", outputSymbol);
writer.putContext("plugin", pluginSymbol);
Expand Down Expand Up @@ -189,6 +188,7 @@ private void writeSharedOperationInit(PythonWriter writer, OperationShape operat
writer.addImport("smithy_core.types", "TypedProperties");
writer.addImport("smithy_core.aio.client", "RequestPipeline");
writer.addImport("smithy_core.exceptions", "ExpectationNotMetError");
writer.addStdlibImport("copy", "deepcopy");

writer.write("""
operation_plugins: list[Plugin] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,9 @@ def _consumer(schema: Schema, de: ShapeDeserializer) -> None:
}

private void deserializeMembers(Collection<MemberShape> members) {
int index = 0;
int index = -1;
for (MemberShape member : members) {
index++;
var target = model.expectShape(member.getTarget());
if (target.hasTrait(StreamingTrait.class) && target.isUnionShape()) {
continue;
Expand All @@ -431,7 +432,7 @@ private void deserializeMembers(Collection<MemberShape> members) {
case $L:
kwargs[$S] = ${C|}
""",
index++,
index,
symbolProvider.toMemberName(member),
writer.consumer(
w -> target.accept(new MemberDeserializerGenerator(context, writer, member, "de"))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void head(Node node, int depth) {
if (!text.trim().isEmpty()) {
if (text.startsWith(":param ")) {
int secondColonIndex = text.indexOf(':', 1);
writer.write(text.substring(0, secondColonIndex + 1));
writer.write("$L", text.substring(0, secondColonIndex + 1));
//TODO right now the code generator gives us a mixture of
// RST and HTML (for instance :param xyz: <p> docs
// </p>). Since we standardize to html above, that <p> tag
Expand All @@ -91,16 +91,16 @@ public void head(Node node, int depth) {
} else {
writer.ensureNewline();
writer.indent();
writer.write(text.substring(secondColonIndex + 1));
writer.write("$L", text.substring(secondColonIndex + 1));
writer.dedent();
}
} else {
writer.writeInline(text);
writer.writeInline("$L", text);
}
// Account for services making a paragraph tag that's empty except
// for a newline
} else if (node.parent() != null && ((Element) node.parent()).tagName().equals("p")) {
writer.writeInline(text.replaceAll("[ \\t]+", ""));
writer.writeInline("$L", text.replaceAll("[ \\t]+", ""));
}
} else if (node instanceof Element) {
Element element = (Element) node;
Expand Down Expand Up @@ -158,7 +158,7 @@ public void tail(Node node, int depth) {
case "a":
String href = element.attr("href");
if (!href.isEmpty()) {
writer.writeInline(" <").writeInline(href).writeInline(">`_");
writer.writeInline(" <").writeInline("$L", href).writeInline(">`_");
} else {
writer.writeInline("`");
}
Expand Down Expand Up @@ -196,7 +196,7 @@ public void tail(Node node, int depth) {
break;
case "h1":
String title = element.text();
writer.ensureNewline().writeInline("=".repeat(title.length())).ensureNewline();
writer.ensureNewline().writeInline("$L", "=".repeat(title.length())).ensureNewline();
break;
default:
break;
Expand Down
4 changes: 2 additions & 2 deletions codegen/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
junit5 = "6.0.0"
smithy = "1.62.0"
smithy = "1.63.0"
test-logger-plugin = "4.0.0"
spotbugs = "6.0.22"
spotless = "8.0.0"
smithy-gradle-plugins = "1.3.0"
dep-analysis = "3.1.0"
dep-analysis = "3.4.0"
jsoup = "1.21.2"
commonmark = "0.17.0"

Expand Down
8 changes: 8 additions & 0 deletions packages/smithy-core/.changes/0.1.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"changes": [
{
"type": "bugfix",
"description": "Fix incorrect header casing for the shape id of eventHeaders."
}
]
}
5 changes: 5 additions & 0 deletions packages/smithy-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.1.1

### Bug fixes
* Fix incorrect header casing for the shape id of eventHeaders.

## v0.1.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-core/src/smithy_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from . import interfaces, rfc3986
from .exceptions import SmithyError

__version__ = "0.1.0"
__version__ = "0.1.1"


class HostType(Enum):
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-core/src/smithy_core/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def value(self) -> str:


@dataclass(init=False, frozen=True)
class EventHeaderTrait(Trait, id=ShapeID("smithy.api#eventheader")):
class EventHeaderTrait(Trait, id=ShapeID("smithy.api#eventHeader")):
def __post_init__(self):
assert self.document_value is None

Expand Down
8 changes: 8 additions & 0 deletions packages/smithy-http/.changes/0.2.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"changes": [
{
"type": "bugfix",
"description": "Add port to CRT HTTP client's host header."
}
]
}
5 changes: 5 additions & 0 deletions packages/smithy-http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.2.1

### Bug fixes
* Add port to CRT HTTP client's host header.

## v0.2.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-http/src/smithy_http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from . import interfaces
from .interfaces import FieldPosition

__version__ = "0.2.0"
__version__ = "0.2.1"


class Field(interfaces.Field):
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-http/src/smithy_http/aio/crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _marshal_request(
headers_list: list[tuple[str, str]] = []
if "host" not in request.fields:
request.fields.set_field(
Field(name="host", values=[request.destination.host])
Field(name="host", values=[request.destination.netloc])
)

if "accept" not in request.fields:
Expand Down
21 changes: 21 additions & 0 deletions packages/smithy-http/tests/unit/aio/test_crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ def test_client_marshal_request() -> None:
assert crt_request.path == "/path?key1=value1&key2=value2"


@pytest.mark.parametrize(
"host,expected",
[
("example.com", "example.com:8443"),
("2001:db8::1", "[2001:db8::1]:8443"),
],
)
async def test_port_included_in_host_header(host: str, expected: str) -> None:
client = AWSCRTHTTPClient()
request = HTTPRequest(
method="GET",
destination=URI(
host=host, path="/path", query="key1=value1&key2=value2", port=8443
),
body=BytesIO(),
fields=Fields(),
)
crt_request = client._marshal_request(request) # type: ignore
assert crt_request.headers.get("host") == expected # type: ignore


async def test_body_generator_bytes() -> None:
"""Test body generator with bytes input."""
client = AWSCRTHTTPClient()
Expand Down
Loading