Skip to content

Commit

Permalink
Fix IDL serialization to add resource properties (#1996)
Browse files Browse the repository at this point in the history
* generate resource shape 'properties' with Smithy IDL serialization

* properties serialization round trip test

adding properties to MyResource triggered validation errors, so had to extend test schema to pass validation.

* order the new operations correctly to match output format

* keep EmptyResource
  • Loading branch information
zourzouvillys authored Oct 11, 2023
1 parent 8d2a291 commit e5cd7d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,11 @@ public Void resourceShape(ResourceShape shape) {
codeWriter.writeOptionalIdList("operations", shape.getIntroducedOperations());
codeWriter.writeOptionalIdList("collectionOperations", shape.getCollectionOperations());
codeWriter.writeOptionalIdList("resources", shape.getIntroducedResources());

if (shape.hasProperties()) {
codeWriter.openBlock("properties: {");
shape.getProperties().forEach((name, shapeId) -> codeWriter.write("$L: $I", name, shapeId));
codeWriter.closeBlock("}");
}
codeWriter.closeBlock("}");
codeWriter.write("");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ resource MyResource {
id: String
}
put: ResourceOperation
create: ResourceOperation
create: EmptyOperation
read: ReadonlyResourceOperation
update: ResourceOperation
delete: ResourceOperation
list: ReadonlyResourceOperation
list: CollectionResourceOperation
operations: [
ResourceOperation
CollectionResourceOperation
]
collectionOperations: [
ResourceOperation
CollectionResourceOperation
]
resources: [
SubResource
]
properties: {
value: String
other: String
}
}

resource SubResource {
Expand All @@ -46,6 +50,15 @@ resource SubResource {
}
}

@readonly
operation CollectionResourceOperation {
input := {}
output := {}
errors: [
Error
]
}

operation EmptyOperation {
input: Unit
output: Unit
Expand All @@ -62,6 +75,7 @@ operation MyOperation {
@readonly
operation ReadonlyResourceOperation {
input := {
@required
id: String
}
output: Unit
Expand All @@ -70,9 +84,13 @@ operation ReadonlyResourceOperation {
@idempotent
operation ResourceOperation {
input := {
@required
id: String
}
output: Unit
output := {
value: String
other: String
}
}

@error("client")
Expand Down

0 comments on commit e5cd7d1

Please sign in to comment.