github.com/6543-forks/go-swagger@v0.26.0/generator/templates/structfield.gotmpl (about) 1 {{ define "structfield" }} 2 {{- if not $.IsBaseType -}} 3 // {{ template "docstring" . }} 4 {{- template "propertyValidationDocString" .}} 5 {{- end}} 6 {{ pascalize .Name}} {{ template "schemaType" . }} ` 7 {{- $prop := . }} 8 {{- range $i, $structTag := $.StructTags }} 9 {{- if gt $i 0 }} {{ end }} 10 {{- template "structTag" dict "Tag" $structTag "Schema" $prop }} 11 {{- else }} 12 {{- template "structTag" dict "Tag" "json" "Schema" $prop }} 13 {{- end }} 14 {{- if .XMLName }} xml:"{{ .XMLName }}"{{ end }} 15 {{- if .CustomTag }} {{ .CustomTag }}{{ end }}` 16 {{ end }} 17 18 {{- define "structTag" }} 19 {{- .Tag }}:" 20 {{- if $.HasBaseType -}} 21 - 22 {{- else }} 23 {{- .Schema.OriginalName }} 24 {{- if and (not .Schema.Required) .Schema.IsEmptyOmitted }},omitempty{{ end }}{{ if .Schema.IsJSONString }},string{{ end }} 25 {{- end }}" 26 {{- end }} 27 {{- define "tuplefield" }} 28 {{- if not $.IsBaseType -}} 29 // {{ template "docstring" . }} 30 {{- template "propertyValidationDocString" .}} 31 {{ end }} 32 {{- pascalize .Name}} {{ template "schemaType" . }} `json:"-" 33 {{- if .CustomTag }} {{ .CustomTag }}{{ end }}` // custom serializer 34 {{ end }} 35 36 {{- define "structfieldIface" }} 37 {{- if not $.IsBaseType -}} 38 // {{ template "docstring" . }} 39 {{- template "propertyValidationDocString" .}} 40 {{- end }} 41 {{ pascalize .Name}}() {{ template "schemaType" . }} 42 Set{{ pascalize .Name}}({{ template "schemaType" . }}) 43 {{ end }} 44 {{ define "tuplefieldIface" }} 45 {{- if not $.IsBaseType -}} 46 // {{ template "docstring" . }} 47 {{- template "propertyValidationDocString" . }} 48 {{ end }} 49 {{- pascalize .Name}}() {{ template "schemaType" . }} 50 Set{{ pascalize .Name}}({{ template "schemaType" . }}) 51 {{ end }} 52 53 {{- define "privstructfield" }} 54 {{- camelize .Name}}Field {{ template "schemaType" . }} 55 {{ end }} 56 57 {{- define "privtuplefield" }} 58 {{- camelize .Name}}Field {{ template "schemaType" . }} 59 {{ end }}