From 5abef874bd7028c3beadecdb6047ce70169182fd Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Thu, 15 May 2025 13:52:51 +0300 Subject: [PATCH 1/8] Improve API documentation --- src/Docs/Shop/Models/Customer/Pagination.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Docs/Shop/Models/Customer/Pagination.php b/src/Docs/Shop/Models/Customer/Pagination.php index 6b7c776a..b5211ec9 100755 --- a/src/Docs/Shop/Models/Customer/Pagination.php +++ b/src/Docs/Shop/Models/Customer/Pagination.php @@ -141,10 +141,11 @@ class Pagination * @OA\Property( * title="Path", * description="Path", + * type="string", * example="http://localhost/public/api/v1/examples" * ) * - * @var int + * @var string */ private $path; From d0de5627e56620aa182fb9c6d37bd8f51132e51f Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Thu, 15 May 2025 16:02:09 +0300 Subject: [PATCH 2/8] Improve doc types --- .../Catalog/CategoryController.php | 4 +- .../Controllers/Catalog/ProductController.php | 2 +- .../Controllers/Core/CountryController.php | 9 +- .../Customer/CheckoutController.php | 83 ++++++++----------- .../Customer/WishlistController.php | 4 +- src/Docs/Shop/Models/Catalog/Attribute.php | 2 + .../Shop/Models/Catalog/AttributeFamily.php | 4 +- .../Shop/Models/Catalog/AttributeGroup.php | 4 +- src/Docs/Shop/Models/Catalog/Product.php | 24 ++++-- .../Catalog/ProductConfigurableConfig.php | 6 +- src/Docs/Shop/Models/Customer/Address.php | 6 +- src/Docs/Shop/Models/Customer/CartAddress.php | 6 +- src/Docs/Shop/Models/Customer/Customer.php | 10 ++- 13 files changed, 81 insertions(+), 83 deletions(-) diff --git a/src/Docs/Shop/Controllers/Catalog/CategoryController.php b/src/Docs/Shop/Controllers/Catalog/CategoryController.php index ba340c0c..bcb67990 100755 --- a/src/Docs/Shop/Controllers/Catalog/CategoryController.php +++ b/src/Docs/Shop/Controllers/Catalog/CategoryController.php @@ -163,8 +163,8 @@ public function get() * * @OA\Property( * property="data", - * type="object", - * ref="#/components/schemas/Category" + * type="array", + * * @OA\Items(ref="#/components/schemas/Category") * ) * ) * ), diff --git a/src/Docs/Shop/Controllers/Catalog/ProductController.php b/src/Docs/Shop/Controllers/Catalog/ProductController.php index f8ad518d..5d609a10 100755 --- a/src/Docs/Shop/Controllers/Catalog/ProductController.php +++ b/src/Docs/Shop/Controllers/Catalog/ProductController.php @@ -372,7 +372,7 @@ public function configurableConfig() * @OA\Property( * property="attachments[]", * type="array", - * @OA\Items(type="file"), + * @OA\Items(type="string", format="binary"), * description="Array of attachment files (images or videos)" * ), * required={"comment", "rating", "title"} diff --git a/src/Docs/Shop/Controllers/Core/CountryController.php b/src/Docs/Shop/Controllers/Core/CountryController.php index 0dd73ddb..94e2a77e 100755 --- a/src/Docs/Shop/Controllers/Core/CountryController.php +++ b/src/Docs/Shop/Controllers/Core/CountryController.php @@ -197,11 +197,10 @@ public function get() * description="Successful operation", * * @OA\JsonContent( - * * @OA\Property( * property="data", - * type="object", - * ref="#/components/schemas/CountryState" + * type="array", + * @OA\Items(ref="#/components/schemas/CountryState") * ) * ) * ), @@ -232,8 +231,8 @@ public function states() * * @OA\Property( * property="data", - * type="object", - * ref="#/components/schemas/CountryState" + * type="array", + * @OA\Items(ref="#/components/schemas/CountryState") * ) * ) * ), diff --git a/src/Docs/Shop/Controllers/Customer/CheckoutController.php b/src/Docs/Shop/Controllers/Customer/CheckoutController.php index d975549c..8d34d409 100755 --- a/src/Docs/Shop/Controllers/Customer/CheckoutController.php +++ b/src/Docs/Shop/Controllers/Customer/CheckoutController.php @@ -22,7 +22,7 @@ class CheckoutController * * @OA\Property( * property="billing", - * type="array", + * type="object", * description="", * example={ * "id": 14, @@ -36,32 +36,26 @@ class CheckoutController * "city": "Marrero", * "state": "LA", * "country": "US", - * "postcode": 70072, + * "postcode": "70072", * "phone": 9871234560 * }, - * - * @OA\Items( - * - * @OA\Property(property="id", type="integer"), - * @OA\Property(property="address", type="array", @OA\Items( - * @OA\Property(type="string") - * )), - * @OA\Property(property="save_as_address", type="boolean"), - * @OA\Property(property="use_for_shipping", type="boolean"), - * @OA\Property(property="first_name", type="string"), - * @OA\Property(property="last_name", type="string"), - * @OA\Property(property="email", type="string"), - * @OA\Property(property="company_name", type="string"), - * @OA\Property(property="city", type="string"), - * @OA\Property(property="state", type="string"), - * @OA\Property(property="country", type="string"), - * @OA\Property(property="postcode", type="integer"), - * @OA\Property(property="phone", type="integer") - * ) + * @OA\Property(property="id", type="integer"), + * @OA\Property(property="address", type="array", @OA\Items(@OA\Property(type="string"))), + * @OA\Property(property="save_as_address", type="boolean"), + * @OA\Property(property="use_for_shipping", type="boolean"), + * @OA\Property(property="first_name", type="string"), + * @OA\Property(property="last_name", type="string"), + * @OA\Property(property="email", type="string"), + * @OA\Property(property="company_name", type="string"), + * @OA\Property(property="city", type="string"), + * @OA\Property(property="state", type="string"), + * @OA\Property(property="country", type="string"), + * @OA\Property(property="postcode", type="string"), + * @OA\Property(property="phone", type="integer") * ), * @OA\Property( * property="shipping", - * type="array", + * type="object", * description="", * example={ * "id": null, @@ -74,27 +68,23 @@ class CheckoutController * "city": "Mansfield", * "state": "OH", * "country": "US", - * "postcode": 44907, + * "postcode": "44907", * "phone": 987654321 * }, - * - * @OA\Items( - * - * @OA\Property(property="id", type="integer"), - * @OA\Property(property="address", type="array", @OA\Items( - * @OA\Property(type="string") - * )), - * @OA\Property(property="save_as_address", type="boolean"), - * @OA\Property(property="first_name", type="string"), - * @OA\Property(property="last_name", type="string"), - * @OA\Property(property="email", type="string"), - * @OA\Property(property="company_name", type="string"), - * @OA\Property(property="city", type="string"), - * @OA\Property(property="state", type="string"), - * @OA\Property(property="country", type="string"), - * @OA\Property(property="postcode", type="integer"), - * @OA\Property(property="phone", type="integer") - * ) + * @OA\Property(property="id", type="integer"), + * @OA\Property(property="address", type="array", @OA\Items( + * @OA\Property(type="string") + * )), + * @OA\Property(property="save_as_address", type="boolean"), + * @OA\Property(property="first_name", type="string"), + * @OA\Property(property="last_name", type="string"), + * @OA\Property(property="email", type="string"), + * @OA\Property(property="company_name", type="string"), + * @OA\Property(property="city", type="string"), + * @OA\Property(property="state", type="string"), + * @OA\Property(property="country", type="string"), + * @OA\Property(property="postcode", type="string"), + * @OA\Property(property="phone", type="integer") * ), * required={"billing"} * ) @@ -246,15 +236,8 @@ public function saveShipping() * * @OA\Property( * property="payment", - * type="array", - * example={ - * "method": "cashondelivery" - * }, - * - * @OA\Items( - * - * @OA\Property(property="method", type="string") - * ) + * type="object", + * @OA\Property(property="method", type="string", example="cashondelivery"), * ), * required={"payment"} * ) diff --git a/src/Docs/Shop/Controllers/Customer/WishlistController.php b/src/Docs/Shop/Controllers/Customer/WishlistController.php index d88fa48c..2ca47dac 100755 --- a/src/Docs/Shop/Controllers/Customer/WishlistController.php +++ b/src/Docs/Shop/Controllers/Customer/WishlistController.php @@ -21,8 +21,8 @@ class WishlistController * * @OA\Property( * property="data", - * type="object", - * ref="#/components/schemas/Wishlist" + * type="array", + * @OA\Items(ref="#/components/schemas/Wishlist") * ) * ) * ), diff --git a/src/Docs/Shop/Models/Catalog/Attribute.php b/src/Docs/Shop/Models/Catalog/Attribute.php index d61033ce..6066dab2 100755 --- a/src/Docs/Shop/Models/Catalog/Attribute.php +++ b/src/Docs/Shop/Models/Catalog/Attribute.php @@ -83,6 +83,8 @@ class Attribute * @OA\Property( * title="Options", * description="Attribute's options" + * type="array", + * @OA\Items(ref="#/components/schemas/AttributeOption") * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Catalog\AttributeOption diff --git a/src/Docs/Shop/Models/Catalog/AttributeFamily.php b/src/Docs/Shop/Models/Catalog/AttributeFamily.php index 314e12f8..87641b38 100755 --- a/src/Docs/Shop/Models/Catalog/AttributeFamily.php +++ b/src/Docs/Shop/Models/Catalog/AttributeFamily.php @@ -59,7 +59,9 @@ class AttributeFamily /** * @OA\Property( * title="Groups", - * description="Attribute's groups" + * description="Attribute's groups", + * type="array", + * @OA\Items(ref="#/components/schemas/AttributeGroup") * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Catalog\AttributeGroup diff --git a/src/Docs/Shop/Models/Catalog/AttributeGroup.php b/src/Docs/Shop/Models/Catalog/AttributeGroup.php index d527c898..c493e78d 100755 --- a/src/Docs/Shop/Models/Catalog/AttributeGroup.php +++ b/src/Docs/Shop/Models/Catalog/AttributeGroup.php @@ -58,7 +58,9 @@ class AttributeGroup /** * @OA\Property( * title="Attributes", - * description="Attributes" + * description="Attributes", + * type="array", + * @OA\Items(ref="#/components/schemas/Attribute") * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Catalog\Attribute diff --git a/src/Docs/Shop/Models/Catalog/Product.php b/src/Docs/Shop/Models/Catalog/Product.php index 8be8669c..744ba3a1 100755 --- a/src/Docs/Shop/Models/Catalog/Product.php +++ b/src/Docs/Shop/Models/Catalog/Product.php @@ -70,10 +70,11 @@ class Product * @OA\Property( * title="Price", * description="Product price", - * example=12.20 + * example="12.20", + * type="string" * ) * - * @var float + * @var string */ public $price; @@ -81,7 +82,8 @@ class Product * @OA\Property( * title="Formatted Price", * description="Product's formatted price", - * example="$12.20" + * example="$12.20", + * type="string" * ) * * @var string @@ -287,10 +289,11 @@ class Product * @OA\Property( * title="Special Price", * description="Product's special price, Only use if special_price is applied to product", - * example=8.00 + * example="8.00", + * type="string" * ) * - * @var float + * @var string */ public $special_price; @@ -298,7 +301,8 @@ class Product * @OA\Property( * title="Formatted Special Price", * description="Product's formatted special price, Only use if special_price is applied to product", - * example="$8.00" + * example="$8.00", + * type="string" * ) * * @var string @@ -309,10 +313,11 @@ class Product * @OA\Property( * title="Regular Price", * description="Product's regular price", - * example=12.20 + * example="12.20", + * type="string" * ) * - * @var float + * @var string */ public $regular_price; @@ -320,7 +325,8 @@ class Product * @OA\Property( * title="Formatted Regular Price", * description="Product's formatted regular price", - * example="$12.20" + * example="$12.20", + * type="string" * ) * * @var string diff --git a/src/Docs/Shop/Models/Catalog/ProductConfigurableConfig.php b/src/Docs/Shop/Models/Catalog/ProductConfigurableConfig.php index 3b5e4322..cb20d7fc 100755 --- a/src/Docs/Shop/Models/Catalog/ProductConfigurableConfig.php +++ b/src/Docs/Shop/Models/Catalog/ProductConfigurableConfig.php @@ -198,13 +198,13 @@ class ProductConfigurableConfig * @OA\Property( * property="regular_price", * type="object", - * @OA\Property(property="price", type="integer", example=60.00), + * @OA\Property(property="price", type="string", example="60.00"), * @OA\Property(property="formated_price", type="string", example="$60.00") * ), * @OA\Property( * property="final_price", * type="object", - * @OA\Property(property="price", type="integer", example=60.00), + * @OA\Property(property="price", type="string", example="60.00"), * @OA\Property(property="formated_price", type="string", example="$60.00") * ) * ) @@ -301,7 +301,7 @@ class ProductConfigurableConfig * "price": 30 * }, * @OA\Property(property="formated_price", type="string", example="$30.00"), - * @OA\Property(property="price", type="float", example=30.00) + * @OA\Property(property="price", type="string", example="30.00") * ) * * @var object diff --git a/src/Docs/Shop/Models/Customer/Address.php b/src/Docs/Shop/Models/Customer/Address.php index d1b695d4..ea616717 100755 --- a/src/Docs/Shop/Models/Customer/Address.php +++ b/src/Docs/Shop/Models/Customer/Address.php @@ -136,11 +136,11 @@ class Address * @OA\Property( * title="Postcode", * description="Address Postcode", - * format="int64", - * example=21797 + * format="string", + * example="21797" * ) * - * @var int + * @var string */ private $postcode; diff --git a/src/Docs/Shop/Models/Customer/CartAddress.php b/src/Docs/Shop/Models/Customer/CartAddress.php index 916e223f..d66c3423 100755 --- a/src/Docs/Shop/Models/Customer/CartAddress.php +++ b/src/Docs/Shop/Models/Customer/CartAddress.php @@ -150,11 +150,11 @@ class CartAddress * @OA\Property( * title="Postcode", * description="Address Postcode", - * format="int64", - * example=21797 + * format="string", + * example="21797" * ) * - * @var int + * @var string */ private $postcode; diff --git a/src/Docs/Shop/Models/Customer/Customer.php b/src/Docs/Shop/Models/Customer/Customer.php index 832f1f39..4b665c46 100755 --- a/src/Docs/Shop/Models/Customer/Customer.php +++ b/src/Docs/Shop/Models/Customer/Customer.php @@ -92,10 +92,12 @@ class Customer * @OA\Property( * title="Status", * description="Customer's Status", - * example="1", + * example=1, + * type="integer", + * format="int64" * ) * - * @var string + * @var int */ private $status; @@ -126,9 +128,11 @@ class Customer * @OA\Property( * title="Notes", * description="Customer's notes", + * type="array", + * @OA\Items(type="string") * ) * - * @var string + * @var array */ private $notes; From 37f03195273250db09ceadb4797df91215f4a868 Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Thu, 15 May 2025 17:30:11 +0300 Subject: [PATCH 3/8] Add Cart description --- .../Customer/CheckoutController.php | 28 +++---- src/Docs/Shop/Models/Customer/Cart.php | 83 ++++++++++++------- src/Docs/Shop/Models/Customer/Order.php | 16 ++-- src/Docs/Shop/Models/Customer/OrderItem.php | 36 +++++--- 4 files changed, 105 insertions(+), 58 deletions(-) diff --git a/src/Docs/Shop/Controllers/Customer/CheckoutController.php b/src/Docs/Shop/Controllers/Customer/CheckoutController.php index 8d34d409..5a381819 100755 --- a/src/Docs/Shop/Controllers/Customer/CheckoutController.php +++ b/src/Docs/Shop/Controllers/Customer/CheckoutController.php @@ -71,20 +71,20 @@ class CheckoutController * "postcode": "44907", * "phone": 987654321 * }, - * @OA\Property(property="id", type="integer"), - * @OA\Property(property="address", type="array", @OA\Items( - * @OA\Property(type="string") - * )), - * @OA\Property(property="save_as_address", type="boolean"), - * @OA\Property(property="first_name", type="string"), - * @OA\Property(property="last_name", type="string"), - * @OA\Property(property="email", type="string"), - * @OA\Property(property="company_name", type="string"), - * @OA\Property(property="city", type="string"), - * @OA\Property(property="state", type="string"), - * @OA\Property(property="country", type="string"), - * @OA\Property(property="postcode", type="string"), - * @OA\Property(property="phone", type="integer") + * @OA\Property(property="id", type="integer"), + * @OA\Property(property="address", type="array", @OA\Items( + * @OA\Property(type="string") + * )), + * @OA\Property(property="save_as_address", type="boolean"), + * @OA\Property(property="first_name", type="string"), + * @OA\Property(property="last_name", type="string"), + * @OA\Property(property="email", type="string"), + * @OA\Property(property="company_name", type="string"), + * @OA\Property(property="city", type="string"), + * @OA\Property(property="state", type="string"), + * @OA\Property(property="country", type="string"), + * @OA\Property(property="postcode", type="string"), + * @OA\Property(property="phone", type="integer") * ), * required={"billing"} * ) diff --git a/src/Docs/Shop/Models/Customer/Cart.php b/src/Docs/Shop/Models/Customer/Cart.php index 7d21ffda..81b76cd0 100755 --- a/src/Docs/Shop/Models/Customer/Cart.php +++ b/src/Docs/Shop/Models/Customer/Cart.php @@ -138,10 +138,11 @@ class Cart * @OA\Property( * title="Grand Total", * description="Grand Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $grand_total; @@ -149,10 +150,11 @@ class Cart * @OA\Property( * title="Formatted Grand Total", * description="Formatted Grand Total of the Cart", - * example="$10.00" + * example="$10.00", + * type="string" * ) * - * @var float + * @var string */ private $formatted_grand_total; @@ -160,10 +162,11 @@ class Cart * @OA\Property( * title="Base Grand Total", * description="Base Grand Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $base_grand_total; @@ -182,10 +185,11 @@ class Cart * @OA\Property( * title="Sub Total", * description="Sub Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $sub_total; @@ -194,9 +198,10 @@ class Cart * title="Formatted Sub Total", * description="Formatted Sub Total of the Cart", * example="$10.00" + * type="string" * ) * - * @var float + * @var string */ private $formatted_sub_total; @@ -204,10 +209,11 @@ class Cart * @OA\Property( * title="Base Sub Total", * description="Base Sub Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $base_sub_total; @@ -215,7 +221,8 @@ class Cart * @OA\Property( * title="Formatted Base Sub Total", * description="Formatted Base Sub Total of the Cart", - * example="$10.00" + * example="$10.00", + * type="string" * ) * * @var string @@ -226,10 +233,11 @@ class Cart * @OA\Property( * title="Tax Total", * description="Tax Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $tax_total; @@ -237,10 +245,11 @@ class Cart * @OA\Property( * title="Formatted Tax Total", * description="Formatted Tax Total of the Cart", - * example="$10.00" + * example="$10.00", + * type="string" * ) * - * @var float + * @var string */ private $formatted_tax_total; @@ -248,10 +257,11 @@ class Cart * @OA\Property( * title="Base Tax Total", * description="Base Tax Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $base_tax_total; @@ -260,6 +270,7 @@ class Cart * title="Formatted Base Tax Total", * description="Formatted Base Tax Total of the Cart", * example="$10.00" + * type="string" * ) * * @var string @@ -270,10 +281,11 @@ class Cart * @OA\Property( * title="Discount Total", * description="Discount Total of the Cart", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $discount; @@ -281,10 +293,11 @@ class Cart * @OA\Property( * title="Formatted Discount Total", * description="Formatted Discount Total of the Cart", - * example="$10.00" + * example="$10.00", + * type="string" * ) * - * @var float + * @var string */ private $formatted_discount; @@ -293,9 +306,10 @@ class Cart * title="Base Discount Total", * description="Base Discount Total of the Cart", * example="10.00" + * type="string" * ) * - * @var float + * @var string */ private $base_discount; @@ -304,6 +318,7 @@ class Cart * title="Formatted Base Discount Total", * description="Formatted Base Discount Total of the Cart", * example="$10.00" + * type="string" * ) * * @var string @@ -335,7 +350,9 @@ class Cart /** * @OA\Property( * title="Order's Customer", - * description="Order's Customer" + * description="Order's Customer", + * type="object", + * ref="#/components/schemas/Customer" * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Customer\Customer @@ -346,16 +363,20 @@ class Cart * @OA\Property( * title="Cart Items", * description="Cart Items" + * type="array", + * @OA\Items(ref="#/components/schemas/CartItem") * ) * - * @var \Webkul\RestApi\Docs\Shop\Models\Customer\CartItem + * @var \Webkul\RestApi\Docs\Shop\Models\Customer\CartItem[] */ private $items; /** * @OA\Property( * title="Cart Shipping Rate", - * description="Selected cart's shipping rate" + * description="Selected cart's shipping rate", + * type="object", + * ref="#/components/schemas/CartShippingRate" * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Customer\CartShippingRate @@ -366,6 +387,8 @@ class Cart * @OA\Property( * title="Cart Payment", * description="Selected cart's payment" + * type="object", + * ref="#/components/schemas/CartPayment" * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Customer\CartPayment @@ -375,7 +398,9 @@ class Cart /** * @OA\Property( * title="Cart Billing Address", - * description="Cart billing address" + * description="Cart billing address", + * type="object", + * ref="#/components/schemas/CartAddress" * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Customer\CartAddress @@ -385,7 +410,9 @@ class Cart /** * @OA\Property( * title="Cart Shipping Address", - * description="Cart shipping address" + * description="Cart shipping address", + * type="object", + * ref="#/components/schemas/CartAddress" * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Customer\CartAddress diff --git a/src/Docs/Shop/Models/Customer/Order.php b/src/Docs/Shop/Models/Customer/Order.php index 7943e2ca..43a9aa92 100755 --- a/src/Docs/Shop/Models/Customer/Order.php +++ b/src/Docs/Shop/Models/Customer/Order.php @@ -114,10 +114,11 @@ class Order * @OA\Property( * title="Grand Total", * description="Grand Total of the Order", - * example="10.00" + * example="10.00", + * type="string" * ) * - * @var float + * @var string */ private $grand_total; @@ -126,9 +127,10 @@ class Order * title="Formatted Grand Total", * description="Formatted Grand Total of the Order", * example="$10.00" + * type="string" * ) * - * @var float + * @var string */ private $formatted_grand_total; @@ -137,9 +139,10 @@ class Order * title="Base Grand Total", * description="Base Grand Total of the Order", * example="10.00" + * type="string" * ) * - * @var float + * @var string */ private $base_grand_total; @@ -148,6 +151,7 @@ class Order * title="Formatted Base Grand Total", * description="Formatted Base Grand Total of the Order", * example="$10.00" + * type="string" * ) * * @var string @@ -158,9 +162,11 @@ class Order * @OA\Property( * title="Order Items", * description="Order Items" + * type="array", + * @OA\Items(ref="#/components/schemas/OrderItem") * ) * - * @var \Webkul\RestApi\Docs\Shop\Models\Customer\OrderItem + * @var \Webkul\RestApi\Docs\Shop\Models\Customer\OrderItem[] */ private $items; diff --git a/src/Docs/Shop/Models/Customer/OrderItem.php b/src/Docs/Shop/Models/Customer/OrderItem.php index 89f4a5b9..43a11075 100755 --- a/src/Docs/Shop/Models/Customer/OrderItem.php +++ b/src/Docs/Shop/Models/Customer/OrderItem.php @@ -142,9 +142,10 @@ class OrderItem * title="Ordered Item Price", * description="Price of ordered item", * example="18.63", + * type="string" * ) * - * @var float + * @var string */ private $price; @@ -152,7 +153,8 @@ class OrderItem * @OA\Property( * title="Formatted Price", * description="Formatted Price of the Order Item", - * example="€18.63" + * example="€18.63", + * type="string" * ) * * @var string @@ -163,10 +165,11 @@ class OrderItem * @OA\Property( * title="Base Price", * description="Base price of the Order Item", - * example="20.45" + * example="20.45", + * type="string" * ) * - * @var float + * @var string */ private $base_price; @@ -174,7 +177,8 @@ class OrderItem * @OA\Property( * title="Formatted Base Price", * description="Formatted Base price of the Order Item", - * example="$20.45" + * example="$20.45", + * type="string" * ) * * @var string @@ -186,9 +190,10 @@ class OrderItem * title="Ordered Item Total", * description="Total of ordered item", * example="37.26", + * type="string" * ) * - * @var float + * @var string */ private $total; @@ -197,6 +202,7 @@ class OrderItem * title="Formatted Ordered Item Total", * description="Formatted total of ordered item", * example="€37.26", + * type="string" * ) * * @var string @@ -208,9 +214,10 @@ class OrderItem * title="Base Total", * description="Base total of the Order Item", * example="42.95" + * type="string" * ) * - * @var float + * @var string */ private $base_total; @@ -230,9 +237,10 @@ class OrderItem * title="Total Invoiced of Ordered Item", * description="Total invoiced amount of ordered item", * example="20.45", + * type="string" * ) * - * @var float + * @var string */ private $total_invoiced; @@ -241,6 +249,7 @@ class OrderItem * title="Total Base Invoiced of Ordered Item", * description="Total base invoiced amount of ordered item", * example="$20.45", + * type="string" * ) * * @var string @@ -252,9 +261,10 @@ class OrderItem * title="Total Refunded Amount of Ordered Item", * description="Total refunded amount of ordered item", * example="20.45", + * type="string" * ) * - * @var float + * @var string */ private $amount_refunded; @@ -263,6 +273,7 @@ class OrderItem * title="Total Base Refunded Amount of Ordered Item", * description="Total base refunded amount of ordered item", * example="$20.45", + * type="string" * ) * * @var string @@ -274,9 +285,10 @@ class OrderItem * title="Tax Percentage Applied On Ordered Item", * description="Tax percentage that applied on order item", * example="10%", + * type="string" * ) * - * @var float + * @var string */ private $tax_percent; @@ -285,9 +297,10 @@ class OrderItem * title="Tax Amount of Ordered Item", * description="Tax amount of ordered item", * example="2.045", + * type="string" * ) * - * @var float + * @var string */ private $tax_amount; @@ -296,6 +309,7 @@ class OrderItem * title="Base Tax Amount Of Ordered Item", * description="Base tax amount of ordered item", * example="$2.045", + * type="string" * ) * * @var string From 18621f4ce3fd910ae184651ea0521c33af8411b0 Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Fri, 16 May 2025 15:16:46 +0300 Subject: [PATCH 4/8] Improve wishlist --- .../Customer/WishlistController.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Docs/Shop/Controllers/Customer/WishlistController.php b/src/Docs/Shop/Controllers/Customer/WishlistController.php index 2ca47dac..3ed3ef55 100755 --- a/src/Docs/Shop/Controllers/Customer/WishlistController.php +++ b/src/Docs/Shop/Controllers/Customer/WishlistController.php @@ -22,7 +22,22 @@ class WishlistController * @OA\Property( * property="data", * type="array", - * @OA\Items(ref="#/components/schemas/Wishlist") + * @OA\Items( + * @OA\Property(property="id", type="integer"), + * @OA\Property(property="product", type="object", ref="#/components/schemas/Product"), + * @OA\Property( + * property="created_at", + * example="2020-01-27 17:50:45", + * format="datetime", + * type="string" + * ), + * @OA\Property( + * property="updated_at", + * example="2020-01-27 17:50:45", + * format="datetime", + * type="string" + * ) + * ) * ) * ) * ), @@ -67,7 +82,7 @@ public function get() * mediaType="application/json", * * @OA\Schema( - * + * @OA\Property(property="product_id", type="integer", example=1, required=true), * @OA\Property( * property="additional", * type="array", @@ -88,10 +103,8 @@ public function get() * type="array", * * @OA\Items( - * * @OA\Property(property="selected_configurable_option", type="integer"), * @OA\Property(property="quantity", type="integer"), - * @OA\Property(property="product_id", type="integer"), * @OA\Property( * property="super_attribute", * type="array", From f5a4b86fcd3a43865d4031c5795b154a7580482a Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Fri, 16 May 2025 15:20:08 +0300 Subject: [PATCH 5/8] Fix attribute options --- src/Docs/Shop/Models/Catalog/Attribute.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Docs/Shop/Models/Catalog/Attribute.php b/src/Docs/Shop/Models/Catalog/Attribute.php index 6066dab2..20127873 100755 --- a/src/Docs/Shop/Models/Catalog/Attribute.php +++ b/src/Docs/Shop/Models/Catalog/Attribute.php @@ -82,12 +82,12 @@ class Attribute /** * @OA\Property( * title="Options", - * description="Attribute's options" + * description="Attribute's options", * type="array", * @OA\Items(ref="#/components/schemas/AttributeOption") * ) * - * @var \Webkul\RestApi\Docs\Shop\Models\Catalog\AttributeOption + * @var \Webkul\RestApi\Docs\Shop\Models\Catalog\AttributeOption[] */ public $options; From e0e6eb307dc4ad829a6975ae58eb502a9aaa8b68 Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Fri, 16 May 2025 15:31:51 +0300 Subject: [PATCH 6/8] Fix CS --- .../Shop/Controllers/Customer/WishlistController.php | 4 ++-- src/Docs/Shop/Models/Customer/Cart.php | 12 ++++++------ src/Docs/Shop/Models/Customer/Order.php | 8 ++++---- src/Docs/Shop/Models/Customer/OrderItem.php | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Docs/Shop/Controllers/Customer/WishlistController.php b/src/Docs/Shop/Controllers/Customer/WishlistController.php index 3ed3ef55..2a48430c 100755 --- a/src/Docs/Shop/Controllers/Customer/WishlistController.php +++ b/src/Docs/Shop/Controllers/Customer/WishlistController.php @@ -82,14 +82,14 @@ public function get() * mediaType="application/json", * * @OA\Schema( - * @OA\Property(property="product_id", type="integer", example=1, required=true), + * required={"product_id"}, + * @OA\Property(property="product_id", type="integer", example=1), * @OA\Property( * property="additional", * type="array", * example={ * "selected_configurable_option": 2, * "quantity": 1, - * "product_id": 1, * "super_attribute": { * "attribute_id_1": "attribute_option_id_1", * "attribute_id_2": "attribute_option_id_2" diff --git a/src/Docs/Shop/Models/Customer/Cart.php b/src/Docs/Shop/Models/Customer/Cart.php index 81b76cd0..26bcf385 100755 --- a/src/Docs/Shop/Models/Customer/Cart.php +++ b/src/Docs/Shop/Models/Customer/Cart.php @@ -197,7 +197,7 @@ class Cart * @OA\Property( * title="Formatted Sub Total", * description="Formatted Sub Total of the Cart", - * example="$10.00" + * example="$10.00", * type="string" * ) * @@ -269,7 +269,7 @@ class Cart * @OA\Property( * title="Formatted Base Tax Total", * description="Formatted Base Tax Total of the Cart", - * example="$10.00" + * example="$10.00", * type="string" * ) * @@ -305,7 +305,7 @@ class Cart * @OA\Property( * title="Base Discount Total", * description="Base Discount Total of the Cart", - * example="10.00" + * example="10.00", * type="string" * ) * @@ -317,7 +317,7 @@ class Cart * @OA\Property( * title="Formatted Base Discount Total", * description="Formatted Base Discount Total of the Cart", - * example="$10.00" + * example="$10.00", * type="string" * ) * @@ -362,7 +362,7 @@ class Cart /** * @OA\Property( * title="Cart Items", - * description="Cart Items" + * description="Cart Items", * type="array", * @OA\Items(ref="#/components/schemas/CartItem") * ) @@ -386,7 +386,7 @@ class Cart /** * @OA\Property( * title="Cart Payment", - * description="Selected cart's payment" + * description="Selected cart's payment", * type="object", * ref="#/components/schemas/CartPayment" * ) diff --git a/src/Docs/Shop/Models/Customer/Order.php b/src/Docs/Shop/Models/Customer/Order.php index 43a9aa92..9f5bd034 100755 --- a/src/Docs/Shop/Models/Customer/Order.php +++ b/src/Docs/Shop/Models/Customer/Order.php @@ -126,7 +126,7 @@ class Order * @OA\Property( * title="Formatted Grand Total", * description="Formatted Grand Total of the Order", - * example="$10.00" + * example="$10.00", * type="string" * ) * @@ -138,7 +138,7 @@ class Order * @OA\Property( * title="Base Grand Total", * description="Base Grand Total of the Order", - * example="10.00" + * example="10.00", * type="string" * ) * @@ -150,7 +150,7 @@ class Order * @OA\Property( * title="Formatted Base Grand Total", * description="Formatted Base Grand Total of the Order", - * example="$10.00" + * example="$10.00", * type="string" * ) * @@ -161,7 +161,7 @@ class Order /** * @OA\Property( * title="Order Items", - * description="Order Items" + * description="Order Items", * type="array", * @OA\Items(ref="#/components/schemas/OrderItem") * ) diff --git a/src/Docs/Shop/Models/Customer/OrderItem.php b/src/Docs/Shop/Models/Customer/OrderItem.php index 43a11075..0ef8f4d9 100755 --- a/src/Docs/Shop/Models/Customer/OrderItem.php +++ b/src/Docs/Shop/Models/Customer/OrderItem.php @@ -213,7 +213,7 @@ class OrderItem * @OA\Property( * title="Base Total", * description="Base total of the Order Item", - * example="42.95" + * example="42.95", * type="string" * ) * From 664015c9c56f17858c82ddf0ec5010f8f38be5ed Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Sat, 17 May 2025 11:31:56 +0300 Subject: [PATCH 7/8] Add type options --- .../Customer/WishlistController.php | 9 ++ src/Docs/Shop/Models/Core/Theme.php | 112 ++++++++++++++- .../Shop/Models/Core/ThemeTranslation.php | 135 ++++++++++++++++++ .../V1/Shop/Customer/WishlistController.php | 29 ++-- src/Resources/lang/en/app.php | 11 +- 5 files changed, 280 insertions(+), 16 deletions(-) create mode 100644 src/Docs/Shop/Models/Core/ThemeTranslation.php diff --git a/src/Docs/Shop/Controllers/Customer/WishlistController.php b/src/Docs/Shop/Controllers/Customer/WishlistController.php index 2a48430c..df93998f 100755 --- a/src/Docs/Shop/Controllers/Customer/WishlistController.php +++ b/src/Docs/Shop/Controllers/Customer/WishlistController.php @@ -166,6 +166,15 @@ public function store() * ) * ), * + * @OA\RequestBody( + * @OA\MediaType( + * mediaType="application/json", + * @OA\Schema( + * @OA\Property(property="quantity", type="integer", example=1, nullable=true) + * ) + * ) + * ), + * * @OA\Response( * response=200, * description="Successful operation", diff --git a/src/Docs/Shop/Models/Core/Theme.php b/src/Docs/Shop/Models/Core/Theme.php index 27e1aa98..20284000 100644 --- a/src/Docs/Shop/Models/Core/Theme.php +++ b/src/Docs/Shop/Models/Core/Theme.php @@ -22,6 +22,18 @@ class Theme */ public $id; + /** + * @OA\Property( + * title="Theme code", + * description="Theme code", + * type="string", + * example="default" + * ) + * + * @var string + */ + public $theme_code; + /** * @OA\Property( * title="channel_id", @@ -39,7 +51,8 @@ class Theme * title="type", * description="type", * example="image_carousel", - * type="string" + * type="string", + * enum={"image_carousel", "static_content", "category_carousel", "product_carousel", "footer_links", "services_content"} * ) * * @var string @@ -107,4 +120,101 @@ class Theme * @var int */ public $sort_order; + + /** + * @OA\Property( + * title="Options", + * description="Variable structure depending on theme type", + * additionalProperties=true, + * type="object", + * oneOf={ + * @OA\Schema( + * title="Image Carousel Options", + * @OA\Property( + * property="images", + * type="array", + * @OA\Items( + * @OA\Property(property="link", type="string"), + * @OA\Property(property="image", type="string"), + * @OA\Property(property="title", type="string") + * ) + * ) + * ), + * @OA\Schema( + * title="Static Content Options", + * @OA\Property(property="css", type="string"), + * @OA\Property(property="html", type="string") + * ), + * @OA\Schema( + * title="Category Carousel Options", + * @OA\Property( + * property="filters", + * type="object", + * @OA\Property(property="sort", type="string"), + * @OA\Property(property="limit", type="integer"), + * @OA\Property(property="parent_id", type="integer") + * ) + * ), + * @OA\Schema( + * title="Product Carousel Options", + * @OA\Property(property="title", type="string"), + * @OA\Property( + * property="filters", + * type="object", + * @OA\Property(property="new", type="integer"), + * @OA\Property(property="sort", type="string"), + * @OA\Property(property="limit", type="integer") + * ) + * ), + * @OA\Schema( + * title="Footer Links Options", + * @OA\Property( + * property="column_1", + * type="array", + * @OA\Items( + * @OA\Property(property="url", type="string"), + * @OA\Property(property="title", type="string"), + * @OA\Property(property="sort_order", type="integer") + * ) + * ), + * @OA\Property( + * property="column_2", + * type="array", + * @OA\Items( + * @OA\Property(property="url", type="string"), + * @OA\Property(property="title", type="string"), + * @OA\Property(property="sort_order", type="integer") + * ) + * ) + * ), + * @OA\Schema( + * title="Services Content Options", + * @OA\Property( + * property="services", + * type="array", + * @OA\Items( + * @OA\Property(property="title", type="string"), + * @OA\Property(property="description", type="string"), + * @OA\Property(property="service_icon", type="string") + * ) + * ) + * ) + * } + * ) + * + * @var array + */ + public $options; + + /** + * @OA\Property( + * title="Translations", + * description="Theme translations", + * type="array", + * @OA\Items(ref="#/components/schemas/ThemeTranslation") + * ) + * + * @var array + */ + public $translations; } diff --git a/src/Docs/Shop/Models/Core/ThemeTranslation.php b/src/Docs/Shop/Models/Core/ThemeTranslation.php new file mode 100644 index 00000000..34a49a31 --- /dev/null +++ b/src/Docs/Shop/Models/Core/ThemeTranslation.php @@ -0,0 +1,135 @@ +input('quantity')); + try { + $result = Cart::moveToCart($wishlistItem, $request->input('quantity')); - if ($result) { - $cart = Cart::getCart(); + if ($result) { + $cart = Cart::getCart(); + + return response([ + 'data' => $cart ? new CartResource($cart) : null, + 'message' => trans('rest-api::app.shop.wishlist.moved'), + ]); + } return response([ - 'data' => $cart ? new CartResource($cart) : null, - 'message' => trans('rest-api::app.shop.wishlist.moved'), - ]); - } + 'message' => trans('rest-api::app.shop.wishlist.option-missing'), + ], 400); + } catch (Throwable $throwable) { + report($throwable); - return response([ - 'message' => trans('rest-api::app.shop.wishlist.option-missing'), - ], 400); + return response([ + 'message' => trans('rest-api::app.shop.wishlist.unknown-failure'), + ], 400); + } } /** diff --git a/src/Resources/lang/en/app.php b/src/Resources/lang/en/app.php index ac4390da..50eb86b1 100755 --- a/src/Resources/lang/en/app.php +++ b/src/Resources/lang/en/app.php @@ -495,11 +495,12 @@ ], 'wishlist' => [ - 'moved' => 'Item successfully moved To cart.', - 'option-missing' => 'Product options are missing, so item can not be moved to the wishlist.', - 'removed' => 'Item Successfully Removed From Wishlist.', - 'remove-fail' => 'Item Cannot Be Removed From Wishlist.', - 'success' => 'Item Successfully Added To Wishlist.', + 'moved' => 'Item successfully moved To cart.', + 'option-missing' => 'Product options are missing, so item can not be moved to the wishlist.', + 'removed' => 'Item Successfully Removed From Wishlist.', + 'remove-fail' => 'Item Cannot Be Removed From Wishlist.', + 'success' => 'Item Successfully Added To Wishlist.', + 'unknown-failure' => 'Something went wrong!', 'error' => [ 'security-warning' => 'Suspicious activity found!', From 1633f8bb88fc3d529a3eb176062454bbdd2e4263 Mon Sep 17 00:00:00 2001 From: Serhii Andriichuk Date: Wed, 21 May 2025 15:10:22 +0300 Subject: [PATCH 8/8] Add actual fields for the product image resource --- src/Docs/Shop/Models/Catalog/Product.php | 4 ++- src/Docs/Shop/Models/Catalog/ProductImage.php | 35 ------------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/src/Docs/Shop/Models/Catalog/Product.php b/src/Docs/Shop/Models/Catalog/Product.php index 744ba3a1..250f1d06 100755 --- a/src/Docs/Shop/Models/Catalog/Product.php +++ b/src/Docs/Shop/Models/Catalog/Product.php @@ -115,7 +115,9 @@ class Product /** * @OA\Property( * title="Images", - * description="Product's images" + * description="Product's images", + * type="array", + * @OA\Items(ref="#/components/schemas/ProductImage") * ) * * @var \Webkul\RestApi\Docs\Shop\Models\Catalog\ProductImage diff --git a/src/Docs/Shop/Models/Catalog/ProductImage.php b/src/Docs/Shop/Models/Catalog/ProductImage.php index d323de1e..a17af7d2 100755 --- a/src/Docs/Shop/Models/Catalog/ProductImage.php +++ b/src/Docs/Shop/Models/Catalog/ProductImage.php @@ -22,17 +22,6 @@ class ProductImage */ public $id; - /** - * @OA\Property( - * title="Type", - * description="Image type", - * enum={"images"} - * ) - * - * @var string - */ - protected $type; - /** * @OA\Property( * title="Path", @@ -98,28 +87,4 @@ class ProductImage * @var string */ protected $large_image_url; - - /** - * @OA\Property( - * title="Product ID", - * description="Product ID", - * format="int64", - * example=1 - * ) - * - * @var int - */ - public $product_id; - - /** - * @OA\Property( - * title="Position", - * description="Image position", - * format="int64", - * example=0 - * ) - * - * @var int - */ - public $position; }