api-generator-templates/Web-documentation/blocks/method-body.html.twig

180 lines
7.1 KiB
Twig

<h2 class="subtitle" id="{{ method.anchorPath }}">{{ method.description }}</h2>
<h3>Метод</h3>
<p class="sub-header">{{ method.type }} {{ method.url }}</p>
<h3>Параметры</h3>
{% if (method.requestHeaders is empty) and (method.requestQueryParams is empty) and (method.requestFields is empty)%}
<p class="sub-header">Параметры отсутствуют</p>
{% else %}
{% if method.requestHeaders is not empty %}
<p>Заголовки:</p>
<div class="table example-response-expanded">
<div class="part-table">
<div class="row-header">
<div>Название заголовка</div>
<div>Тип</div>
<div class="text-centered">Описание</div>
<div>Обязательность</div>
</div>
{% for field in method.requestHeaders -%}
{%- include 'field-row.html.twig' with {
field: field,
objectsLinks: objectsLinks,
useAnchors: useAnchors
} %}
{%- endfor %}
</div>
</div>
{% endif %}
{% if method.requestQueryParams is not empty %}
<p>Query-параметры:</p>
<div class="table example-response-expanded">
<div class="part-table">
<div class="row-header">
<div>Название параметра</div>
<div>Тип</div>
<div class="text-centered">Описание</div>
<div>Обязательность</div>
</div>
{% for field in method.requestQueryParams -%}
{%- include 'field-row.html.twig' with {
field: field,
objectsLinks: objectsLinks,
useAnchors: useAnchors
} %}
{%- endfor %}
</div>
</div>
{% endif %}
{% if method.requestFields is not empty %}
<p>Тело запроса, объект следующей структуры:</p>
<div class="table example-response-expanded">
<div class="part-table">
<div class="row-header">
<div>Название поля</div>
<div>Тип</div>
<div class="text-centered">Описание</div>
<div>Обязательность</div>
</div>
{% for field in method.requestFields -%}
{%- include 'field-row.html.twig' with {
field: field,
objectsLinks: objectsLinks,
useAnchors: useAnchors
} %}
{%- endfor %}
</div>
{% if default(showSandbox, true) %}
<div class="part-block">
<a class="show-example-response">Пример запроса</a>
</div>
<div class="part-example-response">
<div class="inputs">
{% for field in method.requestFields -%}
<label>
{{ field.jsonName }}<br>
{% if field.type.values is not empty -%}
<div class="styled-select">
<select data-name="{{ field.jsonName }}">
{% for value in field.type.values %}
<option>{{ value.value }}</option>
{% endfor %}
</select>
{%- if field.optional or field.nullable -%}
{% include 'sandbox-optional-nullable.html.twig' with { field: field } %}
{% endif %}
</div>
{%- else %}
{%- if field.optional or field.nullable -%}
<div class="styled-input">
<input type="text" data-name="{{ field.jsonName }}">
{% include 'sandbox-optional-nullable.html.twig' with { field: field } %}
</div>
{%- else %}
<input type="text" data-name="{{ field.jsonName }}">
{% endif %}
{%- endif %}
</label>
{% endfor %}
<button class="btn run-btn" data-server-method-path="{{ serverMethodPath }}">
Выполнить
</button>
</div>
<div class="text-response"></div>
</div>
{% endif %}
</div>
{% endif %}
{% endif %}
<h3>Возможные ошибки</h3>
{% if (method.errorsEnumeration is empty) or (method.errorsEnumeration.allowedValues is empty) %}
<p class="sub-header">Описание ошибок отсутствует</p>
{% else %}
{% for value in method.errorsEnumeration.values -%}
{%- if value.value in method.errorsEnumeration.allowedValues %}
<p class="sub-header">#Код {{ value.value }}{{ value.description }}</p>
{%- endif -%}
{%- endfor %}
{% endif %}
<h3>Результат</h3>
{% if (method.responseFields is empty) and (method.responseHeaders is empty) %}
<p class="sub-header">Результат отсутствует</p>
{% else %}
{% if method.booleanResponseDescription is not empty %}
<p>{{ method.booleanResponseDescription }}. Тип Boolean.</p>
{% elseif method.responseFields is not empty %}
<p>Объект следующей структуры:</p>
<div class="table example-response-expanded">
<div class="part-table">
<div class="row-header">
<div>Название поля</div>
<div>Тип</div>
<div class="text-centered">Описание</div>
<div>Обязательность</div>
</div>
{% for field in method.responseFields -%}
{%- include 'field-row.html.twig' with {
field: field,
objectsLinks: objectsLinks,
useAnchors: useAnchors
} %}
{%- endfor %}
</div>
</div>
{% endif %}
{% if method.responseHeaders is not empty %}
<p>Заголовки:</p>
<div class="table example-response-expanded">
<div class="part-table">
<div class="row-header">
<div>Название заголовка</div>
<div>Тип</div>
<div class="text-centered">Описание</div>
<div>Обязательность</div>
</div>
{% for field in method.responseHeaders -%}
{%- include 'field-row.html.twig' with {
field: field,
objectsLinks: objectsLinks,
useAnchors: useAnchors
} %}
{%- endfor %}
</div>
</div>
{% endif %}
{% endif %}
{%- include 'comment.html.twig' with { comment: method.comment } %}