swagger-client 3.27.0 → 3.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1854,6 +1854,13 @@ function formatKeyValueBySerializationOption(key, value, skipEncoding, serializa
1854
1854
  const escape = skipEncoding ? false : serializationOption && serializationOption.allowReserved ? 'unsafe' : 'reserved';
1855
1855
  const encodeFn = v => (0,_execute_oas3_style_serializer_js__WEBPACK_IMPORTED_MODULE_2__.valueEncoder)(v, escape);
1856
1856
  const encodeKeyFn = skipEncoding ? k => k : k => encodeFn(k);
1857
+ if (typeof value === 'string') {
1858
+ try {
1859
+ value = JSON.parse(value);
1860
+ } catch {
1861
+ // can't parse the value so treat it as as a simple string
1862
+ }
1863
+ }
1857
1864
 
1858
1865
  // Primitive
1859
1866
  if (typeof value !== 'object') {
@@ -1924,6 +1931,18 @@ function encodeFormOrQuery(data) {
1924
1931
  * @param {string} parameterName - Parameter name
1925
1932
  * @return {object} encoded parameter names and values
1926
1933
  */
1934
+ if (typeof data === 'string') {
1935
+ try {
1936
+ data = JSON.parse(data);
1937
+ Object.entries(data).forEach(([key, value]) => {
1938
+ if (typeof value === 'object' && !Array.isArray(value)) {
1939
+ data[key] = JSON.stringify(value);
1940
+ }
1941
+ });
1942
+ } catch {
1943
+ return (0,_execute_oas3_style_serializer_js__WEBPACK_IMPORTED_MODULE_2__.valueEncoder)(data, 'reserved');
1944
+ }
1945
+ }
1927
1946
  const encodedQuery = Object.keys(data).reduce((result, parameterName) => {
1928
1947
  // eslint-disable-next-line no-restricted-syntax
1929
1948
  for (const [key, value] of formatKeyValue(parameterName, data[parameterName])) {