<?php

namespace App\Http\Controllers\Api\V1;

use App\Http\Controllers\Controller;
use App\Support\Api\V1\SerenataApiDocumentation;
use Illuminate\Http\Request;

class SerenataApiDocumentationController extends Controller
{
    public function index(Request $request)
    {
        return $this->spec($request);
    }

    public function spec(Request $request)
    {
        return response()->json(
            SerenataApiDocumentation::openApi(rtrim($request->getSchemeAndHttpHost(), '/')),
            200,
            [],
            JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
        );
    }
}
