From a4025256d4eaf041a45775252a9e3f66b04be103 Mon Sep 17 00:00:00 2001 From: parsa aghaei Date: Tue, 23 Jun 2026 18:34:20 +0330 Subject: [PATCH] 3.1-3.6: install l5-swagger, add @OA annotations to all controllers --- .../Api/Blog/CategoryController.php | 61 ++ .../Controllers/Api/Blog/HomeController.php | 11 + .../Controllers/Api/Blog/PostController.php | 54 ++ .../Controllers/Api/Blog/TagController.php | 48 ++ .../Api/Website/AboutMeController.php | 59 ++ .../Api/Website/ProjectController.php | 54 +- .../Api/Website/ServiceController.php | 22 + app/SwaggerDefinitions.php | 85 +++ composer.json | 1 + composer.lock | 553 +++++++++++++++--- config/l5-swagger.php | 318 ++++++++++ resources/views/vendor/l5-swagger/.gitkeep | 0 .../views/vendor/l5-swagger/index.blade.php | 174 ++++++ 13 files changed, 1367 insertions(+), 73 deletions(-) create mode 100644 app/SwaggerDefinitions.php create mode 100644 config/l5-swagger.php create mode 100644 resources/views/vendor/l5-swagger/.gitkeep create mode 100644 resources/views/vendor/l5-swagger/index.blade.php diff --git a/app/Http/Controllers/Api/Blog/CategoryController.php b/app/Http/Controllers/Api/Blog/CategoryController.php index 2d5641e..a19a472 100644 --- a/app/Http/Controllers/Api/Blog/CategoryController.php +++ b/app/Http/Controllers/Api/Blog/CategoryController.php @@ -10,8 +10,21 @@ use App\Models\Blog\Category; use Illuminate\Http\Request; +/** + * @OA\Tag(name="Categories", description="Blog categories") + */ class CategoryController extends Controller { + /** + * @OA\Get( + * path="/blog/categories", + * tags={"Categories"}, + * summary="Paginated list of categories", + * @OA\Parameter(name="per_page", in="query", @OA\Schema(type="integer")), + * @OA\Parameter(name="filter", in="query", @OA\Schema(type="string")), + * @OA\Response(response=200, description="OK") + * ) + */ public function index(Request $request) { $filter = $request->input('filter'); @@ -32,12 +45,32 @@ public function index(Request $request) return CategoryResource::collection($categories); } + /** + * @OA\Get( + * path="/blog/categories/{id}", + * tags={"Categories"}, + * summary="Get a category by ID", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK") + * ) + */ public function show($id) { $category = Category::with('posts')->findOrFail($id); return new CategoryResource($category); } + /** + * @OA\Get( + * path="/blog/categories/{slug}/posts", + * tags={"Categories"}, + * summary="Get posts by category slug", + * @OA\Parameter(name="slug", in="path", required=true, @OA\Schema(type="string")), + * @OA\Parameter(name="per_page", in="query", @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK"), + * @OA\Response(response=404, description="Category not found") + * ) + */ public function getCategoryWithPosts(Request $request, $slug) { $category = Category::where('slug', $slug)->first(); @@ -87,12 +120,31 @@ public function getCategoryWithPosts(Request $request, $slug) ], 200); } + /** + * @OA\Post( + * path="/blog/categories", + * tags={"Categories"}, + * summary="Create a category", + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=201, description="Created") + * ) + */ public function store(StoreCategoryRequest $request) { $category = Category::create($request->validated()); return new CategoryResource($category); } + /** + * @OA\Put( + * path="/blog/categories/{id}", + * tags={"Categories"}, + * summary="Update a category", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=200, description="OK") + * ) + */ public function update(UpdateCategoryRequest $request, $id) { $category = Category::findOrFail($id); @@ -100,6 +152,15 @@ public function update(UpdateCategoryRequest $request, $id) return new CategoryResource($category); } + /** + * @OA\Delete( + * path="/blog/categories/{id}", + * tags={"Categories"}, + * summary="Delete a category", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK") + * ) + */ public function destroy($id) { $category = Category::findOrFail($id); diff --git a/app/Http/Controllers/Api/Blog/HomeController.php b/app/Http/Controllers/Api/Blog/HomeController.php index a8cd57d..47f44f2 100644 --- a/app/Http/Controllers/Api/Blog/HomeController.php +++ b/app/Http/Controllers/Api/Blog/HomeController.php @@ -8,8 +8,19 @@ use App\Models\Blog\Category; use App\Models\Blog\Post; +/** + * @OA\Tag(name="Blog Home", description="Blog homepage aggregated data") + */ class HomeController extends Controller { + /** + * @OA\Get( + * path="/blog/homepage", + * tags={"Blog Home"}, + * summary="Get homepage data: latest posts, categories, most viewed, random", + * @OA\Response(response=200, description="OK") + * ) + */ public function index() { $latestPosts = Post::with(['category', 'tags', 'author']) diff --git a/app/Http/Controllers/Api/Blog/PostController.php b/app/Http/Controllers/Api/Blog/PostController.php index 87cbe05..52ae283 100644 --- a/app/Http/Controllers/Api/Blog/PostController.php +++ b/app/Http/Controllers/Api/Blog/PostController.php @@ -9,8 +9,25 @@ use App\Models\Blog\Post; use Illuminate\Http\Request; +/** + * @OA\Tag(name="Posts", description="Blog post management") + */ class PostController extends Controller { + /** + * @OA\Get( + * path="/blog/posts", + * tags={"Posts"}, + * summary="Paginated list of posts", + * @OA\Parameter(name="per_page", in="query", @OA\Schema(type="integer")), + * @OA\Parameter(name="category", in="query", @OA\Schema(type="string")), + * @OA\Parameter(name="tag", in="query", @OA\Schema(type="string")), + * @OA\Parameter(name="search", in="query", @OA\Schema(type="string")), + * @OA\Parameter(name="sort_field", in="query", @OA\Schema(type="string")), + * @OA\Parameter(name="sort_direction", in="query", @OA\Schema(type="string", enum={"asc","desc"})), + * @OA\Response(response=200, description="OK") + * ) + */ public function index(Request $request) { $filters = $request->only(['category', 'tag', 'search', 'author', 'published']); @@ -29,6 +46,15 @@ public function index(Request $request) return PostResource::collection($posts); } + /** + * @OA\Get( + * path="/blog/posts/{slug}", + * tags={"Posts"}, + * summary="Get a single post by slug with related posts", + * @OA\Parameter(name="slug", in="path", required=true, @OA\Schema(type="string")), + * @OA\Response(response=200, description="OK") + * ) + */ public function show($slug) { $post = Post::with(['category', 'tags', 'author', 'relatedPosts.category', 'relatedPosts.tags', 'relatedPosts.author']) @@ -41,6 +67,15 @@ public function show($slug) ], 200); } + /** + * @OA\Post( + * path="/blog/posts", + * tags={"Posts"}, + * summary="Create a post", + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=201, description="Created") + * ) + */ public function store(StorePostRequest $request) { $post = Post::create($request->validated()); @@ -52,6 +87,16 @@ public function store(StorePostRequest $request) return new PostResource($post->load(['category', 'tags', 'author'])); } + /** + * @OA\Put( + * path="/blog/posts/{id}", + * tags={"Posts"}, + * summary="Update a post", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=200, description="OK") + * ) + */ public function update(UpdatePostRequest $request, $id) { $post = Post::findOrFail($id); @@ -64,6 +109,15 @@ public function update(UpdatePostRequest $request, $id) return new PostResource($post->load(['category', 'tags', 'author'])); } + /** + * @OA\Delete( + * path="/blog/posts/{id}", + * tags={"Posts"}, + * summary="Delete a post", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK") + * ) + */ public function destroy($id) { $post = Post::findOrFail($id); diff --git a/app/Http/Controllers/Api/Blog/TagController.php b/app/Http/Controllers/Api/Blog/TagController.php index 60f71fd..a310caf 100644 --- a/app/Http/Controllers/Api/Blog/TagController.php +++ b/app/Http/Controllers/Api/Blog/TagController.php @@ -9,26 +9,65 @@ use App\Models\Blog\Tag; use Illuminate\Http\Request; +/** + * @OA\Tag(name="Tags", description="Blog tag management") + */ class TagController extends Controller { + /** + * @OA\Get( + * path="/blog/tags", + * tags={"Tags"}, + * summary="Paginated list of tags", + * @OA\Response(response=200, description="OK") + * ) + */ public function index(Request $request) { $tags = Tag::with('posts')->paginate(10); return TagResource::collection($tags); } + /** + * @OA\Get( + * path="/blog/tags/{id}", + * tags={"Tags"}, + * summary="Get a tag by ID", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK") + * ) + */ public function show($id) { $tag = Tag::with('posts')->findOrFail($id); return new TagResource($tag); } + /** + * @OA\Post( + * path="/blog/tags", + * tags={"Tags"}, + * summary="Create a tag", + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=201, description="Created") + * ) + */ public function store(StoreTagRequest $request) { $tag = Tag::create($request->validated()); return new TagResource($tag); } + /** + * @OA\Put( + * path="/blog/tags/{id}", + * tags={"Tags"}, + * summary="Update a tag", + * @OA\Parameter(name="id", in="path", required=True, @OA\Schema(type="integer")), + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=200, description="OK") + * ) + */ public function update(UpdateTagRequest $request, $id) { $tag = Tag::findOrFail($id); @@ -36,6 +75,15 @@ public function update(UpdateTagRequest $request, $id) return new TagResource($tag); } + /** + * @OA\Delete( + * path="/blog/tags/{id}", + * tags={"Tags"}, + * summary="Delete a tag", + * @OA\Parameter(name="id", in="path", required=True, @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK") + * ) + */ public function destroy($id) { $tag = Tag::findOrFail($id); diff --git a/app/Http/Controllers/Api/Website/AboutMeController.php b/app/Http/Controllers/Api/Website/AboutMeController.php index c727339..7aa654d 100644 --- a/app/Http/Controllers/Api/Website/AboutMeController.php +++ b/app/Http/Controllers/Api/Website/AboutMeController.php @@ -7,26 +7,65 @@ use App\Http\Requests\Website\UpdateAboutMeRequest; use App\Models\Website\AboutMe; +/** + * @OA\Tag(name="About Me", description="About Me section endpoints") + */ class AboutMeController extends Controller { + /** + * @OA\Get( + * path="/website/about-me", + * tags={"About Me"}, + * summary="Get the first About Me entry with skills", + * @OA\Response(response=200, description="OK", @OA\JsonContent(ref="#/components/schemas/AboutMe")) + * ) + */ public function index() { $aboutMe = AboutMe::with('skills')->first(); return response()->json($aboutMe); } + /** + * @OA\Get( + * path="/website/about-me/{id}", + * tags={"About Me"}, + * summary="Get a specific About Me entry", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=200, description="OK") + * ) + */ public function show($id) { $aboutMe = AboutMe::with('skills')->findOrFail($id); return response()->json($aboutMe); } + /** + * @OA\Post( + * path="/website/about-me", + * tags={"About Me"}, + * summary="Create an About Me entry", + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=201, description="Created") + * ) + */ public function store(StoreAboutMeRequest $request) { $aboutMe = AboutMe::create($request->validated()); return response()->json($aboutMe, 201); } + /** + * @OA\Put( + * path="/website/about-me/{id}", + * tags={"About Me"}, + * summary="Update an About Me entry", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=200, description="OK") + * ) + */ public function update(UpdateAboutMeRequest $request, $id) { $aboutMe = AboutMe::findOrFail($id); @@ -34,12 +73,32 @@ public function update(UpdateAboutMeRequest $request, $id) return response()->json($aboutMe); } + /** + * @OA\Delete( + * path="/website/about-me/{id}", + * tags={"About Me"}, + * summary="Delete an About Me entry", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=204, description="No Content") + * ) + */ public function destroy($id) { AboutMe::destroy($id); return response()->json(null, 204); } + /** + * @OA\Get( + * path="/website/about-me/{id}/translation/{locale}", + * tags={"About Me"}, + * summary="Get localized About Me with skills", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Parameter(name="locale", in="path", required=true, @OA\Schema(type="string", enum={"fa","en"})), + * @OA\Response(response=200, description="OK", @OA\JsonContent(ref="#/components/schemas/AboutMe")), + * @OA\Response(response=404, description="Translation not found") + * ) + */ public function getTranslation($id, $locale) { $aboutMe = AboutMe::with('skills')->findOrFail($id); diff --git a/app/Http/Controllers/Api/Website/ProjectController.php b/app/Http/Controllers/Api/Website/ProjectController.php index 37abfd0..947060e 100644 --- a/app/Http/Controllers/Api/Website/ProjectController.php +++ b/app/Http/Controllers/Api/Website/ProjectController.php @@ -8,8 +8,22 @@ use App\Models\Website\Project; use App\Models\Website\ProjectCategory; +/** + * @OA\Tag(name="Projects", description="Projects section endpoints") + */ class ProjectController extends Controller { + /** + * @OA\Get( + * path="/website/projects/translation/{locale}", + * tags={"Projects"}, + * summary="List projects and categories in a locale", + * @OA\Parameter(name="locale", in="path", required=true, @OA\Schema(type="string", enum={"fa","en"})), + * @OA\Parameter(name="per_page", in="query", @OA\Schema(type="integer")), + * @OA\Parameter(name="sort", in="query", @OA\Schema(type="string", enum={"asc","desc"})), + * @OA\Response(response=200, description="OK") + * ) + */ public function index($locale): \Illuminate\Http\JsonResponse { $perPage = request()->query('per_page', 10); @@ -48,6 +62,15 @@ public function index($locale): \Illuminate\Http\JsonResponse ]); } + /** + * @OA\Post( + * path="/website/projects", + * tags={"Projects"}, + * summary="Create a project", + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=201, description="Created") + * ) + */ public function store(StoreProjectRequest $request) { $project = Project::create($request->only(['category_id', 'image1', 'image2'])); @@ -61,6 +84,16 @@ public function store(StoreProjectRequest $request) return response()->json($project, 201); } + /** + * @OA\Get( + * path="/website/projects/{id}/translation/{locale}", + * tags={"Projects"}, + * summary="Get a single project translation", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Parameter(name="locale", in="path", required=true, @OA\Schema(type="string", enum={"fa","en"})), + * @OA\Response(response=200, description="OK") + * ) + */ public function show($id, $locale) { $project = Project::with('category')->findOrFail($id); @@ -68,7 +101,7 @@ public function show($id, $locale) $formattedProject = [ 'id' => $project->id, 'title' => $project->getTranslation('title', $locale), - 'category' => $project->category?->getTranslation('title', 'fa'), + 'category' => $project->category?->getTranslation('title', $locale), 'images' => [ ['src' => $project->image1, 'position' => '1', 'zIndex' => 1], ['src' => $project->image2, 'position' => '2', 'zIndex' => 2], @@ -80,6 +113,16 @@ public function show($id, $locale) return response()->json(['project' => $formattedProject]); } + /** + * @OA\Put( + * path="/website/projects/{id}", + * tags={"Projects"}, + * summary="Update a project", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\RequestBody(@OA\MediaType(mediaType="application/json")), + * @OA\Response(response=200, description="OK") + * ) + */ public function update(UpdateProjectRequest $request, $id) { $project = Project::findOrFail($id); @@ -98,6 +141,15 @@ public function update(UpdateProjectRequest $request, $id) return response()->json($project); } + /** + * @OA\Delete( + * path="/website/projects/{id}", + * tags={"Projects"}, + * summary="Delete a project", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Response(response=204, description="No Content") + * ) + */ public function destroy($id) { Project::destroy($id); diff --git a/app/Http/Controllers/Api/Website/ServiceController.php b/app/Http/Controllers/Api/Website/ServiceController.php index eda031c..f4d3d22 100644 --- a/app/Http/Controllers/Api/Website/ServiceController.php +++ b/app/Http/Controllers/Api/Website/ServiceController.php @@ -5,8 +5,20 @@ use App\Http\Controllers\Controller; use App\Models\Website\Service; +/** + * @OA\Tag(name="Services", description="Services section endpoints") + */ class ServiceController extends Controller { + /** + * @OA\Get( + * path="/website/services/{locale}", + * tags={"Services"}, + * summary="List all services in a given locale", + * @OA\Parameter(name="locale", in="path", required=true, @OA\Schema(type="string", enum={"fa","en"})), + * @OA\Response(response=200, description="OK", @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/Service"))) + * ) + */ public function index($locale) { $services = Service::all(); @@ -26,6 +38,16 @@ public function index($locale) return response()->json($response); } + /** + * @OA\Get( + * path="/website/services/{id}/translation/{locale}", + * tags={"Services"}, + * summary="Get a single service translation", + * @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")), + * @OA\Parameter(name="locale", in="path", required=true, @OA\Schema(type="string", enum={"fa","en"})), + * @OA\Response(response=200, description="OK") + * ) + */ public function showTranslation($id, $locale) { $service = Service::findOrFail($id); diff --git a/app/SwaggerDefinitions.php b/app/SwaggerDefinitions.php new file mode 100644 index 0000000..142d471 --- /dev/null +++ b/app/SwaggerDefinitions.php @@ -0,0 +1,85 @@ +=5.18.3", + "symfony/yaml": "^5.0 || ^6.0 || ^7.0", + "zircote/swagger-php": "^5.0.0" + }, + "require-dev": { + "mockery/mockery": "1.*", + "orchestra/testbench": "^10.0 || ^9.0 || ^8.0 || 7.* || ^6.15 || 5.*", + "php-coveralls/php-coveralls": "^2.0", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "L5Swagger": "L5Swagger\\L5SwaggerFacade" + }, + "providers": [ + "L5Swagger\\L5SwaggerServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "L5Swagger\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Darius Matulionis", + "email": "darius@matulionis.lt" + } + ], + "description": "OpenApi or Swagger integration to Laravel", + "keywords": [ + "api", + "documentation", + "laravel", + "openapi", + "specification", + "swagger", + "ui" + ], + "support": { + "issues": "https://github.com/DarkaOnLine/L5-Swagger/issues", + "source": "https://github.com/DarkaOnLine/L5-Swagger/tree/9.0.1" + }, + "funding": [ + { + "url": "https://github.com/DarkaOnLine", + "type": "github" + } + ], + "time": "2025-02-28T06:25:02+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -210,6 +291,83 @@ }, "time": "2024-07-08T12:26:09+00:00" }, + { + "name": "doctrine/annotations", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "901c2ee5d26eb64ff43c47976e114bf00843acf7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/901c2ee5d26eb64ff43c47976e114bf00843acf7", + "reference": "901c2ee5d26eb64ff43c47976e114bf00843acf7", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^2 || ^3", + "ext-tokenizer": "*", + "php": "^7.2 || ^8.0", + "psr/cache": "^1 || ^2 || ^3" + }, + "require-dev": { + "doctrine/cache": "^2.0", + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.10.28", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "symfony/cache": "^5.4 || ^6.4 || ^7", + "vimeo/psalm": "^4.30 || ^5.14" + }, + "suggest": { + "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "https://www.doctrine-project.org/projects/annotations.html", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "support": { + "issues": "https://github.com/doctrine/annotations/issues", + "source": "https://github.com/doctrine/annotations/tree/2.0.2" + }, + "abandoned": true, + "time": "2024-09-05T10:17:24+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.10", @@ -2459,6 +2617,102 @@ ], "time": "2024-07-20T21:41:07+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "2.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "a004701b11273a26cd7955a61d67a7f1e525a45a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/a004701b11273a26cd7955a61d67a7f1e525a45a", + "reference": "a004701b11273a26cd7955a61d67a7f1e525a45a", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^5.3.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.2" + }, + "time": "2026-01-25T14:56:51+00:00" + }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, { "name": "psr/clock", "version": "1.0.0", @@ -3319,6 +3573,67 @@ ], "time": "2026-04-23T08:26:29+00:00" }, + { + "name": "swagger-api/swagger-ui", + "version": "v5.32.8", + "source": { + "type": "git", + "url": "https://github.com/swagger-api/swagger-ui.git", + "reference": "4e0d3f88de7db0395a80ef0541ff428f0926d484" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/4e0d3f88de7db0395a80ef0541ff428f0926d484", + "reference": "4e0d3f88de7db0395a80ef0541ff428f0926d484", + "shasum": "" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Anna Bodnia", + "email": "anna.bodnia@gmail.com" + }, + { + "name": "Buu Nguyen", + "email": "buunguyen@gmail.com" + }, + { + "name": "Josh Ponelat", + "email": "jponelat@gmail.com" + }, + { + "name": "Kyle Shockey", + "email": "kyleshockey1@gmail.com" + }, + { + "name": "Robert Barnwell", + "email": "robert@robertismy.name" + }, + { + "name": "Sahar Jafari", + "email": "shr.jafari@gmail.com" + } + ], + "description": " Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.", + "homepage": "http://swagger.io", + "keywords": [ + "api", + "documentation", + "openapi", + "specification", + "swagger", + "ui" + ], + "support": { + "issues": "https://github.com/swagger-api/swagger-ui/issues", + "source": "https://github.com/swagger-api/swagger-ui/tree/v5.32.8" + }, + "time": "2026-06-23T08:15:35+00:00" + }, { "name": "symfony/clock", "version": "v7.1.1", @@ -5545,6 +5860,77 @@ ], "time": "2024-09-16T10:07:02+00:00" }, + { + "name": "symfony/yaml", + "version": "v7.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/4e561c316e135e053bd758bf3b3eb291d9919de4", + "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v7.1.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-17T12:49:58+00:00" + }, { "name": "tijsverkoyen/css-to-inline-styles", "version": "v2.2.7", @@ -5813,6 +6199,100 @@ "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, "time": "2022-06-03T18:03:27+00:00" + }, + { + "name": "zircote/swagger-php", + "version": "5.8.3", + "source": { + "type": "git", + "url": "https://github.com/zircote/swagger-php.git", + "reference": "098223019f764a16715f64089a58606096719c98" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zircote/swagger-php/zipball/098223019f764a16715f64089a58606096719c98", + "reference": "098223019f764a16715f64089a58606096719c98", + "shasum": "" + }, + "require": { + "ext-json": "*", + "nikic/php-parser": "^4.19 || ^5.0", + "php": ">=7.4", + "phpstan/phpdoc-parser": "^2.0", + "psr/log": "^1.1 || ^2.0 || ^3.0", + "symfony/deprecation-contracts": "^2 || ^3", + "symfony/finder": "^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0 || ^8.0" + }, + "conflict": { + "symfony/process": ">=6, <6.4.14" + }, + "require-dev": { + "composer/package-versions-deprecated": "^1.11", + "doctrine/annotations": "^2.0", + "friendsofphp/php-cs-fixer": "^3.62.0", + "phpstan/phpstan": "^1.6 || ^2.0", + "phpunit/phpunit": "^9.0", + "rector/rector": "^1.0 || ^2.3.1", + "vimeo/psalm": "^4.30 || ^5.0" + }, + "suggest": { + "doctrine/annotations": "^2.0", + "radebatz/type-info-extras": "^1.0.2" + }, + "bin": [ + "bin/openapi" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "OpenApi\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Robert Allen", + "email": "zircote@gmail.com" + }, + { + "name": "Bob Fanger", + "email": "bfanger@gmail.com", + "homepage": "https://bfanger.nl" + }, + { + "name": "Martin Rademacher", + "email": "mano@radebatz.net", + "homepage": "https://radebatz.net" + } + ], + "description": "Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations", + "homepage": "https://github.com/zircote/swagger-php", + "keywords": [ + "api", + "json", + "rest", + "service discovery" + ], + "support": { + "issues": "https://github.com/zircote/swagger-php/issues", + "source": "https://github.com/zircote/swagger-php/tree/5.8.3" + }, + "funding": [ + { + "url": "https://github.com/zircote", + "type": "github" + } + ], + "time": "2026-03-02T00:47:18+00:00" } ], "packages-dev": [ @@ -7834,77 +8314,6 @@ ], "time": "2024-07-03T05:13:08+00:00" }, - { - "name": "symfony/yaml", - "version": "v7.1.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4e561c316e135e053bd758bf3b3eb291d9919de4", - "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4", - "shasum": "" - }, - "require": { - "php": ">=8.2", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "symfony/console": "<6.4" - }, - "require-dev": { - "symfony/console": "^6.4|^7.0" - }, - "bin": [ - "Resources/bin/yaml-lint" - ], - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Loads and dumps YAML files", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v7.1.5" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-17T12:49:58+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.3", diff --git a/config/l5-swagger.php b/config/l5-swagger.php new file mode 100644 index 0000000..a3ce546 --- /dev/null +++ b/config/l5-swagger.php @@ -0,0 +1,318 @@ + 'default', + 'documentations' => [ + 'default' => [ + 'api' => [ + 'title' => 'L5 Swagger UI', + ], + + 'routes' => [ + /* + * Route for accessing api documentation interface + */ + 'api' => 'api/documentation', + ], + 'paths' => [ + /* + * Edit to include full URL in ui for assets + */ + 'use_absolute_path' => env('L5_SWAGGER_USE_ABSOLUTE_PATH', true), + + /* + * Edit to set path where swagger ui assets should be stored + */ + 'swagger_ui_assets_path' => env('L5_SWAGGER_UI_ASSETS_PATH', 'vendor/swagger-api/swagger-ui/dist/'), + + /* + * File name of the generated json documentation file + */ + 'docs_json' => 'api-docs.json', + + /* + * File name of the generated YAML documentation file + */ + 'docs_yaml' => 'api-docs.yaml', + + /* + * Set this to `json` or `yaml` to determine which documentation file to use in UI + */ + 'format_to_use_for_docs' => env('L5_FORMAT_TO_USE_FOR_DOCS', 'json'), + + /* + * Absolute paths to directory containing the swagger annotations are stored. + */ + 'annotations' => [ + base_path('app'), + ], + ], + ], + ], + 'defaults' => [ + 'routes' => [ + /* + * Route for accessing parsed swagger annotations. + */ + 'docs' => 'docs', + + /* + * Route for Oauth2 authentication callback. + */ + 'oauth2_callback' => 'api/oauth2-callback', + + /* + * Middleware allows to prevent unexpected access to API documentation + */ + 'middleware' => [ + 'api' => [], + 'asset' => [], + 'docs' => [], + 'oauth2_callback' => [], + ], + + /* + * Route Group options + */ + 'group_options' => [], + ], + + 'paths' => [ + /* + * Absolute path to location where parsed annotations will be stored + */ + 'docs' => storage_path('api-docs'), + + /* + * Absolute path to directory where to export views + */ + 'views' => base_path('resources/views/vendor/l5-swagger'), + + /* + * Edit to set the api's base path + */ + 'base' => env('L5_SWAGGER_BASE_PATH', null), + + /* + * Absolute path to directories that should be excluded from scanning + * @deprecated Please use `scanOptions.exclude` + * `scanOptions.exclude` overwrites this + */ + 'excludes' => [], + ], + + 'scanOptions' => [ + /** + * Configuration for default processors. Allows to pass processors configuration to swagger-php. + * + * @link https://zircote.github.io/swagger-php/reference/processors.html + */ + 'default_processors_configuration' => [ + /** Example */ + /** + * 'operationId.hash' => true, + * 'pathFilter' => [ + * 'tags' => [ + * '/pets/', + * '/store/', + * ], + * ],. + */ + ], + + /** + * analyser: defaults to \OpenApi\StaticAnalyser . + * + * @see \OpenApi\scan + */ + 'analyser' => null, + + /** + * analysis: defaults to a new \OpenApi\Analysis . + * + * @see \OpenApi\scan + */ + 'analysis' => null, + + /** + * Custom query path processors classes. + * + * @link https://github.com/zircote/swagger-php/tree/master/Examples/processors/schema-query-parameter + * @see \OpenApi\scan + */ + 'processors' => [ + // new \App\SwaggerProcessors\SchemaQueryParameter(), + ], + + /** + * pattern: string $pattern File pattern(s) to scan (default: *.php) . + * + * @see \OpenApi\scan + */ + 'pattern' => null, + + /* + * Absolute path to directories that should be excluded from scanning + * @note This option overwrites `paths.excludes` + * @see \OpenApi\scan + */ + 'exclude' => [], + + /* + * Allows to generate specs either for OpenAPI 3.0.0 or OpenAPI 3.1.0. + * By default the spec will be in version 3.0.0 + */ + 'open_api_spec_version' => env('L5_SWAGGER_OPEN_API_SPEC_VERSION', \L5Swagger\Generator::OPEN_API_DEFAULT_SPEC_VERSION), + ], + + /* + * API security definitions. Will be generated into documentation file. + */ + 'securityDefinitions' => [ + 'securitySchemes' => [ + /* + * Examples of Security schemes + */ + /* + 'api_key_security_example' => [ // Unique name of security + 'type' => 'apiKey', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2". + 'description' => 'A short description for security scheme', + 'name' => 'api_key', // The name of the header or query parameter to be used. + 'in' => 'header', // The location of the API key. Valid values are "query" or "header". + ], + 'oauth2_security_example' => [ // Unique name of security + 'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2". + 'description' => 'A short description for oauth2 security scheme.', + 'flow' => 'implicit', // The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode". + 'authorizationUrl' => 'http://example.com/auth', // The authorization URL to be used for (implicit/accessCode) + //'tokenUrl' => 'http://example.com/auth' // The authorization URL to be used for (password/application/accessCode) + 'scopes' => [ + 'read:projects' => 'read your projects', + 'write:projects' => 'modify projects in your account', + ] + ], + */ + + /* Open API 3.0 support + 'passport' => [ // Unique name of security + 'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2". + 'description' => 'Laravel passport oauth2 security.', + 'in' => 'header', + 'scheme' => 'https', + 'flows' => [ + "password" => [ + "authorizationUrl" => config('app.url') . '/oauth/authorize', + "tokenUrl" => config('app.url') . '/oauth/token', + "refreshUrl" => config('app.url') . '/token/refresh', + "scopes" => [] + ], + ], + ], + 'sanctum' => [ // Unique name of security + 'type' => 'apiKey', // Valid values are "basic", "apiKey" or "oauth2". + 'description' => 'Enter token in format (Bearer )', + 'name' => 'Authorization', // The name of the header or query parameter to be used. + 'in' => 'header', // The location of the API key. Valid values are "query" or "header". + ], + */ + ], + 'security' => [ + /* + * Examples of Securities + */ + [ + /* + 'oauth2_security_example' => [ + 'read', + 'write' + ], + + 'passport' => [] + */ + ], + ], + ], + + /* + * Set this to `true` in development mode so that docs would be regenerated on each request + * Set this to `false` to disable swagger generation on production + */ + 'generate_always' => env('L5_SWAGGER_GENERATE_ALWAYS', false), + + /* + * Set this to `true` to generate a copy of documentation in yaml format + */ + 'generate_yaml_copy' => env('L5_SWAGGER_GENERATE_YAML_COPY', false), + + /* + * Edit to trust the proxy's ip address - needed for AWS Load Balancer + * string[] + */ + 'proxy' => false, + + /* + * Configs plugin allows to fetch external configs instead of passing them to SwaggerUIBundle. + * See more at: https://github.com/swagger-api/swagger-ui#configs-plugin + */ + 'additional_config_url' => null, + + /* + * Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), + * 'method' (sort by HTTP method). + * Default is the order returned by the server unchanged. + */ + 'operations_sort' => env('L5_SWAGGER_OPERATIONS_SORT', null), + + /* + * Pass the validatorUrl parameter to SwaggerUi init on the JS side. + * A null value here disables validation. + */ + 'validator_url' => null, + + /* + * Swagger UI configuration parameters + */ + 'ui' => [ + 'display' => [ + 'dark_mode' => env('L5_SWAGGER_UI_DARK_MODE', false), + /* + * Controls the default expansion setting for the operations and tags. It can be : + * 'list' (expands only the tags), + * 'full' (expands the tags and operations), + * 'none' (expands nothing). + */ + 'doc_expansion' => env('L5_SWAGGER_UI_DOC_EXPANSION', 'none'), + + /** + * If set, enables filtering. The top bar will show an edit box that + * you can use to filter the tagged operations that are shown. Can be + * Boolean to enable or disable, or a string, in which case filtering + * will be enabled using that string as the filter expression. Filtering + * is case-sensitive matching the filter expression anywhere inside + * the tag. + */ + 'filter' => env('L5_SWAGGER_UI_FILTERS', true), // true | false + ], + + 'authorization' => [ + /* + * If set to true, it persists authorization data, and it would not be lost on browser close/refresh + */ + 'persist_authorization' => env('L5_SWAGGER_UI_PERSIST_AUTHORIZATION', false), + + 'oauth2' => [ + /* + * If set to true, adds PKCE to AuthorizationCodeGrant flow + */ + 'use_pkce_with_authorization_code_grant' => false, + ], + ], + ], + /* + * Constants which can be used in annotations + */ + 'constants' => [ + 'L5_SWAGGER_CONST_HOST' => env('L5_SWAGGER_CONST_HOST', 'http://my-default-host.com'), + ], + ], +]; diff --git a/resources/views/vendor/l5-swagger/.gitkeep b/resources/views/vendor/l5-swagger/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/vendor/l5-swagger/index.blade.php b/resources/views/vendor/l5-swagger/index.blade.php new file mode 100644 index 0000000..4f57040 --- /dev/null +++ b/resources/views/vendor/l5-swagger/index.blade.php @@ -0,0 +1,174 @@ + + + + + {{ $documentationTitle }} + + + + + @if(config('l5-swagger.defaults.ui.display.dark_mode')) + + @endif + + + +
+ + + + + +