Skip to content

Commit a26b950

Browse files
committed
Fix resource properties IDL serializing order
1 parent 996fd94 commit a26b950

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

smithy-model/src/main/java/software/amazon/smithy/model/shapes/SmithyIdlModelSerializer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,11 @@ public Void resourceShape(ResourceShape shape) {
837837
entry.getValue()));
838838
codeWriter.closeBlock("}");
839839
}
840+
if (shape.hasProperties()) {
841+
codeWriter.openBlock("properties: {");
842+
shape.getProperties().forEach((name, shapeId) -> codeWriter.write("$L: $I", name, shapeId));
843+
codeWriter.closeBlock("}");
844+
}
840845

841846
shape.getPut().ifPresent(shapeId -> codeWriter.write("put: $I", shapeId));
842847
shape.getCreate().ifPresent(shapeId -> codeWriter.write("create: $I", shapeId));
@@ -847,11 +852,6 @@ public Void resourceShape(ResourceShape shape) {
847852
codeWriter.writeOptionalIdList("operations", shape.getIntroducedOperations());
848853
codeWriter.writeOptionalIdList("collectionOperations", shape.getCollectionOperations());
849854
codeWriter.writeOptionalIdList("resources", shape.getIntroducedResources());
850-
if (shape.hasProperties()) {
851-
codeWriter.openBlock("properties: {");
852-
shape.getProperties().forEach((name, shapeId) -> codeWriter.write("$L: $I", name, shapeId));
853-
codeWriter.closeBlock("}");
854-
}
855855
codeWriter.closeBlock("}");
856856
codeWriter.write("");
857857
return null;

smithy-model/src/test/resources/software/amazon/smithy/model/shapes/idl-serialization/cases/service-shapes.smithy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ resource MyResource {
2323
identifiers: {
2424
id: String
2525
}
26+
properties: {
27+
value: String
28+
other: String
29+
}
2630
put: ResourceOperation
2731
create: EmptyOperation
2832
read: ReadonlyResourceOperation
@@ -38,10 +42,6 @@ resource MyResource {
3842
resources: [
3943
SubResource
4044
]
41-
properties: {
42-
value: String
43-
other: String
44-
}
4545
}
4646

4747
resource SubResource {

0 commit comments

Comments
 (0)