<commit_before><h1><%= @info.app.name.titleize %> REST API Reference documentation</h1>

<h2>Routes index</h2>

<ul>
<% @info.routes.sort.each do |route| %>
  <li><%= link_to route.spec, doc_path(anchor: route.anchor) %></li>
<% end %>
</ul>

<h2>Table of content</h2>

<ul>
<% @info.toc.keys.sort.each do |controller_name| %>
  <li>
    <%= controller_name.titleize %>
    <ul>
      <% @info.toc[controller_name].keys.sort.each do |action_name| %>
        <% route = @info.toc[controller_name][action_name] %>
        <li><%= link_to action_name.titleize, doc_path(anchor: route.anchor) %></li>
      <% end %>
    </ul>
  </li>
<% end %>
</ul>

<h2>Schema</h2>

<% @info.toc.keys.sort.each do |controller_name| %>
<% @info.toc[controller_name].keys.sort.each do |action_name| %>

<% route = @info.toc[controller_name][action_name] %>
<% schema = route.schema %>

<h3>
<%= content_tag :a, "#{controller_name.titleize} > #{action_name.titleize}", id: route.anchor %>
</h3>

<h4>Route</h4>
<%= route.spec %>

<% if schema.request_schema %>
  <h4>Request schema</h4>

  <% if schema.request_schema.headers %>
    <h5>Headers schema</h4>
    <%= highlight_json_schema schema.request_schema.headers.to_h %>
  <% else %>
    No headers schema.
  <% end %>

  <% [ :path, :query, :body ].each do |name| %>
    <h5><%= name.capitalize %> parameters</h5>
    <% if schema.request_schema.send("#{name}_parameters").documented_properties.empty? %>
      No <%= name %> parameters schema.
    <% else %>
      <%= highlight_json_schema schema.request_schema.send("#{name}_parameters").to_h %>
    <% end %>
  <% end %>

<% end %>

<% unless schema.response_schemas.empty? %>
<h4>Response schema</h4>
  <% schema.response_schemas.each do |status, response_schema| %>
    <h5><%= response_schema.status %> [<%= response_schema.http_status %>]</h5>
    <% if response_schema.headers %>
      <h4>Headers schema</h4>
      <%= highlight_json_schema response_schema.headers.to_h %>
    <% else %>
      No headers schema.
    <% end %>
    <% if response_schema.body %>
      <h4>Body schema</h4>
      <%= highlight_json_schema response_schema.body.to_h %>
    <% else %>
      No body schema.
    <% end %>
  <% end %>
<% end %>

<% end %>
<% end %><commit_msg>Indent.<commit_after><h1><%= @info.app.name.titleize %> REST API Reference documentation</h1>

<h2>Routes index</h2>

<ul>
<% @info.routes.sort.each do |route| %>
  <li><%= link_to route.spec, doc_path(anchor: route.anchor) %></li>
<% end %>
</ul>

<h2>Table of content</h2>

<ul>
<% @info.toc.keys.sort.each do |controller_name| %>
  <li>
    <%= controller_name.titleize %>
    <ul>
      <% @info.toc[controller_name].keys.sort.each do |action_name| %>
        <% route = @info.toc[controller_name][action_name] %>
        <li><%= link_to action_name.titleize, doc_path(anchor: route.anchor) %></li>
      <% end %>
    </ul>
  </li>
<% end %>
</ul>

<h2>Schema</h2>

<% @info.toc.keys.sort.each do |controller_name| %>
  <% @info.toc[controller_name].keys.sort.each do |action_name| %>

    <% route = @info.toc[controller_name][action_name] %>
    <% schema = route.schema %>

    <h3>
    <%= content_tag :a, "#{controller_name.titleize} > #{action_name.titleize}", id: route.anchor %>
    </h3>

    <h4>Route</h4>
    <%= route.spec %>

    <% if schema.request_schema %>
      <h4>Request schema</h4>

      <% if schema.request_schema.headers %>
        <h5>Headers schema</h4>
        <%= highlight_json_schema schema.request_schema.headers.to_h %>
      <% else %>
        No headers schema.
      <% end %>

      <% [ :path, :query, :body ].each do |name| %>
        <h5><%= name.capitalize %> parameters</h5>
        <% if schema.request_schema.send("#{name}_parameters").documented_properties.empty? %>
          No <%= name %> parameters schema.
        <% else %>
          <%= highlight_json_schema schema.request_schema.send("#{name}_parameters").to_h %>
        <% end %>
      <% end %>

    <% end %>

    <% unless schema.response_schemas.empty? %>
      <h4>Response schema</h4>
      <% schema.response_schemas.each do |status, response_schema| %>
        <h5><%= response_schema.status %> [<%= response_schema.http_status %>]</h5>
        <% if response_schema.headers %>
          <h4>Headers schema</h4>
          <%= highlight_json_schema response_schema.headers.to_h %>
        <% else %>
          No headers schema.
        <% end %>
        <% if response_schema.body %>
          <h4>Body schema</h4>
          <%= highlight_json_schema response_schema.body.to_h %>
        <% else %>
          No body schema.
        <% end %>
      <% end %>
    <% end %>

  <% end %>
<% end %>
{'fraction_non_alphanumeric': 0.19275300171526585, 'fraction_numerical': 0.011149228130360206, 'mean_word_length': 2.9940068493150687, 'pattern_counts': {'":': 0, '<': 173, '<?xml version=': 0, '>': 175, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '242857', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1604, 'n_words': 282}