-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go.tmpl
47 lines (40 loc) · 1.15 KB
/
types.go.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{{define "types"}}
{{- $typeMap := .TypeMap -}}
{{- $types := .Types -}}
{{- $services := .Services -}}
// region Types
{{- if $types -}}
{{range $_i, $type := $types -}}
{{if isEnumType $type }}
@JsonClass(generateAdapter = true)
enum class {{$type.Name}} {
{{- range $_, $field := $type.Fields}}
@Json(name = "{{$field.Name}}")
{{toUpper (snakeCase $field.Name)}},
{{- end}}
@Json(name = "UNKNOWN_DEFAULT")
UNKNOWN_DEFAULT,
}
{{end -}}
{{- if isStructType $type }}
@JsonClass(generateAdapter = true)
data class {{$type.Name}}(
{{- range $_, $field := $type.Fields}}
{{- $isExportable := true -}}
{{- range $meta := $field.Meta -}}
{{- if exists $meta "json" -}}
{{- if eq (printf "%v" (get $meta "json")) "-" -}}
{{- $isExportable = false}}
{{- end -}}
{{- end -}}
{{- end }}
{{- if $isExportable }}
@Json(name = "{{template "codingKey" dict "Field" .}}") val {{template "fieldName" dict "Field" .}}: {{template "type" dict "Type" $field.Type "TypeMap" $typeMap}}{{if .Optional}}?{{end}},
{{- end -}}
{{- end}}
)
{{end -}}
{{end -}}
{{end -}}
// endregion
{{end}}