-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtype.go.tmpl
More file actions
35 lines (33 loc) · 1008 Bytes
/
type.go.tmpl
File metadata and controls
35 lines (33 loc) · 1008 Bytes
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
{{- define "type" -}}
{{- /* Required args */}}
{{- $typeMap := .TypeMap -}}
{{- $type := .Type -}}
{{$type.Name}}:
{{- if isEnumType $type}}
type: string
{{if gt (len $type.Fields) 0 -}}
description: Represented as {{$type.Type}} on the server side
{{end -}}
enum:
{{- range $type.Fields}}
- {{.Name}}
{{- end -}}
{{- else if isAliasType $type}}
{{ template "fieldType" dict "Type" $type.Type "TypeMap" $typeMap "Indent" " " }}
{{else}}
type: object
{{- if gt (len $type.Fields) 0}}
{{- if gt (len $type.RequiredFields) 0}}
required:
{{- range $i, $field := $type.RequiredFields }}
- {{$field.Name}}
{{- end }}
{{- end }}
properties:
{{- end -}}
{{- range $i, $field := $type.Fields }}
{{$field.Name -}}:
{{ template "fieldType" dict "Type" $field.Type "TypeMap" $typeMap "Indent" " " }}
{{- end -}}
{{- end -}}
{{- end -}}