EscolaLMS/Images

View on GitHub
src/Http/Controllers/Swagger/ImagesControllerSwagger.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
<?php

namespace EscolaLms\Images\Http\Controllers\Swagger;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

/**
 * SWAGGER_VERSION
 */
interface ImagesControllerSwagger
{
    /**
     * @OA\Get(
     *     path="/api/images/img",
     *     summary="Generate resized image on-fly and save it in cache. Returns redirect to cached file",
     *     summary="The path is generated by simple hash fn `$hash = sha1($path.json_encode($params));` then the URL is $prefix.$hash.$extension",
     *     tags={"Images"},
     *     @OA\Parameter(
     *         name="path",
     *         in="query",
     *         required=true,
     *         @OA\Schema(
     *             type="path",
     *         )
     *     ),
     *     @OA\Property(
     *         property="size",
     *         description="predefined size",
     *         type="string",
     *         example="thumbnail"
     *     ),
     *     @OA\Parameter(
     *         name="w",
     *         in="query",
     *         @OA\Schema(
     *             type="int",
     *             default="100",
     *         )
     *     ),
     *     @OA\Parameter(
     *         name="h",
     *         in="query",
     *         @OA\Schema(
     *             type="int",
     *             default="100",
     *         )
     *     ),
     *     @OA\Parameter(
     *         name="format",
     *         in="query",
     *         @OA\Schema(
     *             type="string"
     *         )
     *     ),
     *     @OA\Response(
     *         response=200,
     *         description="resized file operation",
     *      ),
     *     @OA\Response(
     *          response=500,
     *          description="server-side error",
     *      ),
     * )
     * 
     */
    public function image(Request $request): RedirectResponse;

    /**
     * @OA\Post(
     *     path="/api/images/img",
     *     summary="Lists resized images by array input",
     *     tags={"Images"},
     *     security={
     *         {"passport": {}},
     *     },
     *     @OA\RequestBody(
     *          required=true,
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  type="array",
     *                  @OA\Items(
     *                      @OA\Property(
     *                          property="path",
     *                          description="Filepath",
     *                          type="string",
     *                          example="tutor_avatar.jpg"
     *                      ),
     *                      @OA\Property(
     *                          property="params",
     *                          description="params",
     *                          type="object",
     *                          @OA\Property(
     *                              property="size",
     *                              description="predefined size",
     *                              type="string",
     *                              example="thumbnail"
     *                          ),
     *                          @OA\Property(
     *                              property="w",
     *                              description="width",
     *                              type="integer",
     *                              example="100"
     *                          ),
     *                          @OA\Property(
     *                              property="h",
     *                              description="height",
     *                              type="integer",
     *                              example="100"
     *                          ),
     *                      ),
     *                  ),
     *              ),
     *          ),
     *     ),
     *     @OA\Response(
     *         response=200,
     *         description="successful operation",
     *     ),
     *     @OA\Response(
     *          response=404,
     *          description="Target path access is not found",
     *     ),
     *     @OA\Response(
     *          response=500,
     *          description="server-side error",
     *     ),
     * )
     *
     */
    public function images(Request $request): JsonResponse;
}