-
Notifications
You must be signed in to change notification settings - Fork 12
/
datatype.hbs
65 lines (60 loc) · 2.01 KB
/
datatype.hbs
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
{{!
When properties are renderered this partial renders the datatype of a property,
with a link to the type-definition (in case of a $ref).
Depending on the input, it renders an augmented data-type (e.g. "string[]"),
the 'format'-value (e.g. "date-time") and "enum"-values.
@param {boolean} discriminator true, this property is a swagger-discriminator (in which case enums are rendered as links)
}}
<span class="json-property-type">
{{~#if $ref}}
{{~>json-schema/reference $ref}}
{{~else}}
{{~json-schema--datatype .}}
{{~/if}}
</span>
{{~#if format}}
<span class="json-property-format">({{format}})</span>
{{~/if~}}
{{!-- Enum values --}}
{{~#if enum}}
<span class="json-property-enum" title="Possible values">, x ∈ {
{{#each enum}}
{{! Render enums in the descriminator as links to the appropriate definitions}}
{{#if ../discriminator}}
<span class="json-property-enum-item"><a href="#definition-{{.}}">{{.}}</a></span>
{{else}}
<span class="json-property-enum-item">{{.}}</span>
{{/if}}
{{#ifeq ../default .}}
(default)
{{/ifeq}}
{{#unless @last}},{{/unless}}
{{/each}}
}
</span>
{{~/if}}
{{!-- min- and max-values --}}
<span class="json-property-range" title="Value limits">
{{~json-schema--range . ~}}
</span>
{{!-- Default values (for non-enum types) --}}
{{~#unless enum}}
{{~#if default}}
<span class="json-property-default-value">{{~default}}</span>
{{/if}}
{{~/unless}}
{{#if minLength}}
<span class="json-property-range" title="String length limits">
{{#if maxLength}}
({{minLength}} to {{maxLength}} chars)
{{else}}
(at least {{minLength}} chars)
{{/if}}
</span>
{{else}}
{{#if maxLength}}
<span class="json-property-range" title="String length limits">
(up to {{maxLength}} chars)
</span>
{{/if}}
{{/if}}