api-generator-templates/Swift/macroses/class.utils.twig

30 lines
850 B
Twig

{% macro typeParameters(parameters, withConstraint) %}
{%- import '../macroses/common.utils.twig' as utils -%}
{%- if parameters is not empty -%}
<
{%- for typeParameter in parameters %}
{{- utils.formatValueType(typeParameter) -}}{{- withConstraint ? ": Codable" : ""-}}{%- if not (loop.last) %}, {% endif %}
{%- endfor -%}
>
{%- endif -%}
{% endmacro %}
{% macro classType(type) %}
{%- import _self as self -%}
{{- type.baseTypeName -}}{{- self.typeParameters(type.typeParameters, true) -}}
{% endmacro %}
{% macro parentClassType(parent, parentTypeParameters) %}
{%- import _self as self -%}
{%- if parent is not null %}
{{- parent.type.baseTypeName -}}
{%- else -%}
Codable
{%- endif -%}
{{- self.typeParameters(parentTypeParameters, false) -}}
{% endmacro %}