-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.nunjucks
100 lines (88 loc) · 3.25 KB
/
item.nunjucks
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<li>
<strong>{{ item.key }}</strong>{% if item.type !== nil %}:
{% if not item.structuredValue %}
<em>
{%- if item.required -%}<span class="required">required </span>{%- endif -%}
(
{%- if item.enum -%}
{%- if item.enum.length === 1 -%}
{{ item.enum.join(', ') }}
{%- else -%}
one of {{ item.enum.join(', ') }}
{%- endif -%}
{%- else -%}
{%- if item.type === 'array' and item.items -%}
array of {{ item.items.originalType | d(item.items.type) }}
{%- elif item.type === 'union' and item.anyOf.length -%}
union of
{% for alt in item.anyOf -%}
{{ alt.originalType | d(alt.displayName) | d(alt.type) }}
{%- if not loop.last %} or {% endif -%}
{%- endfor -%}
{%- else -%}
{{ item.type }}
{%- endif -%}
{%- endif -%}
{%- if item.default or item.default == 0 or item.default == false %} - default: {{ item.default }}{%- endif -%}
{%- if item.repeat %} - repeat: {{ item.repeat }}{%- endif -%}
{%- if item.type == 'string' -%}
{%- if item.minLength or item.minLength == 0 %} - minLength: {{ item.minLength }}{%- endif -%}
{%- if item.maxLength or item.maxLength == 0 %} - maxLength: {{ item.maxLength }}{%- endif -%}
{%- else -%}
{%- if item.minItems or item.minItems == 0 %} - minItems: {{ item.minItems }}{%- endif -%}
{%- if item.maxItems or item.maxItems == 0 %} - maxItems: {{ item.maxItems }}{%- endif -%}
{%- if item.minimum or item.minimum == 0 %} - minimum: {{ item.minimum }}{%- endif -%}
{%- if item.maximum or item.maximum == 0 %} - maximum: {{ item.maximum }}{%- endif -%}
{%- endif -%}
{%- if item.pattern %} - pattern: {{ item.pattern }}{%- endif -%}
)
</em>
{% endif %}
{% endif %}
{% markdown %}
{{ item.description }}
{% endmarkdown %}
{% if item.annotations.length %}
<h3>Annotations</h3>
<ul>
{% for item in item.annotations %}
{% include "./item.nunjucks" %}
{% endfor %}
</ul>
{% endif %}
{% if item.items and item.items.properties %}
{% if isStandardType(item.items) %}
<p><strong>Items</strong>: {{ item.items }}</p>
{% endif %}
{% if not isStandardType(item.items) %}
<p><strong>Items</strong>: {{ item.items.displayName }}</p>
{% if item.items.properties or item.items.examples.length %}
<div class="items">
{% if item.items.properties %}
<ul>
{% for item in item.items.properties %}
{% include "./item.nunjucks" %}
{% endfor %}
</ul>
{% endif %}
{# Sub-item Examples #}
{% set parent = item.items %}
{% include "./examples.nunjucks" %}
</div>
{% endif %}
{% endif %}
{% endif %}
{% if item.properties %}
<ul>
{% for item in item.properties %}
{% include "./item.nunjucks" %}
{% endfor %}
</ul>
{% endif %}
{# Item Examples #}
{% set parent = item %}
{% include "./examples.nunjucks" %}
{% if item.structuredValue %}
<pre><code>{{ item.structuredValue | dump }}</code></pre>
{% endif %}
</li>