-
Notifications
You must be signed in to change notification settings - Fork 3
/
item.nunjucks
86 lines (77 loc) · 2.7 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
<li>
<strong>{{ item.key }}</strong>:
{% if not item.structuredValue %}
<em>
{%- if item.required -%}required {% endif -%}
(
{%- if item.enum -%}
{%- if item.enum.length === 1 -%}
{{ item.enum.join(', ') }}
{%- else -%}
one of {{ item.enum.join(', ') }}
{%- endif -%}
{%- else -%}
{%- if item.type === 'array' -%}
array of {% if isStandardType(item.items) %}{{ item.items }}{% else %}{{ item.items.displayName }}{% endif %}
{%- else -%}
{%- if isStandardType(item.type) -%}
{{ item.type }}
{%- else -%}
{{ item.type.displayName }}
{%- endif -%}
{%- 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.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 %}
{% markdown %}
{{ item.description }}
{% endmarkdown %}
{% if item.items and item.items.properties %}
{% if isStandardType(item.items) %}
<p><strong>Items</strong>: {{ item.items }}</p>
{% endif %}
{% if not isStandardType(item.items) %}
{% 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 or item.type.properties %}
<ul>
{% for item in item.properties %}
{% include "./item.nunjucks" %}
{% endfor %}
{% for item in item.type.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>