Skip to content

Commit

Permalink
Incorporate CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Mar 12, 2021
1 parent 6369c86 commit bd50e45
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion docs/source/1.0/guides/evolving-models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following changes to operation shapes are backward-compatible:
The following changes are not backward-compatible:

#. Removing a resource or operation.
#. Renaming a shape that was was already part of the service.
#. Renaming a shape that was already part of the service.


Updating operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public final class CfnConfig extends JsonSchemaConfig {
private Map<ShapeId, Map<String, Node>> jsonAdd = Collections.emptyMap();
private String organizationName;
private String serviceName;
private ShapeId service;
private List<String> sourceDocs = ListUtils.of(
"Source Url", "SourceUrl", "Source", "Source Code");

Expand Down Expand Up @@ -232,21 +231,6 @@ public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}

public ShapeId getService() {
return service;
}

/**
* Sets the service shape ID to convert the resources of.
*
* <p>For example, smithy.example#Weather.
*
* @param service the Smithy service shape ID to convert the resources of.
*/
public void setService(ShapeId service) {
this.service = service;
}

public List<String> getSourceDocs() {
return sourceDocs;
}
Expand Down
4 changes: 4 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use smithy.test#httpResponseTests
@restJson1
service RestJson {
version: "2019-12-16",
// Ensure that generators are able to handle renames.
rename: {
"aws.protocoltests.restjson.nested#GreetingStruct": "RenamedGreeting",
},
operations: [
// Basic input and output tests
NoInputAndNoOutput,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$version: "1.0"

namespace aws.protocoltests.restjson.nested

// Note that this conflicts with the shared-types GreetingStruct
// and needs to be renamed if used as part of a service closure.
structure GreetingStruct {
salutation: String,
}
28 changes: 28 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/unions.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ union MyUnion {
listValue: StringList,
mapValue: StringMap,
structureValue: GreetingStruct,

// Note that this uses a conflicting structure name with
// GreetingStruct, so it must be renamed in the service.
renamedStructureValue: aws.protocoltests.restjson.nested#GreetingStruct,
}

apply JsonUnions @httpRequestTests([
Expand Down Expand Up @@ -230,6 +234,30 @@ apply JsonUnions @httpRequestTests([
}
}
},
{
id: "RestJsonSerializeRenamedStructureUnionValue",
documentation: "Serializes a renamed structure union value",
protocol: restJson1,
method: "PUT",
uri: "/JsonUnions",
body: """
{
"contents": {
"renamedStructureValue": {
"salutation": "hello!"
}
}
}""",
bodyMediaType: "application/json",
headers: {"Content-Type": "application/json"},
params: {
contents: {
renamedStructureValue: {
salutation: "hello!",
}
}
}
},
])

apply JsonUnions @httpResponseTests([
Expand Down
34 changes: 0 additions & 34 deletions smithy-aws-protocol-tests/model/restJson1WithRenames/main.smithy

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import software.amazon.smithy.model.validation.ValidationEvent;

/**
* Creates a DANGER event when a shape is renamed that was already
* Creates an ERROR event when a shape is renamed that was already
* part of the service, when a rename changes for a shape, or when
* a rename is removed for a shape.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private List<ValidationEvent> validateRenames(ServiceShape service, Map<ShapeId,
} else {
getInvalidRenameReason(closure.get(from)).ifPresent(reason -> {
events.add(error(service, String.format(
"Service attempts to rename an invalid %s shape from `%s` to \"%s\"; %s",
"Service attempts to rename a %s shape from `%s` to \"%s\"; %s",
closure.get(from).getType(), from, to, reason)));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package software.amazon.smithy.model.shapes;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -44,4 +46,16 @@ public void convertsToBuilder() {
.build();
assertEquals(service, service.toBuilder().build());
}

@Test
public void providesContextualShapeName() {
ShapeId id = ShapeId.from("foo.bar#Name");
ServiceShape serviceShape = ServiceShape.builder()
.id("smithy.example#Service")
.version("1")
.putRename(id, "FooName")
.build();

assertThat(serviceShape.getContextualName(id), equalTo("FooName"));
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ERROR] smithy.example#MyService: Service attempts to rename an invalid structure shape from `smithy.example#BadGreeting` to "ThisDoesNotWork"; errors cannot be renamed | Service
[ERROR] smithy.example#MyService: Service attempts to rename a structure shape from `smithy.example#BadGreeting` to "ThisDoesNotWork"; errors cannot be renamed | Service
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ERROR] smithy.example#MyService: Service attempts to rename an invalid member shape from `smithy.example#SayHelloInput$foo` to "thisDoesNotWork"; members cannot be renamed | Service
[ERROR] smithy.example#MyService: Service attempts to rename a member shape from `smithy.example#SayHelloInput$foo` to "thisDoesNotWork"; members cannot be renamed | Service
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ERROR] smithy.example#MyService: Service attempts to rename an invalid operation shape from `smithy.example#SayHello` to "SayHello2"; operations cannot be renamed | Service
[ERROR] smithy.example#MyService: Service attempts to rename a operation shape from `smithy.example#SayHello` to "SayHello2"; operations cannot be renamed | Service

0 comments on commit bd50e45

Please sign in to comment.