in private/model/api/shape.go [498:608]
func (ref *ShapeRef) GoTags(toplevel bool, isRequired bool) string {
tags := append(ShapeTags{}, ref.CustomTags...)
var location string
if ref.Location != "" {
tags = append(tags, ShapeTag{"location", ref.Location})
location = ref.Location
} else if ref.Shape.Location != "" {
tags = append(tags, ShapeTag{"location", ref.Shape.Location})
location = ref.Shape.Location
} else if ref.IsEventHeader {
tags = append(tags, ShapeTag{"location", "header"})
location = "header"
}
if ref.LocationName != "" {
tags = append(tags, ShapeTag{"locationName", ref.LocationName})
} else if ref.Shape.LocationName != "" {
tags = append(tags, ShapeTag{"locationName", ref.Shape.LocationName})
} else if len(ref.Shape.EventFor) != 0 && ref.API.Metadata.Protocol == "rest-xml" {
// RPC JSON events need to have location name modeled for round trip testing.
tags = append(tags, ShapeTag{"locationName", ref.Shape.OrigShapeName})
}
if ref.QueryName != "" {
tags = append(tags, ShapeTag{"queryName", ref.QueryName})
}
if ref.Shape.MemberRef.LocationName != "" {
tags = append(tags, ShapeTag{"locationNameList", ref.Shape.MemberRef.LocationName})
}
if ref.Shape.KeyRef.LocationName != "" {
tags = append(tags, ShapeTag{"locationNameKey", ref.Shape.KeyRef.LocationName})
}
if ref.Shape.ValueRef.LocationName != "" {
tags = append(tags, ShapeTag{"locationNameValue", ref.Shape.ValueRef.LocationName})
}
if ref.Shape.Min > 0 {
tags = append(tags, ShapeTag{"min", fmt.Sprintf("%v", ref.Shape.Min)})
}
if ref.Deprecated || ref.Shape.Deprecated {
tags = append(tags, ShapeTag{"deprecated", "true"})
}
// All shapes have a type
tags = append(tags, ShapeTag{"type", ref.Shape.Type})
// embed the timestamp type for easier lookups
if ref.Shape.Type == "timestamp" {
if format := ref.GetTimestampFormat(); len(format) > 0 {
tags = append(tags, ShapeTag{
Key: "timestampFormat",
Val: format,
})
}
}
// Value that is encoded as a header that needs to be base64 encoded
if ref.SuppressedJSONValue && location == "header" {
tags = append(tags, ShapeTag{"suppressedJSONValue", "true"})
}
if ref.Shape.Flattened || ref.Flattened {
tags = append(tags, ShapeTag{"flattened", "true"})
}
if ref.XMLAttribute {
tags = append(tags, ShapeTag{"xmlAttribute", "true"})
}
if isRequired {
tags = append(tags, ShapeTag{"required", "true"})
}
if ref.Shape.IsEnum() {
tags = append(tags, ShapeTag{"enum", ref.ShapeName})
} else if ref.Shape.Type == "list" && ref.Shape.MemberRef.Shape.IsEnum() {
tags = append(tags, ShapeTag{"enum", ref.Shape.MemberRef.ShapeName})
}
if toplevel {
if name := ref.Shape.PayloadRefName(); len(name) > 0 {
tags = append(tags, ShapeTag{"payload", name})
}
if ref.Shape.UsedAsInput && !ref.Shape.HasPayloadMembers() && ref.API.Metadata.Protocol == "rest-json" {
tags = append(tags, ShapeTag{"nopayload", "true"})
}
}
if ref.XMLNamespace.Prefix != "" {
tags = append(tags, ShapeTag{"xmlPrefix", ref.XMLNamespace.Prefix})
} else if ref.Shape.XMLNamespace.Prefix != "" {
tags = append(tags, ShapeTag{"xmlPrefix", ref.Shape.XMLNamespace.Prefix})
}
if ref.XMLNamespace.URI != "" {
tags = append(tags, ShapeTag{"xmlURI", ref.XMLNamespace.URI})
} else if ref.Shape.XMLNamespace.URI != "" {
tags = append(tags, ShapeTag{"xmlURI", ref.Shape.XMLNamespace.URI})
}
if ref.IdempotencyToken || ref.Shape.IdempotencyToken {
tags = append(tags, ShapeTag{"idempotencyToken", "true"})
}
if ref.Ignore {
tags = append(tags, ShapeTag{"ignore", "true"})
}
if ref.Shape.IsSensitive() {
tags = append(tags, ShapeTag{"sensitive", "true"})
}
return fmt.Sprintf("`%s`", tags)
}