{{!--
  Original work Copyright (c) 2015 Nils Knappmeier
  https://github.com/bootprint/bootprint-json-schema

  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)
--}}
<div class="json-property-type">
  {{~#if $ref}}
    {{~>json-schema/reference .}}
  {{~else if items.$ref}}
    {{~>json-schema/reference .}}
  {{~else}}
    {{~schemaDatatype .}}
  {{~/if}}
  {{~#if x-nullable}}
    | null
  {{~/if}}
</div>
{{~#if format}}
  <span class="json-property-format">({{format}})</span>
{{~/if~}}

{{!-- Enum values --}}
{{~#if enum}}
  <span class="json-property-enum" title="Possible values">
    {{#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 if $ref}}
          {{~>json-schema/reference .}}
      {{~else}}
        <span class="json-property-enum-item{{#ifeq ../default .}} json-property-enum-default-value{{/ifeq}}">{{.}}</span>
      {{~/if}}{{#unless @last}},{{/unless}}
    {{/each}}
  </span>
{{~/if}}

{{!-- Min and Max values --}}
<span class="json-property-range" title="Value limits">
  {{~schemaRange . ~}}
</span>

{{!-- Default values --}}
{{~#ifneq default undefined}}
  <span class="json-property-default-value" title="Default value">{{~default}}</span>
{{/ifneq}}

{{#if minLength}}
  <span class="json-property-range" title="String length limits">
    {{#if maxLength}}
      {{#ifeq minLength maxLength}}
        ({{minLength}} chars)
      {{else}}
        ({{minLength}} to {{maxLength}} chars)
      {{/ifeq}}
    {{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}}
