Add custom API documentation page at /api/doc
- ApiDocController: serves doc page + JSON spec at /api/doc/spec.json
- Custom brutal design template matching site aesthetic
- 6 sections: Auth, Events, Orders, Scanner, Billets/Stock, Export
- Each endpoint shows: method badge (colored), path, summary, description
- Auth headers: ETicket-Email + ETicket-JWT displayed prominently
- Parameters table with type, required, default values
- Request body with JSON example and field types
- Response body with JSON example
- Status codes with colored badges (green/yellow/red)
- Rate limiting section with X-RateLimit headers
- Table of contents with anchor links
- Standard response format: {success, data, error}
- No external dependencies (no Swagger/NelmioApiDoc)
- Fully customizable via PHP spec array
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 18:51:46 +01:00
{% extends 'base.html.twig' %}
{% block title %} API Documentation - E-Ticket {% endblock %}
{% block description %} Documentation de l'API E-Ticket pour les organisateurs et l'application scanner. {% endblock %}
{% block body %}
<div class="bg-[#fbfbfb] min-h-screen">
<section class="relative bg-gray-900 text-white px-4 pt-20 pb-16 border-b-8 border-[#fabf04]">
<div class="absolute inset-0 opacity-[0.05] pointer-events-none select-none overflow-hidden">
<span class="text-[8rem] md:text-[16rem] font-black uppercase leading-none block -rotate-12 translate-y-10 font-mono"> { API}</span>
</div>
<div class="max-w-5xl mx-auto relative z-10">
<div class="inline-block px-3 py-1 border-2 border-[#fabf04] bg-[#fabf04] text-gray-900 text-[10px] font-black uppercase tracking-widest mb-4">v1.0</div>
<h1 class="text-4xl md:text-6xl font-black uppercase tracking-tighter leading-[0.85] mb-4">API E-Ticket</h1>
<p class="text-lg font-bold text-gray-300 max-w-2xl">Documentation complete de l'API REST pour les organisateurs. Gestion des evenements, commandes, billets et scan.</p>
<div class="mt-8 flex flex-wrap gap-4">
<div class="border-2 border-gray-700 bg-gray-800 px-4 py-3">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1">Format</p>
<p class="font-mono font-bold text-sm">JSON (application/json)</p>
</div>
<div class="border-2 border-gray-700 bg-gray-800 px-4 py-3">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-500 mb-1">Authentification</p>
<p class="font-mono font-bold text-sm">ETicket-Email + ETicket-JWT</p>
</div>
</div>
2026-03-23 18:56:10 +01:00
2026-03-23 18:58:17 +01:00
<div class="mt-8 grid grid-cols-1 sm:grid-cols-2 gap-4">
{% for env in environments %}
<div class="border-2 border-gray-700 bg-gray-800 p-4">
<div class="flex items-center gap-2 mb-2">
<span class=" {{ env .badgeColor }} text-white text-[10px] font-black uppercase tracking-widest px-2 py-0.5"> {{ env .badge }} </span>
<span class="font-black text-sm uppercase tracking-tighter"> {{ env .name }} </span>
</div>
<p class="font-mono font-bold text-sm text-[#fabf04] mb-2">https://ticket.e-cosplay.fr {{ env .baseUrl }} </p>
<p class="text-xs font-bold text-gray-400"> {{ env .description }} </p>
</div>
{% endfor %}
</div>
<p class="mt-4 text-xs font-bold text-gray-400">L'authentification (<span class="font-mono">/api/auth/login</span>) est commune aux deux environnements : <span class="font-mono text-[#fabf04]">https://ticket.e-cosplay.fr/api/auth/login</span></p>
2026-03-23 18:56:10 +01:00
<div class="mt-8">
<a href=" {{ path ( 'app_api_doc_json' ) }} " target="_blank" class="inline-flex items-center gap-2 px-6 py-3 border-4 border-[#fabf04] bg-[#fabf04] text-gray-900 font-black uppercase text-xs tracking-widest shadow-[6px_6px_0px_rgba(0,0,0,1)] hover:shadow-[8px_8px_0px_rgba(0,0,0,1)] hover:translate-y-[-2px] transition-all">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/></svg>
Voir la spec JSON
</a>
</div>
Add custom API documentation page at /api/doc
- ApiDocController: serves doc page + JSON spec at /api/doc/spec.json
- Custom brutal design template matching site aesthetic
- 6 sections: Auth, Events, Orders, Scanner, Billets/Stock, Export
- Each endpoint shows: method badge (colored), path, summary, description
- Auth headers: ETicket-Email + ETicket-JWT displayed prominently
- Parameters table with type, required, default values
- Request body with JSON example and field types
- Response body with JSON example
- Status codes with colored badges (green/yellow/red)
- Rate limiting section with X-RateLimit headers
- Table of contents with anchor links
- Standard response format: {success, data, error}
- No external dependencies (no Swagger/NelmioApiDoc)
- Fully customizable via PHP spec array
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 18:51:46 +01:00
</div>
</section>
<div class="max-w-5xl mx-auto px-4 py-12">
<nav class="card-brutal overflow-hidden mb-12">
<div class="bg-gray-900 text-white px-6 py-3">
<h2 class="text-[10px] font-black uppercase tracking-widest">Sommaire</h2>
</div>
<div class="p-6">
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3">
{% for section in sections %}
<a href="#section- {{ loop .index }} " class="border-2 border-gray-900 px-4 py-3 font-black uppercase text-xs tracking-widest hover:bg-gray-900 hover:text-white transition-all">
{{ section .name }}
<span class="text-gray-400 ml-1">( {{ section .endpoints | length }} )</span>
</a>
{% endfor %}
</div>
</div>
</nav>
<div class="card-brutal overflow-hidden mb-12 border-[#fabf04]" style="border-color: #fabf04;">
<div class="bg-[#fabf04] text-gray-900 px-6 py-3">
<h2 class="text-[10px] font-black uppercase tracking-widest">Authentification</h2>
</div>
<div class="p-6">
<p class="font-bold text-sm text-gray-700 mb-4">Toutes les routes (sauf <span class="font-mono bg-gray-100 px-1">/api/auth/login</span>) necessitent deux headers :</p>
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead>
<tr class="bg-gray-900 text-white">
<th class="px-4 py-2 text-left font-black uppercase text-[10px] tracking-widest">Header</th>
<th class="px-4 py-2 text-left font-black uppercase text-[10px] tracking-widest">Description</th>
<th class="px-4 py-2 text-left font-black uppercase text-[10px] tracking-widest">Exemple</th>
</tr>
</thead>
<tbody>
<tr class="border-b border-gray-200">
<td class="px-4 py-3 font-mono font-bold text-indigo-600">ETicket-Email</td>
<td class="px-4 py-3 font-bold text-gray-600">Email de l'organisateur</td>
<td class="px-4 py-3 font-mono text-xs text-gray-500">orga@example.com</td>
</tr>
<tr>
<td class="px-4 py-3 font-mono font-bold text-indigo-600">ETicket-JWT</td>
<td class="px-4 py-3 font-bold text-gray-600">Token JWT (obtenu via /api/auth/login)</td>
<td class="px-4 py-3 font-mono text-xs text-gray-500">eyJhbGciOiJIUzI1NiIs...</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-6 border-2 border-gray-900 bg-gray-900 text-white p-4">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-500 mb-2">Reponse standard</p>
<pre class="font-mono text-xs leading-relaxed overflow-x-auto"><code> {
"success": true,
"data": { ... },
"error": null
}</code></pre>
</div>
<div class="mt-4 border-2 border-red-800 bg-red-50 p-4">
<p class="text-[10px] font-black uppercase tracking-widest text-red-800 mb-2">Reponse erreur</p>
<pre class="font-mono text-xs leading-relaxed overflow-x-auto text-red-900"><code> {
"success": false,
"data": null,
"error": "Message d'erreur explicite"
}</code></pre>
</div>
</div>
</div>
{% for section in sections %}
<div id="section- {{ loop .index }} " class="mb-12 scroll-mt-8">
<div class="flex items-center gap-4 mb-6">
<h2 class="text-2xl font-black uppercase tracking-tighter"> {{ section .name }} </h2>
<div class="flex-1 border-t-3 border-gray-900"></div>
</div>
{% if section .description %}
<p class="font-bold text-sm text-gray-500 mb-6"> {{ section .description }} </p>
{% endif %}
{% for endpoint in section .endpoints %}
<div class="card-brutal overflow-hidden mb-6">
<div class="flex items-stretch">
{% set method_colors = {
'GET': 'bg-green-600',
'POST': 'bg-indigo-600',
'PATCH': 'bg-orange-500',
'DELETE': 'bg-red-600',
'PUT': 'bg-yellow-500'
} %}
<div class=" {{ method_colors [ endpoint .method ] ? ? 'bg-gray-600' }} text-white px-4 py-3 flex items-center min-w-[80px] justify-center">
<span class="font-black text-xs tracking-widest"> {{ endpoint .method }} </span>
</div>
2026-03-23 18:58:17 +01:00
<div class="flex-1 bg-gray-900 text-white px-4 py-3 flex items-center gap-2 flex-wrap">
{% if endpoint .path starts with '/api/auth' %}
<code class="font-mono font-bold text-sm"> {{ endpoint .path }} </code>
{% else %}
<code class="font-mono font-bold text-sm"><span class="text-orange-400">/api/sandbox</span><span class="text-gray-500">|</span><span class="text-green-400">/api/live</span> {{ endpoint .path | replace ( { '/api' : '' } ) }} </code>
{% endif %}
Add custom API documentation page at /api/doc
- ApiDocController: serves doc page + JSON spec at /api/doc/spec.json
- Custom brutal design template matching site aesthetic
- 6 sections: Auth, Events, Orders, Scanner, Billets/Stock, Export
- Each endpoint shows: method badge (colored), path, summary, description
- Auth headers: ETicket-Email + ETicket-JWT displayed prominently
- Parameters table with type, required, default values
- Request body with JSON example and field types
- Response body with JSON example
- Status codes with colored badges (green/yellow/red)
- Rate limiting section with X-RateLimit headers
- Table of contents with anchor links
- Standard response format: {success, data, error}
- No external dependencies (no Swagger/NelmioApiDoc)
- Fully customizable via PHP spec array
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 18:51:46 +01:00
</div>
</div>
<div class="p-6">
<h3 class="font-black uppercase text-sm tracking-tighter mb-1"> {{ endpoint .summary }} </h3>
<p class="text-sm font-bold text-gray-500 mb-4"> {{ endpoint .description }} </p>
{% if endpoint .headers | length > 0 %}
<div class="mb-4">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-400 mb-2">Headers requis</p>
<div class="flex flex-wrap gap-2">
{% for header in endpoint .headers %}
<span class="font-mono text-xs px-2 py-1 border-2 border-indigo-600 text-indigo-600 font-bold"> {{ header .name }} </span>
{% endfor %}
</div>
</div>
{% endif %}
{% if endpoint .params | length > 0 %}
<div class="mb-4">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-400 mb-2">Parametres</p>
<div class="overflow-x-auto">
<table class="w-full text-xs">
<thead>
<tr class="bg-gray-100">
<th class="px-3 py-2 text-left font-black uppercase tracking-widest">Nom</th>
<th class="px-3 py-2 text-left font-black uppercase tracking-widest">Type</th>
<th class="px-3 py-2 text-left font-black uppercase tracking-widest">Requis</th>
<th class="px-3 py-2 text-left font-black uppercase tracking-widest">Description</th>
</tr>
</thead>
<tbody>
{% for name , param in endpoint .params %}
<tr class="border-b border-gray-100">
<td class="px-3 py-2 font-mono font-bold text-indigo-600"> {{ name }} </td>
<td class="px-3 py-2 font-mono text-gray-500"> {{ param .type }} </td>
<td class="px-3 py-2">
{% if param .required %}
<span class="text-red-600 font-black">oui</span>
{% else %}
<span class="text-gray-400">non {% if param .default is defined %} ( {{ param .default }} ) {% endif %} </span>
{% endif %}
</td>
<td class="px-3 py-2 font-bold text-gray-600"> {{ param .description }} </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
{% if endpoint .request %}
<div class="mb-4">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-400 mb-2">Body (JSON)</p>
<div class="border-2 border-gray-900 bg-gray-900 text-white p-4">
<pre class="font-mono text-xs leading-relaxed overflow-x-auto"><code> {
{% for name , field in endpoint .request %}
" {{ name }} ": {{ field .example is defined ? '"' ~ field .example ~ '"' : '"..."' }} {{ not loop .last ? ',' : '' }} <span class="text-gray-500">// {{ field .type }} {% if field .required %} (requis) {% endif %} </span>
{% endfor %}
}</code></pre>
</div>
</div>
{% endif %}
{% if endpoint .response %}
<div class="mb-4">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-400 mb-2">Reponse (200)</p>
<div class="border-2 border-green-800 bg-green-50 p-4">
<pre class="font-mono text-xs leading-relaxed overflow-x-auto text-green-900"><code> {
{% for name , field in endpoint .response %}
" {{ name }} ": {{ field .example }} <span class="text-green-600">// {{ field .type }} </span> {{ not loop .last ? ',' : '' }}
{% endfor %}
}</code></pre>
</div>
</div>
{% endif %}
{% if endpoint .statuses | length > 0 %}
<div>
<p class="text-[10px] font-black uppercase tracking-widest text-gray-400 mb-2">Codes de reponse</p>
<div class="flex flex-wrap gap-2">
{% for code , desc in endpoint .statuses %}
{% set code_color = code < 3 0 0 ? 'border-green-600 text-green-700 bg-green-50' : ( code < 4 0 0 ? 'border-yellow-500 text-yellow-700 bg-yellow-50' : ( code < 5 0 0 ? 'border-red-600 text-red-700 bg-red-50' : 'border-gray-600 text-gray-700 bg-gray-50' ) ) %}
<div class="border-2 {{ code_color }} px-3 py-1">
<span class="font-mono font-black text-xs"> {{ code }} </span>
<span class="font-bold text-xs ml-1"> {{ desc }} </span>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endfor %}
<div class="card-brutal overflow-hidden">
<div class="bg-gray-900 text-white px-6 py-3">
<h2 class="text-[10px] font-black uppercase tracking-widest">Rate Limiting</h2>
</div>
<div class="p-6">
<p class="font-bold text-sm text-gray-700 mb-4">L'API est limitee a <span class="font-mono bg-gray-100 px-1 text-indigo-600">60 requetes par minute</span> par cle API. En cas de depassement, un code <span class="font-mono bg-red-50 px-1 text-red-600">429</span> est retourne.</p>
<div class="border-2 border-gray-200 p-4">
<p class="text-[10px] font-black uppercase tracking-widest text-gray-400 mb-2">Headers de rate limit</p>
<table class="w-full text-xs">
<tr class="border-b border-gray-100">
<td class="py-2 font-mono font-bold text-gray-600">X-RateLimit-Limit</td>
<td class="py-2 font-bold text-gray-500">Nombre max de requetes par fenetre</td>
</tr>
<tr class="border-b border-gray-100">
<td class="py-2 font-mono font-bold text-gray-600">X-RateLimit-Remaining</td>
<td class="py-2 font-bold text-gray-500">Requetes restantes dans la fenetre courante</td>
</tr>
<tr>
<td class="py-2 font-mono font-bold text-gray-600">Retry-After</td>
<td class="py-2 font-bold text-gray-500">Secondes avant la prochaine fenetre (si 429)</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}