diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/TypeConversionCodegen.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/TypeConversionCodegen.java index 84ed22402..2b9b074b7 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/TypeConversionCodegen.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/TypeConversionCodegen.java @@ -255,6 +255,30 @@ protected Set findInitialShapeIdsToConvert() { .map(unionShape -> unionShape.getId()) .collect(Collectors.toSet()); + // Collect map shapes + final Set mapShapes = model + .getMapShapes() + .stream() + .map(Shape::getId) + .filter(this::isInServiceNamespace) + .collect(Collectors.toSet()); + + // Collect list shapes + final Set listShapes = model + .getListShapes() + .stream() + .map(Shape::getId) + .filter(this::isInServiceNamespace) + .collect(Collectors.toSet()); + + // Collect structure shapes + final Set structureShapes = model + .getStructureShapes() + .stream() + .map(Shape::getId) + .filter(this::isInServiceNamespace) + .collect(Collectors.toSet()); + // TODO add smithy v2 Enums // Collect enum shapes final Set enumShapes = model @@ -277,6 +301,9 @@ protected Set findInitialShapeIdsToConvert() { orderedSet.addAll(unionShapes); orderedSet.addAll(errorStructures); orderedSet.addAll(enumShapes); + orderedSet.addAll(mapShapes); + orderedSet.addAll(listShapes); + orderedSet.addAll(structureShapes); return orderedSet; } @@ -2014,9 +2041,9 @@ protected TypeConverter buildConverterFromMethodBodies( // This is more controlled than exposing // the NativeWrapper and the Dafny wrapped type. final boolean isDependantModuleType = - ModelUtils.isReferenceDependantModuleType( + ModelUtils.isDependantModuleType( shape, - nameResolver.namespaceForService() + nameResolver.serviceShape.getId().getNamespace() ); // Make all converters public, because most need to be and it's not worth the trouble to hide the remaining few. diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/utils/ModelUtils.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/utils/ModelUtils.java index 0b8469b54..d212461a3 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/utils/ModelUtils.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/utils/ModelUtils.java @@ -557,7 +557,19 @@ public static Boolean isReferenceDependantModuleType( final String namespace ) { if (shape.hasTrait(ReferenceTrait.class)) { - return !namespace.equalsIgnoreCase(shape.getId().getNamespace()); + return isDependantModuleType(shape, namespace); + } else { + return false; + } + } + + public static Boolean isDependantModuleType( + final Shape shape, + final String namespace + ) { + final String shapeNamespace = shape.getId().getNamespace(); + if (!shapeNamespace.toLowerCase().startsWith("smithy.api") && !namespace.equalsIgnoreCase(shapeNamespace)) { + return true; } else { return false; }