From 8c523190d86aa9d628e146b6dca22f8fcaa4097a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJoshua?= Date: Wed, 14 Aug 2024 12:50:00 -0400 Subject: [PATCH] Add demo JSON Schema properties to product endpoint schema --- .../Controllers/Version3/class-wc-rest-products-controller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php index b4a3a933faa..679fee1f3f4 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php @@ -919,6 +919,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller { 'description' => __( 'Product name.', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), + 'minLength' => 5, ), 'slug' => array( 'description' => __( 'Product slug.', 'woocommerce' ), @@ -995,6 +996,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller { 'description' => __( 'Stock Keeping Unit.', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), + 'pattern' => '^\S*$' ), 'global_unique_id' => array( 'description' => __( 'GTIN, UPC, EAN or ISBN.', 'woocommerce' ), @@ -1528,6 +1530,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller { ), ), ), + 'required' => array( 'name' ) ); $post_type_obj = get_post_type_object( $this->post_type );