From e15f1ef1308f65bf6097da61481b804bad347f4a Mon Sep 17 00:00:00 2001
From: Doron Guttman <doronguttman@users.noreply.github.com>
Date: Thu, 18 Jul 2024 16:35:06 -0400
Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20support=20for=20SEARC?=
 =?UTF-8?q?H=20verb?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

https://github.com/swagger-api/swagger-ui/issues/10085
---
 flavors/swagger-ui-react/README.md |  2 +-
 flavors/swagger-ui-react/index.jsx |  1 +
 src/core/config/defaults.js        |  1 +
 src/core/plugins/oas3/selectors.js |  1 +
 src/core/plugins/spec/selectors.js | 17 +++++++++--------
 src/style/_layout.scss             |  5 +++++
 src/style/_variables.scss          |  1 +
 7 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/flavors/swagger-ui-react/README.md b/flavors/swagger-ui-react/README.md
index db5caf61aa6..dc220284401 100644
--- a/flavors/swagger-ui-react/README.md
+++ b/flavors/swagger-ui-react/README.md
@@ -102,7 +102,7 @@ An array of objects that augment and modify Swagger UI's functionality. See Swag
 
 ⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
 
-#### `supportedSubmitMethods`: PropTypes.arrayOf(PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']))
+#### `supportedSubmitMethods`: PropTypes.arrayOf(PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace', 'search']))
 
 HTTP methods that have the Try it out feature enabled. An empty array disables Try it out for all operations. This does not filter the operations from the display.
 
diff --git a/flavors/swagger-ui-react/index.jsx b/flavors/swagger-ui-react/index.jsx
index 3ef06c70b6a..2c52d87a5b0 100644
--- a/flavors/swagger-ui-react/index.jsx
+++ b/flavors/swagger-ui-react/index.jsx
@@ -140,6 +140,7 @@ SwaggerUI.propTypes = {
       "head",
       "patch",
       "trace",
+      "search",
     ])
   ),
   queryConfigEnabled: PropTypes.bool,
diff --git a/src/core/config/defaults.js b/src/core/config/defaults.js
index b7daa8fd624..faf680a4ea5 100644
--- a/src/core/config/defaults.js
+++ b/src/core/config/defaults.js
@@ -62,6 +62,7 @@ const defaultOptions = Object.freeze({
     "head",
     "patch",
     "trace",
+    "search",
   ],
   queryConfigEnabled: false,
 
diff --git a/src/core/plugins/oas3/selectors.js b/src/core/plugins/oas3/selectors.js
index 594e5253713..f1e3dd70d57 100644
--- a/src/core/plugins/oas3/selectors.js
+++ b/src/core/plugins/oas3/selectors.js
@@ -305,4 +305,5 @@ export const validOperationMethods = constant([
   "head",
   "patch",
   "trace",
+  "search",
 ])
diff --git a/src/core/plugins/spec/selectors.js b/src/core/plugins/spec/selectors.js
index 62eddd38120..19af7d17ca4 100644
--- a/src/core/plugins/spec/selectors.js
+++ b/src/core/plugins/spec/selectors.js
@@ -6,7 +6,7 @@ import { fromJS, Set, Map, OrderedMap, List } from "immutable"
 const DEFAULT_TAG = "default"
 
 const OPERATION_METHODS = [
-  "get", "put", "post", "delete", "options", "head", "patch", "trace"
+  "get", "put", "post", "delete", "options", "head", "patch", "trace", "search"
 ]
 
 const state = state => {
@@ -262,7 +262,7 @@ export const operationsWithTags = createSelector(
 
 export const taggedOperations = (state) => ({ getConfigs }) => {
   let { tagsSorter, operationsSorter } = getConfigs()
-  return operationsWithTags(state)
+  const opsWithTags = operationsWithTags(state)
     .sortBy(
       (val, key) => key, // get the name of the tag to be passed to the sorter
       (tagA, tagB) => {
@@ -276,6 +276,7 @@ export const taggedOperations = (state) => ({ getConfigs }) => {
 
       return Map({ tagDetails: tagDetails(state, tag), operations: operations })
     })
+    return opsWithTags
 }
 
 export const responses = createSelector(
@@ -499,8 +500,8 @@ export const validationErrors = (state, pathMethod) => {
   const getErrorsWithPaths = (errors, path = []) => {
     const getNestedErrorsWithPaths = (e, path) => {
       const currPath = [...path, e.get("propKey") || e.get("index")]
-      return Map.isMap(e.get("error")) 
-        ? getErrorsWithPaths(e.get("error"), currPath) 
+      return Map.isMap(e.get("error"))
+        ? getErrorsWithPaths(e.get("error"), currPath)
         : { error: e.get("error"), path: currPath }
     }
 
@@ -511,10 +512,10 @@ export const validationErrors = (state, pathMethod) => {
 
   const formatError = (error, path, paramName) => {
     path = path.reduce((acc, curr) => {
-      return typeof curr === "number" 
-        ? `${acc}[${curr}]` 
-        : acc 
-        ? `${acc}.${curr}` 
+      return typeof curr === "number"
+        ? `${acc}[${curr}]`
+        : acc
+        ? `${acc}.${curr}`
         : curr
     }, "")
     return `For '${paramName}'${path ? ` at path '${path}'` : ""}: ${error}.`
diff --git a/src/style/_layout.scss b/src/style/_layout.scss
index b97083a2605..0661390af12 100644
--- a/src/style/_layout.scss
+++ b/src/style/_layout.scss
@@ -463,6 +463,11 @@
         @include method($_color-options);
     }
 
+    &.opblock-search
+    {
+        @include method($_color-search);
+    }
+
     &.opblock-deprecated
     {
         opacity: .6;
diff --git a/src/style/_variables.scss b/src/style/_variables.scss
index 6e5b9b746f6..3694ac1bab4 100644
--- a/src/style/_variables.scss
+++ b/src/style/_variables.scss
@@ -51,6 +51,7 @@ $_color-head: #9012fe !default;
 $_color-patch: #50e3c2 !default;
 $_color-disabled: #ebebeb !default;
 $_color-options: #0d5aa7 !default;
+$_color-search: #6179fe !default;
 
 // Authorize