Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix searching for namespaced xml attrs #1034

Merged
merged 7 commits into from
Jan 14, 2021
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
17 changes: 17 additions & 0 deletions codegen/protocol-test-codegen/smithy-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@
"moduleVersion": "1.0"
}
}
},
"aws-restxml-with-namespace": {
"transforms": [
{
"name": "includeServices",
"args": {
"services": ["aws.protocoltests.restxml.xmlns#RestXmlWithNamespace"]
}
}
],
"plugins": {
"go-codegen": {
"service": "aws.protocoltests.restxml.xmlns#RestXmlWithNamespace",
"module": "github.com/aws/aws-sdk-go-v2/internal/protocoltest/restxmlwithnamespace",
"moduleVersion": "1.0"
}
}
}
}
}
92 changes: 0 additions & 92 deletions codegen/sdk-codegen/aws-models/redshiftdata.2019-12-20.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"smithy": "1.0",
"shapes": {
"aws.api#ArnNamespace": {
"type": "string",
"traits": {
"smithy.api#pattern": "^[a-z0-9.\\-]{1,63}$",
"smithy.api#private": {}
}
},
"com.amazonaws.redshiftdata#Blob": {
"type": "blob"
},
Expand Down Expand Up @@ -72,13 +65,6 @@
}
}
},
"aws.api#CloudFormationName": {
"type": "string",
"traits": {
"smithy.api#pattern": "^[A-Z][A-Za-z0-9]+$",
"smithy.api#private": {}
}
},
"com.amazonaws.redshiftdata#ColumnList": {
"type": "list",
"member": {
Expand Down Expand Up @@ -1263,15 +1249,6 @@
"com.amazonaws.redshiftdata#String": {
"type": "string"
},
"aws.protocols#StringList": {
"type": "list",
"member": {
"target": "smithy.api#String"
},
"traits": {
"smithy.api#private": {}
}
},
"com.amazonaws.redshiftdata#TableList": {
"type": "list",
"member": {
Expand Down Expand Up @@ -1323,77 +1300,8 @@
"smithy.api#httpError": 400
}
},
"aws.protocols#awsJson1_1": {
"type": "structure",
"members": {
"http": {
"target": "aws.protocols#StringList"
},
"eventStreamHttp": {
"target": "aws.protocols#StringList"
}
},
"traits": {
"smithy.api#documentation": "An RPC-based protocol that sends JSON payloads. This protocol does not use HTTP binding traits.",
"smithy.api#protocolDefinition": {
"traits": ["smithy.api#jsonName"]
},
"smithy.api#trait": {
"selector": "service"
}
}
},
"com.amazonaws.redshiftdata#bool": {
"type": "boolean"
},
"aws.api#service": {
"type": "structure",
"members": {
"sdkId": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": {}
}
},
"arnNamespace": {
"target": "aws.api#ArnNamespace"
},
"cloudFormationName": {
"target": "aws.api#CloudFormationName"
},
"cloudTrailEventSource": {
"target": "smithy.api#String"
}
},
"traits": {
"smithy.api#trait": {
"selector": "service"
}
}
},
"aws.auth#sigv4": {
"type": "structure",
"members": {
"name": {
"target": "smithy.api#String",
"traits": {
"smithy.api#documentation": "The signature version 4 service signing name to use in the credential scope when signing requests. This value SHOULD match the `arnNamespace` property of the `aws.api#service-trait`.",
"smithy.api#externalDocumentation": {
"Reference": "https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html"
},
"smithy.api#required": {}
}
}
},
"traits": {
"smithy.api#documentation": "Signature Version 4 is the process to add authentication information to AWS requests sent by HTTP. For security, most requests to AWS must be signed with an access key, which consists of an access key ID and secret access key. These two keys are commonly referred to as your security credentials.",
"smithy.api#externalDocumentation": {
"Reference": "https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html"
},
"smithy.api#trait": {
"selector": "service"
}
}
}
}
}
2 changes: 1 addition & 1 deletion codegen/smithy-aws-go-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tasks.withType<Test> {
}

dependencies {
api("software.amazon.smithy:smithy-aws-traits:1.4.0")
api("software.amazon.smithy:smithy-aws-traits:[1.5.1,2.0.0[")
api("software.amazon.smithy:smithy-go-codegen:0.1.0")
testCompile("org.junit.jupiter:junit-jupiter-api:5.4.0")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.4.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ static void generateHttpProtocolTests(GenerationContext context) {
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.json#JsonProtocol"))
.operation(ShapeId.from("aws.protocoltests.json#PutAndGetInlineDocuments"))
.build(),

// Rest XML namespaced attributes. This needs to be fixed, but can be punted
// temporarily since this is only used in an output in a single service.
// TODO: fix serializing namespaced xml attributes
HttpProtocolUnitTestGenerator.SkipTest.builder()
.service(ShapeId.from("aws.protocoltests.restxml.xmlns#RestXmlWithNamespace"))
.operation(ShapeId.from("aws.protocoltests.restxml.xmlns#SimpleScalarProperties"))
.build()
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ protected void deserializeStructure(GenerationContext context, StructureShape sh
// Deserialize member shapes modeled with xml attribute trait
if (hasXmlAttributeTraitMember(shape)) {
writer.openBlock("for _, attr := range decoder.StartEl.Attr {", "}", () -> {
writer.write("name := attr.Name.Local");
writer.openBlock("if len(attr.Name.Space) != 0 {", "}", () -> {
writer.addUseImports(SmithyGoDependency.STRINGS);
writer.write("name = attr.Name.Space + `:` + attr.Name.Local");
});
writer.openBlock("switch {", "}", () -> {
Set<MemberShape> members = new TreeSet<>(shape.members());
for (MemberShape member : members) {
Expand All @@ -336,7 +341,7 @@ protected void deserializeStructure(GenerationContext context, StructureShape sh
String memberName = symbolProvider.toMemberName(member);
String serializedMemberName = getSerializedMemberName(member);
writer.addUseImports(SmithyGoDependency.STRINGS);
writer.openBlock("case strings.EqualFold($S, attr.Name.Local):", "", serializedMemberName, () -> {
writer.openBlock("case strings.EqualFold($S, name):", "", serializedMemberName, () -> {
String dest = "sv." + memberName;
context.getModel().expectShape(member.getTarget()).accept(
getMemberDeserVisitor(member, dest, true));
Expand Down
1 change: 1 addition & 0 deletions config/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
1 change: 1 addition & 0 deletions credentials/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down
1 change: 1 addition & 0 deletions example/service/s3/listObjects/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
1 change: 1 addition & 0 deletions feature/dynamodb/attributevalue/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down
1 change: 1 addition & 0 deletions feature/dynamodb/expression/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down
1 change: 1 addition & 0 deletions feature/dynamodbstreams/attributevalue/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down
1 change: 1 addition & 0 deletions feature/s3/manager/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/aws/smithy-go v0.0.0-20210113172615-49588e1e8525/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2 h1:qIAVUVx5yD0y97KcrYHwGo2pQ/xUPyj1XzMC/8FWinM=
github.com/aws/smithy-go v0.5.1-0.20210108173245-f6f6b16d20b2/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down
12 changes: 10 additions & 2 deletions internal/protocoltest/restxml/deserializers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading