@@ -78,6 +78,9 @@ type Shape struct {
7878
7979 OrigShapeName string `json:"-"`
8080
81+ UsedInMap bool
82+ UsedInList bool
83+
8184 // Defines if the shape is a placeholder and should not be used directly
8285 Placeholder bool
8386
@@ -192,6 +195,17 @@ func (s *Shape) GoStructValueType(name string, ref *ShapeRef) string {
192195 return v
193196}
194197
198+ // IsRefPayload will return whether or a not the field name is a payload.
199+ func (s * Shape ) IsRefPayload (name string ) bool {
200+ return s .Payload == name
201+ }
202+
203+ // IsRefPayloadReader will whether or not the shape ref is a payload and that it is
204+ // a streaming reference.
205+ func (s * Shape ) IsRefPayloadReader (name string , ref * ShapeRef ) bool {
206+ return (ref .Streaming || ref .Shape .Streaming ) && s .IsRefPayload (name )
207+ }
208+
195209// GoStructType returns the type of a struct field based on the API
196210// model definition.
197211func (s * Shape ) GoStructType (name string , ref * ShapeRef ) string {
@@ -545,7 +559,9 @@ func (s *Shape) NestedShape() *Shape {
545559}
546560
547561var structShapeTmpl = template .Must (template .New ("StructShape" ).Funcs (template.FuncMap {
548- "GetCrosslinkURL" : GetCrosslinkURL ,
562+ "GetCrosslinkURL" : GetCrosslinkURL ,
563+ "MarshalShapeGoCode" : MarshalShapeGoCode ,
564+ "UnmarshalShapeGoCode" : UnmarshalShapeGoCode ,
549565}).Parse (`
550566{{ .Docstring }}
551567{{ if ne $.OrigShapeName "" -}}
@@ -630,9 +646,18 @@ func (s *{{ $builderShapeName }}) get{{ $name }}() (v {{ $context.GoStructValueT
630646
631647{{ end }}
632648{{ end }}
649+
650+ {{ if not $.API.NoGenMarshalers -}}
651+ {{ MarshalShapeGoCode $ }}
652+ {{- end }}
653+ {{ if not $.API.NoGenUnmarshalers -}}
654+ {{ UnmarshalShapeGoCode $ }}
655+ {{- end }}
633656` ))
634657
635- var enumShapeTmpl = template .Must (template .New ("EnumShape" ).Parse (`
658+ var enumShapeTmpl = template .Must (template .New ("EnumShape" ).Funcs (template.FuncMap {
659+ "MarshalEnumGoCode" : marshalEnumGoCode ,
660+ }).Parse (`
636661{{ .Docstring }}
637662type {{ $.EnumType }} string
638663
@@ -644,6 +669,8 @@ const (
644669 {{ $name }} {{ $.EnumType }} = "{{ $elem }}"
645670 {{ end -}}
646671)
672+
673+ {{ MarshalEnumGoCode $ }}
647674` ))
648675
649676// GoCode returns the rendered Go code for the Shape.
0 commit comments