{% extends "v1/docs/skeleton.html" %}

{% load static %}

{% block title %}
Kubefacets - APIs
{% endblock %}

{% block head_before %} {% endblock %}

{% block head %}
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
{% endblock %}

{% block body %}
<script>
function getCookie(name) {
    let cookieValue = "";
    if (document.cookie && document.cookie !== "") {
        const cookies = document.cookie.split(";");
        for (let i = 0; i < cookies.length; i++) {
            const cookie = cookies[i].trim();
            // Does this cookie string begin with the name we want?
            if (cookie.substring(0, name.length + 1) === name + "=") {
                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                break;
            }
        }
    }
    return cookieValue;
}
window.addEventListener('DOMContentLoaded', (event) => {
    const rapidocEl = document.querySelector('rapi-doc');
    rapidocEl.addEventListener('before-try', (e) => {
        e.detail.request.headers.append('X-CSRFToken', getCookie("csrftoken"));
    });
});
</script>


<rapi-doc 
      show-info = "true"
      spec-url="{{ path }}"
      show-header = "false" 
      theme = "light"
      render-style="focused"
      allow-try="true" 
      regular-font="Open Sans"
      mono-font = "Roboto Mono"
    > 
    <div class="d-flex justify-content-end">
        {{ user.get_username}}
    </div>
</rapi-doc>
{% endblock %}