Skip to content

Commit db2cde5

Browse files
mtdowlingMichael Dowling
authored and
Michael Dowling
committed
Ignore types changes to same type
1 parent 0ccf3ad commit db2cde5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

smithy-model/src/main/java/software/amazon/smithy/model/transform/ChangeShapeType.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ static ChangeShapeType downgradeEnums(Model model) {
8585
Model transform(ModelTransformer transformer, Model model) {
8686
return transformer.mapShapes(model, shape -> {
8787
if (shapeToType.containsKey(shape.getId())) {
88-
return shape.accept(new Retype(shapeToType.get(shape.getId()), synthesizeEnumNames));
88+
ShapeType targetType = shapeToType.get(shape.getId());
89+
return targetType == shape.getType()
90+
? shape
91+
: shape.accept(new Retype(targetType, synthesizeEnumNames));
8992
} else {
9093
return shape;
9194
}

smithy-model/src/test/java/software/amazon/smithy/model/transform/ChangeShapeTypeTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ public void cannotConvertStructureToAnythingButUnion() {
242242
});
243243
}
244244

245+
@Test
246+
public void ignoresConversionToSameType() {
247+
Shape startShape = StructureShape.builder().id(ShapeId.from("smithy.example#Test")).build();
248+
Model model = Model.assembler().addShape(startShape).assemble().unwrap();
249+
250+
ModelTransformer.create().changeShapeType(model, MapUtils.of(startShape.getId(), ShapeType.STRUCTURE));
251+
}
252+
245253
@Test
246254
public void cannotConvertUnionToAnythingButStructure() {
247255
Shape startShape = UnionShape.builder()

0 commit comments

Comments
 (0)