1616 *
1717 * The version of the OpenAPI document: v3
1818 * Generated by: https://openapi-generator.tech
19- * OpenAPI Generator version: 7.3 .0
19+ * Generator version: 7.12 .0
2020 */
2121
2222/**
@@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string
8585 }
8686
8787 # If none of the available Accept headers is of type "json", then just use all them
88- $ headersWithJson = preg_grep ( ' ~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~ ' , $ accept );
88+ $ headersWithJson = $ this -> selectJsonMimeList ( $ accept );
8989 if (count ($ headersWithJson ) === 0 ) {
9090 return implode (', ' , $ accept );
9191 }
@@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string
9595 return $ this ->getAcceptHeaderWithAdjustedWeight ($ accept , $ headersWithJson );
9696 }
9797
98+ /**
99+ * Detects whether a string contains a valid JSON mime type
100+ *
101+ * @param string $searchString
102+ * @return bool
103+ */
104+ public function isJsonMime (string $ searchString ): bool
105+ {
106+ return preg_match ('~^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)~ ' , $ searchString ) === 1 ;
107+ }
108+
109+ /**
110+ * Select all items from a list containing a JSON mime type
111+ *
112+ * @param array $mimeList
113+ * @return array
114+ */
115+ private function selectJsonMimeList (array $ mimeList ): array {
116+ $ jsonMimeList = [];
117+ foreach ($ mimeList as $ mime ) {
118+ if ($ this ->isJsonMime ($ mime )) {
119+ $ jsonMimeList [] = $ mime ;
120+ }
121+ }
122+ return $ jsonMimeList ;
123+ }
124+
125+
98126 /**
99127 * Create an Accept header string from the given "Accept" headers array, recalculating all weights
100128 *
0 commit comments