Skip to content

Commit bd50e45

Browse files
committed
Incorporate CR feedback
1 parent 6369c86 commit bd50e45

File tree

13 files changed

+61
-61
lines changed

13 files changed

+61
-61
lines changed

docs/source/1.0/guides/evolving-models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The following changes to operation shapes are backward-compatible:
2222
The following changes are not backward-compatible:
2323

2424
#. Removing a resource or operation.
25-
#. Renaming a shape that was was already part of the service.
25+
#. Renaming a shape that was already part of the service.
2626

2727

2828
Updating operations

smithy-aws-cloudformation/src/main/java/software/amazon/smithy/aws/cloudformation/schema/CfnConfig.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public final class CfnConfig extends JsonSchemaConfig {
4444
private Map<ShapeId, Map<String, Node>> jsonAdd = Collections.emptyMap();
4545
private String organizationName;
4646
private String serviceName;
47-
private ShapeId service;
4847
private List<String> sourceDocs = ListUtils.of(
4948
"Source Url", "SourceUrl", "Source", "Source Code");
5049

@@ -232,21 +231,6 @@ public void setServiceName(String serviceName) {
232231
this.serviceName = serviceName;
233232
}
234233

235-
public ShapeId getService() {
236-
return service;
237-
}
238-
239-
/**
240-
* Sets the service shape ID to convert the resources of.
241-
*
242-
* <p>For example, smithy.example#Weather.
243-
*
244-
* @param service the Smithy service shape ID to convert the resources of.
245-
*/
246-
public void setService(ShapeId service) {
247-
this.service = service;
248-
}
249-
250234
public List<String> getSourceDocs() {
251235
return sourceDocs;
252236
}

smithy-aws-protocol-tests/model/restJson1/main.smithy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use smithy.test#httpResponseTests
1212
@restJson1
1313
service RestJson {
1414
version: "2019-12-16",
15+
// Ensure that generators are able to handle renames.
16+
rename: {
17+
"aws.protocoltests.restjson.nested#GreetingStruct": "RenamedGreeting",
18+
},
1519
operations: [
1620
// Basic input and output tests
1721
NoInputAndNoOutput,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$version: "1.0"
2+
3+
namespace aws.protocoltests.restjson.nested
4+
5+
// Note that this conflicts with the shared-types GreetingStruct
6+
// and needs to be renamed if used as part of a service closure.
7+
structure GreetingStruct {
8+
salutation: String,
9+
}

smithy-aws-protocol-tests/model/restJson1/unions.smithy

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ union MyUnion {
3737
listValue: StringList,
3838
mapValue: StringMap,
3939
structureValue: GreetingStruct,
40+
41+
// Note that this uses a conflicting structure name with
42+
// GreetingStruct, so it must be renamed in the service.
43+
renamedStructureValue: aws.protocoltests.restjson.nested#GreetingStruct,
4044
}
4145

4246
apply JsonUnions @httpRequestTests([
@@ -230,6 +234,30 @@ apply JsonUnions @httpRequestTests([
230234
}
231235
}
232236
},
237+
{
238+
id: "RestJsonSerializeRenamedStructureUnionValue",
239+
documentation: "Serializes a renamed structure union value",
240+
protocol: restJson1,
241+
method: "PUT",
242+
uri: "/JsonUnions",
243+
body: """
244+
{
245+
"contents": {
246+
"renamedStructureValue": {
247+
"salutation": "hello!"
248+
}
249+
}
250+
}""",
251+
bodyMediaType: "application/json",
252+
headers: {"Content-Type": "application/json"},
253+
params: {
254+
contents: {
255+
renamedStructureValue: {
256+
salutation: "hello!",
257+
}
258+
}
259+
}
260+
},
233261
])
234262

235263
apply JsonUnions @httpResponseTests([

smithy-aws-protocol-tests/model/restJson1WithRenames/main.smithy

Lines changed: 0 additions & 34 deletions
This file was deleted.

smithy-aws-protocol-tests/model/restJson1WithRenames/other-namespace.smithy

Lines changed: 0 additions & 5 deletions
This file was deleted.

smithy-diff/src/main/java/software/amazon/smithy/diff/evaluators/ServiceRename.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import software.amazon.smithy.model.validation.ValidationEvent;
2929

3030
/**
31-
* Creates a DANGER event when a shape is renamed that was already
31+
* Creates an ERROR event when a shape is renamed that was already
3232
* part of the service, when a rename changes for a shape, or when
3333
* a rename is removed for a shape.
3434
*/

smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ServiceValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private List<ValidationEvent> validateRenames(ServiceShape service, Map<ShapeId,
145145
} else {
146146
getInvalidRenameReason(closure.get(from)).ifPresent(reason -> {
147147
events.add(error(service, String.format(
148-
"Service attempts to rename an invalid %s shape from `%s` to \"%s\"; %s",
148+
"Service attempts to rename a %s shape from `%s` to \"%s\"; %s",
149149
closure.get(from).getType(), from, to, reason)));
150150
});
151151
}

smithy-model/src/test/java/software/amazon/smithy/model/shapes/ServiceShapeTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.smithy.model.shapes;
1717

18+
import static org.hamcrest.MatcherAssert.assertThat;
19+
import static org.hamcrest.Matchers.equalTo;
1820
import static org.junit.jupiter.api.Assertions.assertEquals;
1921

2022
import org.junit.jupiter.api.Assertions;
@@ -44,4 +46,16 @@ public void convertsToBuilder() {
4446
.build();
4547
assertEquals(service, service.toBuilder().build());
4648
}
49+
50+
@Test
51+
public void providesContextualShapeName() {
52+
ShapeId id = ShapeId.from("foo.bar#Name");
53+
ServiceShape serviceShape = ServiceShape.builder()
54+
.id("smithy.example#Service")
55+
.version("1")
56+
.putRename(id, "FooName")
57+
.build();
58+
59+
assertThat(serviceShape.getContextualName(id), equalTo("FooName"));
60+
}
4761
}

0 commit comments

Comments
 (0)