forked from layer5io/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema-properties.html
More file actions
35 lines (30 loc) · 1.18 KB
/
schema-properties.html
File metadata and controls
35 lines (30 loc) · 1.18 KB
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
{{ $schema := .schema | default . }}
{{ $schemas := .schemas | default dict }}
{{ $source := partial "rest-apis/schema-source.html" (dict "schema" $schema "schemas" $schemas) | transform.Unmarshal (dict "format" "json") }}
{{ $label := "Schema fields" }}
{{ $result := dict "label" $label "rows" (slice) }}
{{ if and (not (index $source "properties")) (eq (index $source "type") "array") (index $source "items") (index (index $source "items") "properties") }}
{{ $source = index $source "items" }}
{{ $label = "Array item fields" }}
{{ $result = dict "label" $label "rows" (slice) }}
{{ end }}
{{ $properties := index $source "properties" }}
{{ if $properties }}
{{ $required := index $source "required" | default (slice) }}
{{ $rows := slice }}
{{ range $name, $property := $properties }}
{{ $order := 9999 }}
{{ with index $property "x-order" }}
{{ $order = . }}
{{ end }}
{{ $rows = $rows | append (dict
"name" $name
"order" $order
"schema" $property
"required" (in $required $name)
) }}
{{ end }}
{{ $rows = sort (sort $rows "name") "order" }}
{{ $result = dict "label" $label "rows" $rows }}
{{ end }}
{{- $result | jsonify -}}