feat: Integrate L5-Swagger for API documentation and enhance VM synchronization to include host-level details.

This commit is contained in:
pbao9
2026-02-15 12:31:06 +07:00
parent eb123ba97c
commit ef53ea3207
19 changed files with 3040 additions and 13433 deletions
@@ -23,6 +23,12 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
/**
* @OA\Tag(
* name="Services",
* description="API Endpoints for Services/Products"
* )
*/
class ServiceController extends Controller
{
protected $serviceService;
@@ -37,6 +43,56 @@ class ServiceController extends Controller
$this->serviceRepository = $serviceRepository;
}
/**
* @OA\Get(
* path="/services/get-list",
* operationId="getServiceList",
* tags={"Services"},
* summary="Get list of services",
* description="Returns a paginated list of active services/products",
* @OA\Parameter(
* name="limit",
* in="query",
* description="Number of items per page",
* required=false,
* @OA\Schema(type="integer", default=10)
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
* @OA\JsonContent(
* @OA\Property(property="error", type="boolean", example=false),
* @OA\Property(property="message", type="string", example="Lấy dữ liệu thành công"),
* @OA\Property(property="page_type", type="string", example="service"),
* @OA\Property(property="data", type="array", @OA\Items(
* @OA\Property(property="uuid", type="string", example="550e8400-e29b-41d4-a716-446655440000"),
* @OA\Property(property="name", type="string", example="Cloud VPS Basic"),
* @OA\Property(property="slug", type="string", example="cloud-vps-basic"),
* @OA\Property(property="short_description", type="string", example="Basic VPS plan"),
* @OA\Property(property="description", type="string"),
* @OA\Property(property="thumbnail", type="string", example="https://example.com/images/vps.jpg"),
* @OA\Property(property="product_type", type="string", example="vps"),
* @OA\Property(property="specs", type="object",
* @OA\Property(property="cpu", type="integer", example=2),
* @OA\Property(property="ram", type="integer", example=4),
* @OA\Property(property="disk", type="integer", example=50),
* @OA\Property(property="bandwidth", type="integer", example=1000),
* @OA\Property(property="gpu", type="string", nullable=true)
* ),
* @OA\Property(property="stock", type="integer", example=100),
* @OA\Property(property="price", type="number", example=299000),
* @OA\Property(property="price_sale", type="number", example=199000),
* @OA\Property(property="pricing", type="object"),
* @OA\Property(property="pricing_sale", type="object"),
* @OA\Property(property="group", type="string", example="VPS"),
* @OA\Property(property="os", type="array", @OA\Items(
* @OA\Property(property="group", type="string", example="Ubuntu")
* ))
* ))
* )
* )
* )
*/
public function getService(Request $request)
{
$limit = $request->get('limit', 10);
@@ -49,6 +105,63 @@ class ServiceController extends Controller
]);
}
/**
* @OA\Get(
* path="/services/{slug}",
* operationId="getServiceDetail",
* tags={"Services"},
* summary="Get service details",
* description="Returns detailed information about a specific service/product",
* @OA\Parameter(
* name="slug",
* in="path",
* description="Service slug",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
* @OA\JsonContent(
* @OA\Property(property="error", type="boolean", example=false),
* @OA\Property(property="message", type="string", example="Lấy dữ liệu thành công"),
* @OA\Property(property="page_type", type="string", example="service"),
* @OA\Property(property="data", type="object",
* @OA\Property(property="uuid", type="string", example="550e8400-e29b-41d4-a716-446655440000"),
* @OA\Property(property="name", type="string", example="Cloud VPS Basic"),
* @OA\Property(property="slug", type="string", example="cloud-vps-basic"),
* @OA\Property(property="short_description", type="string", example="Basic VPS plan"),
* @OA\Property(property="description", type="string"),
* @OA\Property(property="thumbnail", type="string", example="https://example.com/images/vps.jpg"),
* @OA\Property(property="product_type", type="string", example="vps"),
* @OA\Property(property="specs", type="object",
* @OA\Property(property="cpu", type="integer", example=2),
* @OA\Property(property="ram", type="integer", example=4),
* @OA\Property(property="disk", type="integer", example=50),
* @OA\Property(property="bandwidth", type="integer", example=1000),
* @OA\Property(property="gpu", type="string", nullable=true)
* ),
* @OA\Property(property="stock", type="integer", example=100),
* @OA\Property(property="price", type="number", example=299000),
* @OA\Property(property="price_sale", type="number", example=199000),
* @OA\Property(property="group", type="string", example="VPS"),
* @OA\Property(property="os", type="array", @OA\Items(
* @OA\Property(property="name", type="string", example="Ubuntu"),
* @OA\Property(property="thumbnail", type="string"),
* @OA\Property(property="versions", type="array", @OA\Items(
* @OA\Property(property="version", type="string", example="22.04"),
* @OA\Property(property="name", type="string", example="Ubuntu 22.04 LTS")
* ))
* ))
* )
* )
* ),
* @OA\Response(
* response=404,
* description="Service not found"
* )
* )
*/
public function getDetailService(Product $product)
{
$product->load([