diff --git a/generate/property.go b/generate/property.go index 9e039cd8fc..c70e190b10 100644 --- a/generate/property.go +++ b/generate/property.go @@ -186,6 +186,22 @@ func (p *Property) UnmarshalJSON(data []byte) error { fmt.Printf("Warning: auto-fixing property that has a map of lists, with no list item type. Assuming the lists contain strings ([]string) for %s\n", p.Documentation) } + if p.Type == "List" && p.ItemType == "List" && p.PrimitiveItemType == "" { + p.PrimitiveItemType = "String" + // WORKAROUND: On 2022-06-01, AWS::Rekognition::StreamProcessor published a property + // called 'PolygonRegionsOfInterest' which has Type: List, and ItemType: List, with no PrimitiveItemType. + // This workaround assumes that it should be a list, containing a list of strings. + fmt.Printf("Warning: auto-fixing property that has a list of lists, with no list item type. Assuming the lists contain strings ([]string) for %s\n", p.Documentation) + } + + if p.Type == "Tag" && p.ItemType == "" { + p.ItemType = "Tag" + // WORKAROUND: On 2022-06-01, AWS::Rekognition::ModelPackage published a property + // called 'Tag' with no ItemType. + // This workaround assumes that it should be a tag. + fmt.Printf("Warning: auto-fixing property that is marked as tag but has no tag ItemType for %s\n", p.Documentation) + } + return nil } @@ -249,6 +265,13 @@ func (p Property) IsCustomType() bool { // within a Go struct. For example, []string or map[string]AWSLambdaFunction_VpcConfig func (p Property) GoType(typename string, basename string, name string) string { + if p.Type == "Tag" && p.ItemType == "Tag" { + // WORKAROUND: On 2022-06-01, AWS::Rekognition::ModelPackage published a property + // called 'Tag' with no ItemType. + // This workaround assumes that it should be a tag. + return "tags.Tag" + } + if p.ItemType == "Tag" { return "[]tags.Tag" } @@ -261,6 +284,13 @@ func (p Property) GoType(typename string, basename string, name string) string { return "map[string][]string" } + if p.Type == "List" && p.ItemType == "List" && p.PrimitiveItemType == "String" { + // WORKAROUND: On 2022-06-01, AWS::Rekognition::StreamProcessor published a property + // called 'PolygonRegionsOfInterest' which has Type: List, and ItemType: List, with no PrimitiveItemType. + // This workaround assumes that it should be a list, containing a list of strings. + return "[][]string" + } + if p.IsPolymorphic() { generatePolymorphicProperty(typename, basename+"_"+name, p) @@ -285,7 +315,6 @@ func (p Property) GoType(typename string, basename string, name string) string { } return "[]" + basename + "_" + p.ItemType - } if p.IsCustomType() { diff --git a/generate/templates/schema-property.template b/generate/templates/schema-property.template index 428a8bef00..b5c4bdb139 100644 --- a/generate/templates/schema-property.template +++ b/generate/templates/schema-property.template @@ -122,5 +122,9 @@ {{end}} {{end}} + {{ if and (eq .Property.Type "Tag") (eq .Property.ItemType "Tag") }} + "$ref": "#/definitions/Tag" + {{end}} + {{end}} } diff --git a/goformation_test.go b/goformation_test.go index 878c7a35cf..359220f3c0 100644 --- a/goformation_test.go +++ b/goformation_test.go @@ -1358,7 +1358,7 @@ var _ = Describe("Goformation", func() { template := cloudformation.NewTemplate() template.Resources["Vpc"] = &ec2.VPC{ - CidrBlock: "192.168.0.0/20", + CidrBlock: cloudformation.String("192.168.0.0/20"), } template.Outputs["VpcId"] = cloudformation.Output{