3.1-3.6: install l5-swagger, add @OA annotations to all controllers
Deploy Backend / deploy (push) Failing after 2m16s

This commit is contained in:
parsa aghaei committed 2026-06-23 18:34:20 +03:30
1 parent 37dd2c9d54
commit a4025256d4
13 files changed
+1367 -73

No files matched your search

@@ -9,8 +9,25 @@ use App\Http\Resources\PostResource;
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 @@ class PostController extends Controller
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 @@ class PostController extends Controller
], 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 @@ class PostController extends Controller
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 @@ class PostController extends Controller
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);