mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
[csharp-netcore] Improved Multimap
and ClientUtils
implementation (#5122)
* Improvement Multimap impl * Fixed missing semi-colon * Fixed compile error using .NET Standard 2.0 * Fixed compile error using .NET Standard 2.0 * Update sample projects * Apply modifications to additional code flows
This commit is contained in:
parent
26c9c64634
commit
f356de606b
@ -2,13 +2,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
{{#useCompareNetObjects}}
|
||||
using KellermanSoftware.CompareNetObjects;
|
||||
{{/useCompareNetObjects}}
|
||||
@ -58,15 +55,11 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
var parameters = new Multimap<string, string>();
|
||||
|
||||
if (IsCollection(value) && collectionFormat == "multi")
|
||||
if (value is ICollection collection && collectionFormat == "multi")
|
||||
{
|
||||
var valueCollection = value as IEnumerable;
|
||||
if (valueCollection != null)
|
||||
foreach (var item in collection)
|
||||
{
|
||||
foreach (var item in valueCollection)
|
||||
{
|
||||
parameters.Add(name, ParameterToString(item));
|
||||
}
|
||||
parameters.Add(name, ParameterToString(item));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -87,49 +80,26 @@ namespace {{packageName}}.Client
|
||||
/// <returns>Formatted string.</returns>
|
||||
public static string ParameterToString(object obj, IReadableConfiguration configuration = null)
|
||||
{
|
||||
if (obj is DateTime)
|
||||
if (obj is DateTime dateTime)
|
||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
// For example: 2009-06-15T13:45:30.0000000
|
||||
return ((DateTime)obj).ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
else if (obj is DateTimeOffset)
|
||||
return dateTime.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
if (obj is DateTimeOffset dateTimeOffset)
|
||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
// For example: 2009-06-15T13:45:30.0000000
|
||||
return ((DateTimeOffset)obj).ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
else if (obj is bool)
|
||||
return (bool)obj ? "true" : "false";
|
||||
else
|
||||
{
|
||||
if (obj is IList)
|
||||
{
|
||||
var list = obj as IList;
|
||||
var flattenedString = new StringBuilder();
|
||||
foreach (var param in list)
|
||||
{
|
||||
if (flattenedString.Length > 0)
|
||||
flattenedString.Append(",");
|
||||
flattenedString.Append(param);
|
||||
}
|
||||
return flattenedString.ToString();
|
||||
}
|
||||
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
if (obj is bool boolean)
|
||||
return boolean ? "true" : "false";
|
||||
if (obj is ICollection collection)
|
||||
return string.Join(",", collection.Cast<object>());
|
||||
|
||||
return Convert.ToString(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if generic object is a collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns>True if object is a collection type</returns>
|
||||
private static bool IsCollection(object value)
|
||||
{
|
||||
return value is IList || value is ICollection;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URL encode a string
|
||||
/// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50
|
||||
@ -172,7 +142,7 @@ namespace {{packageName}}.Client
|
||||
/// <returns>Encoded string.</returns>
|
||||
public static string Base64Encode(string text)
|
||||
{
|
||||
return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
||||
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -182,14 +152,9 @@ namespace {{packageName}}.Client
|
||||
/// <returns>Byte array</returns>
|
||||
public static byte[] ReadAsBytes(Stream inputStream)
|
||||
{
|
||||
byte[] buf = new byte[16*1024];
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
int count;
|
||||
while ((count = inputStream.Read(buf, 0, buf.Length)) > 0)
|
||||
{
|
||||
ms.Write(buf, 0, count);
|
||||
}
|
||||
inputStream.CopyTo(ms);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
{{^net35}}using System.Collections.Concurrent;{{/net35}}
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace {{packageName}}.Client
|
||||
@ -10,13 +9,13 @@ namespace {{packageName}}.Client
|
||||
/// <summary>
|
||||
/// A dictionary in which one key has many associated values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the key</typeparam>
|
||||
/// <typeparam name="TKey">The type of the key</typeparam>
|
||||
/// <typeparam name="TValue">The type of the value associated with the key.</typeparam>
|
||||
public class Multimap<T, TValue> : IDictionary<T, IList<TValue>>
|
||||
public class Multimap<TKey, TValue> : IDictionary<TKey, IList<TValue>>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly {{^net35}}Concurrent{{/net35}}Dictionary<T, IList<TValue>> _dictionary;
|
||||
private readonly Dictionary<TKey, IList<TValue>> _dictionary;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@ -27,16 +26,16 @@ namespace {{packageName}}.Client
|
||||
/// </summary>
|
||||
public Multimap()
|
||||
{
|
||||
_dictionary = new {{^net35}}Concurrent{{/net35}}Dictionary<T, IList<TValue>>();
|
||||
_dictionary = new Dictionary<TKey, IList<TValue>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with comparer.
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public Multimap(IEqualityComparer<T> comparer)
|
||||
public Multimap(IEqualityComparer<TKey> comparer)
|
||||
{
|
||||
_dictionary = new {{^net35}}Concurrent{{/net35}}Dictionary<T, IList<TValue>>(comparer);
|
||||
_dictionary = new Dictionary<TKey, IList<TValue>>(comparer);
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
@ -47,7 +46,7 @@ namespace {{packageName}}.Client
|
||||
/// To get the enumerator.
|
||||
/// </summary>
|
||||
/// <returns>Enumerator</returns>
|
||||
public IEnumerator<KeyValuePair<T, IList<TValue>>> GetEnumerator()
|
||||
public IEnumerator<KeyValuePair<TKey, IList<TValue>>> GetEnumerator()
|
||||
{
|
||||
return _dictionary.GetEnumerator();
|
||||
}
|
||||
@ -68,12 +67,25 @@ namespace {{packageName}}.Client
|
||||
/// Add values to Multimap
|
||||
/// </summary>
|
||||
/// <param name="item">Key value pair</param>
|
||||
public void Add(KeyValuePair<T, IList<TValue>> item)
|
||||
public void Add(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
if (!TryAdd(item.Key, item.Value))
|
||||
throw new InvalidOperationException("Could not add values to Multimap.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Multimap to Multimap
|
||||
/// </summary>
|
||||
/// <param name="multimap">Multimap</param>
|
||||
public void Add(Multimap<TKey, TValue> multimap)
|
||||
{
|
||||
foreach (var item in multimap)
|
||||
{
|
||||
if (!TryAdd(item.Key, item.Value))
|
||||
throw new InvalidOperationException("Could not add values to Multimap.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear Multimap
|
||||
/// </summary>
|
||||
@ -88,7 +100,7 @@ namespace {{packageName}}.Client
|
||||
/// <param name="item">Key value pair</param>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
/// <returns>true if the Multimap contains the item; otherwise, false.</returns>
|
||||
public bool Contains(KeyValuePair<T, IList<TValue>> item)
|
||||
public bool Contains(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -101,7 +113,7 @@ namespace {{packageName}}.Client
|
||||
/// from Multimap. The array must have zero-based indexing.</param>
|
||||
/// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
public void CopyTo(KeyValuePair<T, IList<TValue>>[] array, int arrayIndex)
|
||||
public void CopyTo(KeyValuePair<TKey, IList<TValue>>[] array, int arrayIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -112,7 +124,7 @@ namespace {{packageName}}.Client
|
||||
/// <param name="item">Key value pair</param>
|
||||
/// <returns>true if the item is successfully removed; otherwise, false.</returns>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
public bool Remove(KeyValuePair<T, IList<TValue>> item)
|
||||
public bool Remove(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -120,24 +132,12 @@ namespace {{packageName}}.Client
|
||||
/// <summary>
|
||||
/// Gets the number of items contained in the Multimap.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Count;
|
||||
}
|
||||
}
|
||||
public int Count => _dictionary.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the Multimap is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item with the provided key and value to the Multimap.
|
||||
@ -145,12 +145,11 @@ namespace {{packageName}}.Client
|
||||
/// <param name="key">The object to use as the key of the item to add.</param>
|
||||
/// <param name="value">The object to use as the value of the item to add.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when couldn't add the value to Multimap.</exception>
|
||||
public void Add(T key, IList<TValue> value)
|
||||
public void Add(TKey key, IList<TValue> value)
|
||||
{
|
||||
if (value != null && value.Count > 0)
|
||||
{
|
||||
IList<TValue> list;
|
||||
if (_dictionary.TryGetValue(key, out list))
|
||||
if (_dictionary.TryGetValue(key, out var list))
|
||||
{
|
||||
foreach (var k in value) list.Add(k);
|
||||
}
|
||||
@ -169,7 +168,7 @@ namespace {{packageName}}.Client
|
||||
/// <param name="key">The key to locate in the Multimap.</param>
|
||||
/// <returns>true if the Multimap contains an item with
|
||||
/// the key; otherwise, false.</returns>
|
||||
public bool ContainsKey(T key)
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _dictionary.ContainsKey(key);
|
||||
}
|
||||
@ -179,10 +178,9 @@ namespace {{packageName}}.Client
|
||||
/// </summary>
|
||||
/// <param name="key">The key to locate in the Multimap.</param>
|
||||
/// <returns>true if the item is successfully removed; otherwise, false.</returns>
|
||||
public bool Remove(T key)
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
IList<TValue> list;
|
||||
return TryRemove(key, out list);
|
||||
return TryRemove(key, out var _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -194,7 +192,7 @@ namespace {{packageName}}.Client
|
||||
/// This parameter is passed uninitialized.</param>
|
||||
/// <returns> true if the object that implements Multimap contains
|
||||
/// an item with the specified key; otherwise, false.</returns>
|
||||
public bool TryGetValue(T key, out IList<TValue> value)
|
||||
public bool TryGetValue(TKey key, out IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryGetValue(key, out value);
|
||||
}
|
||||
@ -204,36 +202,21 @@ namespace {{packageName}}.Client
|
||||
/// </summary>
|
||||
/// <param name="key">The key of the item to get or set.</param>
|
||||
/// <returns>The value of the specified key.</returns>
|
||||
public IList<TValue> this[T key]
|
||||
public IList<TValue> this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary[key];
|
||||
}
|
||||
set { _dictionary[key] = value; }
|
||||
get => _dictionary[key];
|
||||
set => _dictionary[key] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Collections.Generic.ICollection containing the keys of the Multimap.
|
||||
/// </summary>
|
||||
public ICollection<T> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Keys;
|
||||
}
|
||||
}
|
||||
public ICollection<TKey> Keys => _dictionary.Keys;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Collections.Generic.ICollection containing the values of the Multimap.
|
||||
/// </summary>
|
||||
public ICollection<IList<TValue>> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Values;
|
||||
}
|
||||
}
|
||||
public ICollection<IList<TValue>> Values => _dictionary.Values;
|
||||
|
||||
/// <summary>
|
||||
/// Copy the items of the Multimap to an System.Array,
|
||||
@ -244,7 +227,7 @@ namespace {{packageName}}.Client
|
||||
/// <param name="index">The zero-based index in array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection) _dictionary).CopyTo(array, index);
|
||||
((ICollection)_dictionary).CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -253,19 +236,17 @@ namespace {{packageName}}.Client
|
||||
/// <param name="key">The object to use as the key of the item to add.</param>
|
||||
/// <param name="value">The object to use as the value of the item to add.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when couldn't add value to Multimap.</exception>
|
||||
public void Add(T key, TValue value)
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
IList<TValue> list;
|
||||
if (_dictionary.TryGetValue(key, out list))
|
||||
if (_dictionary.TryGetValue(key, out var list))
|
||||
{
|
||||
list.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new List<TValue>();
|
||||
list.Add(value);
|
||||
list = new List<TValue> { value };
|
||||
if (!TryAdd(key, list))
|
||||
throw new InvalidOperationException("Could not add value to Multimap.");
|
||||
}
|
||||
@ -279,45 +260,27 @@ namespace {{packageName}}.Client
|
||||
/**
|
||||
* Helper method to encapsulate generator differences between dictionary types.
|
||||
*/
|
||||
private bool TryRemove(T key, out IList<TValue> value)
|
||||
private bool TryRemove(TKey key, out IList<TValue> value)
|
||||
{
|
||||
{{^net35}}return _dictionary.TryRemove(key, out value);{{/net35}}
|
||||
{{#net35}}try
|
||||
{
|
||||
_dictionary.TryGetValue(key, out value);
|
||||
_dictionary.Remove(key);
|
||||
}
|
||||
#pragma warning disable 168
|
||||
catch (ArgumentException e)
|
||||
#pragma warning restore 168
|
||||
{
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;{{/net35}}
|
||||
_dictionary.TryGetValue(key, out value);
|
||||
return _dictionary.Remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to encapsulate generator differences between dictionary types.
|
||||
*/
|
||||
private bool TryAdd(T key, IList<TValue> value)
|
||||
private bool TryAdd(TKey key, IList<TValue> value)
|
||||
{
|
||||
{{^net35}}return _dictionary.TryAdd(key, value);{{/net35}}
|
||||
{{#net35}}
|
||||
try
|
||||
{
|
||||
_dictionary.Add(key, value);
|
||||
}
|
||||
#pragma warning disable 168
|
||||
catch (ArgumentException e)
|
||||
#pragma warning restore 168
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
{{/net35}}
|
||||
}
|
||||
#endregion Private Members
|
||||
}
|
||||
|
@ -268,23 +268,11 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{^vendorExtensions.x-csharp-value-type}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
foreach (var _kvp in {{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
}
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{#vendorExtensions.x-csharp-value-type}}
|
||||
foreach (var _kvp in {{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
@ -333,13 +321,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{#isKeyInQuery}}
|
||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
foreach (var _kvp in {{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
@ -438,23 +420,11 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{^vendorExtensions.x-csharp-value-type}}
|
||||
if ({{paramName}} != null)
|
||||
{
|
||||
foreach (var _kvp in {{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
}
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{#vendorExtensions.x-csharp-value-type}}
|
||||
foreach (var _kvp in {{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
@ -503,13 +473,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{#isKeyInQuery}}
|
||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
foreach (var _kvp in {{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add({{packageName}}.Client.ClientUtils.ParameterToMultiMap("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
|
@ -1567,13 +1567,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (query != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query));
|
||||
}
|
||||
localVarRequestOptions.Data = body;
|
||||
|
||||
@ -1639,13 +1633,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (query != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query));
|
||||
}
|
||||
localVarRequestOptions.Data = body;
|
||||
|
||||
@ -2110,43 +2098,19 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (enumQueryStringArray != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray));
|
||||
}
|
||||
if (enumQueryString != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString));
|
||||
}
|
||||
if (enumQueryInteger != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger));
|
||||
}
|
||||
if (enumQueryDouble != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble));
|
||||
}
|
||||
if (enumHeaderStringArray != null)
|
||||
localVarRequestOptions.HeaderParameters.Add("enum_header_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderStringArray)); // header parameter
|
||||
@ -2227,43 +2191,19 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (enumQueryStringArray != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray));
|
||||
}
|
||||
if (enumQueryString != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString));
|
||||
}
|
||||
if (enumQueryInteger != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger));
|
||||
}
|
||||
if (enumQueryDouble != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble));
|
||||
}
|
||||
if (enumHeaderStringArray != null)
|
||||
localVarRequestOptions.HeaderParameters.Add("enum_header_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderStringArray)); // header parameter
|
||||
@ -2336,39 +2276,15 @@ namespace Org.OpenAPITools.Api
|
||||
var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);
|
||||
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup));
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group));
|
||||
if (stringGroup != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup));
|
||||
}
|
||||
if (int64Group != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group));
|
||||
}
|
||||
localVarRequestOptions.HeaderParameters.Add("required_boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(requiredBooleanGroup)); // header parameter
|
||||
if (booleanGroup != null)
|
||||
@ -2433,39 +2349,15 @@ namespace Org.OpenAPITools.Api
|
||||
foreach (var _accept in _accepts)
|
||||
localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
|
||||
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup));
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group));
|
||||
if (stringGroup != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup));
|
||||
}
|
||||
if (int64Group != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group));
|
||||
}
|
||||
localVarRequestOptions.HeaderParameters.Add("required_boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(requiredBooleanGroup)); // header parameter
|
||||
if (booleanGroup != null)
|
||||
@ -2797,53 +2689,23 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (pipe != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe));
|
||||
}
|
||||
if (ioutil != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil));
|
||||
}
|
||||
if (http != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http));
|
||||
}
|
||||
if (url != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url));
|
||||
}
|
||||
if (context != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context));
|
||||
}
|
||||
|
||||
|
||||
@ -2925,53 +2787,23 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (pipe != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe));
|
||||
}
|
||||
if (ioutil != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil));
|
||||
}
|
||||
if (http != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http));
|
||||
}
|
||||
if (url != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url));
|
||||
}
|
||||
if (context != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context));
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,13 +244,7 @@ namespace Org.OpenAPITools.Api
|
||||
// authentication (api_key_query) required
|
||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")));
|
||||
}
|
||||
|
||||
// make the HTTP request
|
||||
@ -313,13 +307,7 @@ namespace Org.OpenAPITools.Api
|
||||
// authentication (api_key_query) required
|
||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")));
|
||||
}
|
||||
|
||||
// make the HTTP request
|
||||
|
@ -851,13 +851,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
@ -924,13 +918,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
@ -996,13 +984,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
@ -1069,13 +1051,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
|
@ -1100,23 +1100,11 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username));
|
||||
}
|
||||
if (password != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password));
|
||||
}
|
||||
|
||||
|
||||
@ -1183,23 +1171,11 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username));
|
||||
}
|
||||
if (password != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password));
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,13 +11,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using KellermanSoftware.CompareNetObjects;
|
||||
|
||||
namespace Org.OpenAPITools.Client
|
||||
@ -63,15 +60,11 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var parameters = new Multimap<string, string>();
|
||||
|
||||
if (IsCollection(value) && collectionFormat == "multi")
|
||||
if (value is ICollection collection && collectionFormat == "multi")
|
||||
{
|
||||
var valueCollection = value as IEnumerable;
|
||||
if (valueCollection != null)
|
||||
foreach (var item in collection)
|
||||
{
|
||||
foreach (var item in valueCollection)
|
||||
{
|
||||
parameters.Add(name, ParameterToString(item));
|
||||
}
|
||||
parameters.Add(name, ParameterToString(item));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -92,49 +85,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// <returns>Formatted string.</returns>
|
||||
public static string ParameterToString(object obj, IReadableConfiguration configuration = null)
|
||||
{
|
||||
if (obj is DateTime)
|
||||
if (obj is DateTime dateTime)
|
||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
// For example: 2009-06-15T13:45:30.0000000
|
||||
return ((DateTime)obj).ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
else if (obj is DateTimeOffset)
|
||||
return dateTime.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
if (obj is DateTimeOffset dateTimeOffset)
|
||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
// For example: 2009-06-15T13:45:30.0000000
|
||||
return ((DateTimeOffset)obj).ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
else if (obj is bool)
|
||||
return (bool)obj ? "true" : "false";
|
||||
else
|
||||
{
|
||||
if (obj is IList)
|
||||
{
|
||||
var list = obj as IList;
|
||||
var flattenedString = new StringBuilder();
|
||||
foreach (var param in list)
|
||||
{
|
||||
if (flattenedString.Length > 0)
|
||||
flattenedString.Append(",");
|
||||
flattenedString.Append(param);
|
||||
}
|
||||
return flattenedString.ToString();
|
||||
}
|
||||
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
if (obj is bool boolean)
|
||||
return boolean ? "true" : "false";
|
||||
if (obj is ICollection collection)
|
||||
return string.Join(",", collection.Cast<object>());
|
||||
|
||||
return Convert.ToString(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if generic object is a collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns>True if object is a collection type</returns>
|
||||
private static bool IsCollection(object value)
|
||||
{
|
||||
return value is IList || value is ICollection;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URL encode a string
|
||||
/// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50
|
||||
@ -177,7 +147,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <returns>Encoded string.</returns>
|
||||
public static string Base64Encode(string text)
|
||||
{
|
||||
return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
||||
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -187,14 +157,9 @@ namespace Org.OpenAPITools.Client
|
||||
/// <returns>Byte array</returns>
|
||||
public static byte[] ReadAsBytes(Stream inputStream)
|
||||
{
|
||||
byte[] buf = new byte[16*1024];
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
int count;
|
||||
while ((count = inputStream.Read(buf, 0, buf.Length)) > 0)
|
||||
{
|
||||
ms.Write(buf, 0, count);
|
||||
}
|
||||
inputStream.CopyTo(ms);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Org.OpenAPITools.Client
|
||||
@ -19,13 +18,13 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// A dictionary in which one key has many associated values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the key</typeparam>
|
||||
/// <typeparam name="TKey">The type of the key</typeparam>
|
||||
/// <typeparam name="TValue">The type of the value associated with the key.</typeparam>
|
||||
public class Multimap<T, TValue> : IDictionary<T, IList<TValue>>
|
||||
public class Multimap<TKey, TValue> : IDictionary<TKey, IList<TValue>>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly ConcurrentDictionary<T, IList<TValue>> _dictionary;
|
||||
private readonly Dictionary<TKey, IList<TValue>> _dictionary;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@ -36,16 +35,16 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
public Multimap()
|
||||
{
|
||||
_dictionary = new ConcurrentDictionary<T, IList<TValue>>();
|
||||
_dictionary = new Dictionary<TKey, IList<TValue>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with comparer.
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public Multimap(IEqualityComparer<T> comparer)
|
||||
public Multimap(IEqualityComparer<TKey> comparer)
|
||||
{
|
||||
_dictionary = new ConcurrentDictionary<T, IList<TValue>>(comparer);
|
||||
_dictionary = new Dictionary<TKey, IList<TValue>>(comparer);
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
@ -56,7 +55,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// To get the enumerator.
|
||||
/// </summary>
|
||||
/// <returns>Enumerator</returns>
|
||||
public IEnumerator<KeyValuePair<T, IList<TValue>>> GetEnumerator()
|
||||
public IEnumerator<KeyValuePair<TKey, IList<TValue>>> GetEnumerator()
|
||||
{
|
||||
return _dictionary.GetEnumerator();
|
||||
}
|
||||
@ -77,12 +76,25 @@ namespace Org.OpenAPITools.Client
|
||||
/// Add values to Multimap
|
||||
/// </summary>
|
||||
/// <param name="item">Key value pair</param>
|
||||
public void Add(KeyValuePair<T, IList<TValue>> item)
|
||||
public void Add(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
if (!TryAdd(item.Key, item.Value))
|
||||
throw new InvalidOperationException("Could not add values to Multimap.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Multimap to Multimap
|
||||
/// </summary>
|
||||
/// <param name="multimap">Multimap</param>
|
||||
public void Add(Multimap<TKey, TValue> multimap)
|
||||
{
|
||||
foreach (var item in multimap)
|
||||
{
|
||||
if (!TryAdd(item.Key, item.Value))
|
||||
throw new InvalidOperationException("Could not add values to Multimap.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear Multimap
|
||||
/// </summary>
|
||||
@ -97,7 +109,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="item">Key value pair</param>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
/// <returns>true if the Multimap contains the item; otherwise, false.</returns>
|
||||
public bool Contains(KeyValuePair<T, IList<TValue>> item)
|
||||
public bool Contains(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -110,7 +122,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// from Multimap. The array must have zero-based indexing.</param>
|
||||
/// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
public void CopyTo(KeyValuePair<T, IList<TValue>>[] array, int arrayIndex)
|
||||
public void CopyTo(KeyValuePair<TKey, IList<TValue>>[] array, int arrayIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -121,7 +133,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="item">Key value pair</param>
|
||||
/// <returns>true if the item is successfully removed; otherwise, false.</returns>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
public bool Remove(KeyValuePair<T, IList<TValue>> item)
|
||||
public bool Remove(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -129,24 +141,12 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Gets the number of items contained in the Multimap.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Count;
|
||||
}
|
||||
}
|
||||
public int Count => _dictionary.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the Multimap is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item with the provided key and value to the Multimap.
|
||||
@ -154,12 +154,11 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="key">The object to use as the key of the item to add.</param>
|
||||
/// <param name="value">The object to use as the value of the item to add.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when couldn't add the value to Multimap.</exception>
|
||||
public void Add(T key, IList<TValue> value)
|
||||
public void Add(TKey key, IList<TValue> value)
|
||||
{
|
||||
if (value != null && value.Count > 0)
|
||||
{
|
||||
IList<TValue> list;
|
||||
if (_dictionary.TryGetValue(key, out list))
|
||||
if (_dictionary.TryGetValue(key, out var list))
|
||||
{
|
||||
foreach (var k in value) list.Add(k);
|
||||
}
|
||||
@ -178,7 +177,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="key">The key to locate in the Multimap.</param>
|
||||
/// <returns>true if the Multimap contains an item with
|
||||
/// the key; otherwise, false.</returns>
|
||||
public bool ContainsKey(T key)
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _dictionary.ContainsKey(key);
|
||||
}
|
||||
@ -188,10 +187,9 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
/// <param name="key">The key to locate in the Multimap.</param>
|
||||
/// <returns>true if the item is successfully removed; otherwise, false.</returns>
|
||||
public bool Remove(T key)
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
IList<TValue> list;
|
||||
return TryRemove(key, out list);
|
||||
return TryRemove(key, out var _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -203,7 +201,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// This parameter is passed uninitialized.</param>
|
||||
/// <returns> true if the object that implements Multimap contains
|
||||
/// an item with the specified key; otherwise, false.</returns>
|
||||
public bool TryGetValue(T key, out IList<TValue> value)
|
||||
public bool TryGetValue(TKey key, out IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryGetValue(key, out value);
|
||||
}
|
||||
@ -213,36 +211,21 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
/// <param name="key">The key of the item to get or set.</param>
|
||||
/// <returns>The value of the specified key.</returns>
|
||||
public IList<TValue> this[T key]
|
||||
public IList<TValue> this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary[key];
|
||||
}
|
||||
set { _dictionary[key] = value; }
|
||||
get => _dictionary[key];
|
||||
set => _dictionary[key] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Collections.Generic.ICollection containing the keys of the Multimap.
|
||||
/// </summary>
|
||||
public ICollection<T> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Keys;
|
||||
}
|
||||
}
|
||||
public ICollection<TKey> Keys => _dictionary.Keys;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Collections.Generic.ICollection containing the values of the Multimap.
|
||||
/// </summary>
|
||||
public ICollection<IList<TValue>> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Values;
|
||||
}
|
||||
}
|
||||
public ICollection<IList<TValue>> Values => _dictionary.Values;
|
||||
|
||||
/// <summary>
|
||||
/// Copy the items of the Multimap to an System.Array,
|
||||
@ -253,7 +236,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="index">The zero-based index in array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection) _dictionary).CopyTo(array, index);
|
||||
((ICollection)_dictionary).CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -262,19 +245,17 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="key">The object to use as the key of the item to add.</param>
|
||||
/// <param name="value">The object to use as the value of the item to add.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when couldn't add value to Multimap.</exception>
|
||||
public void Add(T key, TValue value)
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
IList<TValue> list;
|
||||
if (_dictionary.TryGetValue(key, out list))
|
||||
if (_dictionary.TryGetValue(key, out var list))
|
||||
{
|
||||
list.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new List<TValue>();
|
||||
list.Add(value);
|
||||
list = new List<TValue> { value };
|
||||
if (!TryAdd(key, list))
|
||||
throw new InvalidOperationException("Could not add value to Multimap.");
|
||||
}
|
||||
@ -288,18 +269,27 @@ namespace Org.OpenAPITools.Client
|
||||
/**
|
||||
* Helper method to encapsulate generator differences between dictionary types.
|
||||
*/
|
||||
private bool TryRemove(T key, out IList<TValue> value)
|
||||
private bool TryRemove(TKey key, out IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryRemove(key, out value);
|
||||
|
||||
_dictionary.TryGetValue(key, out value);
|
||||
return _dictionary.Remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to encapsulate generator differences between dictionary types.
|
||||
*/
|
||||
private bool TryAdd(T key, IList<TValue> value)
|
||||
private bool TryAdd(TKey key, IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryAdd(key, value);
|
||||
try
|
||||
{
|
||||
_dictionary.Add(key, value);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion Private Members
|
||||
}
|
||||
|
@ -1567,13 +1567,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (query != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query));
|
||||
}
|
||||
localVarRequestOptions.Data = body;
|
||||
|
||||
@ -1639,13 +1633,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (query != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "query", query));
|
||||
}
|
||||
localVarRequestOptions.Data = body;
|
||||
|
||||
@ -2110,43 +2098,19 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (enumQueryStringArray != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray));
|
||||
}
|
||||
if (enumQueryString != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString));
|
||||
}
|
||||
if (enumQueryInteger != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger));
|
||||
}
|
||||
if (enumQueryDouble != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble));
|
||||
}
|
||||
if (enumHeaderStringArray != null)
|
||||
localVarRequestOptions.HeaderParameters.Add("enum_header_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderStringArray)); // header parameter
|
||||
@ -2227,43 +2191,19 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (enumQueryStringArray != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "enum_query_string_array", enumQueryStringArray));
|
||||
}
|
||||
if (enumQueryString != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_string", enumQueryString));
|
||||
}
|
||||
if (enumQueryInteger != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_integer", enumQueryInteger));
|
||||
}
|
||||
if (enumQueryDouble != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "enum_query_double", enumQueryDouble));
|
||||
}
|
||||
if (enumHeaderStringArray != null)
|
||||
localVarRequestOptions.HeaderParameters.Add("enum_header_string_array", Org.OpenAPITools.Client.ClientUtils.ParameterToString(enumHeaderStringArray)); // header parameter
|
||||
@ -2336,39 +2276,15 @@ namespace Org.OpenAPITools.Api
|
||||
var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);
|
||||
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
|
||||
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup));
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group));
|
||||
if (stringGroup != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup));
|
||||
}
|
||||
if (int64Group != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group));
|
||||
}
|
||||
localVarRequestOptions.HeaderParameters.Add("required_boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(requiredBooleanGroup)); // header parameter
|
||||
if (booleanGroup != null)
|
||||
@ -2433,39 +2349,15 @@ namespace Org.OpenAPITools.Api
|
||||
foreach (var _accept in _accepts)
|
||||
localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
|
||||
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_string_group", requiredStringGroup));
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "required_int64_group", requiredInt64Group));
|
||||
if (stringGroup != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "string_group", stringGroup));
|
||||
}
|
||||
if (int64Group != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "int64_group", int64Group));
|
||||
}
|
||||
localVarRequestOptions.HeaderParameters.Add("required_boolean_group", Org.OpenAPITools.Client.ClientUtils.ParameterToString(requiredBooleanGroup)); // header parameter
|
||||
if (booleanGroup != null)
|
||||
@ -2797,53 +2689,23 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (pipe != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe));
|
||||
}
|
||||
if (ioutil != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil));
|
||||
}
|
||||
if (http != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http));
|
||||
}
|
||||
if (url != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url));
|
||||
}
|
||||
if (context != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context));
|
||||
}
|
||||
|
||||
|
||||
@ -2925,53 +2787,23 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (pipe != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "pipe", pipe));
|
||||
}
|
||||
if (ioutil != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "ioutil", ioutil));
|
||||
}
|
||||
if (http != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("space", "http", http));
|
||||
}
|
||||
if (url != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "url", url));
|
||||
}
|
||||
if (context != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("multi", "context", context));
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,13 +244,7 @@ namespace Org.OpenAPITools.Api
|
||||
// authentication (api_key_query) required
|
||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")));
|
||||
}
|
||||
|
||||
// make the HTTP request
|
||||
@ -313,13 +307,7 @@ namespace Org.OpenAPITools.Api
|
||||
// authentication (api_key_query) required
|
||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "api_key_query", this.Configuration.GetApiKeyWithPrefix("api_key_query")));
|
||||
}
|
||||
|
||||
// make the HTTP request
|
||||
|
@ -851,13 +851,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
@ -924,13 +918,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (status != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "status", status));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
@ -996,13 +984,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
@ -1069,13 +1051,7 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("csv", "tags", tags));
|
||||
}
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
|
@ -1100,23 +1100,11 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username));
|
||||
}
|
||||
if (password != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password));
|
||||
}
|
||||
|
||||
|
||||
@ -1183,23 +1171,11 @@ namespace Org.OpenAPITools.Api
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "username", username));
|
||||
}
|
||||
if (password != null)
|
||||
{
|
||||
foreach (var _kvp in Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password))
|
||||
{
|
||||
foreach (var _kvpValue in _kvp.Value)
|
||||
{
|
||||
localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue);
|
||||
}
|
||||
}
|
||||
localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "password", password));
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,13 +11,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using KellermanSoftware.CompareNetObjects;
|
||||
|
||||
namespace Org.OpenAPITools.Client
|
||||
@ -63,15 +60,11 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var parameters = new Multimap<string, string>();
|
||||
|
||||
if (IsCollection(value) && collectionFormat == "multi")
|
||||
if (value is ICollection collection && collectionFormat == "multi")
|
||||
{
|
||||
var valueCollection = value as IEnumerable;
|
||||
if (valueCollection != null)
|
||||
foreach (var item in collection)
|
||||
{
|
||||
foreach (var item in valueCollection)
|
||||
{
|
||||
parameters.Add(name, ParameterToString(item));
|
||||
}
|
||||
parameters.Add(name, ParameterToString(item));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -92,49 +85,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// <returns>Formatted string.</returns>
|
||||
public static string ParameterToString(object obj, IReadableConfiguration configuration = null)
|
||||
{
|
||||
if (obj is DateTime)
|
||||
if (obj is DateTime dateTime)
|
||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
// For example: 2009-06-15T13:45:30.0000000
|
||||
return ((DateTime)obj).ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
else if (obj is DateTimeOffset)
|
||||
return dateTime.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
if (obj is DateTimeOffset dateTimeOffset)
|
||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
// For example: 2009-06-15T13:45:30.0000000
|
||||
return ((DateTimeOffset)obj).ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
else if (obj is bool)
|
||||
return (bool)obj ? "true" : "false";
|
||||
else
|
||||
{
|
||||
if (obj is IList)
|
||||
{
|
||||
var list = obj as IList;
|
||||
var flattenedString = new StringBuilder();
|
||||
foreach (var param in list)
|
||||
{
|
||||
if (flattenedString.Length > 0)
|
||||
flattenedString.Append(",");
|
||||
flattenedString.Append(param);
|
||||
}
|
||||
return flattenedString.ToString();
|
||||
}
|
||||
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
|
||||
if (obj is bool boolean)
|
||||
return boolean ? "true" : "false";
|
||||
if (obj is ICollection collection)
|
||||
return string.Join(",", collection.Cast<object>());
|
||||
|
||||
return Convert.ToString(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if generic object is a collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns>True if object is a collection type</returns>
|
||||
private static bool IsCollection(object value)
|
||||
{
|
||||
return value is IList || value is ICollection;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URL encode a string
|
||||
/// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50
|
||||
@ -177,7 +147,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <returns>Encoded string.</returns>
|
||||
public static string Base64Encode(string text)
|
||||
{
|
||||
return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
||||
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -187,14 +157,9 @@ namespace Org.OpenAPITools.Client
|
||||
/// <returns>Byte array</returns>
|
||||
public static byte[] ReadAsBytes(Stream inputStream)
|
||||
{
|
||||
byte[] buf = new byte[16*1024];
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
int count;
|
||||
while ((count = inputStream.Read(buf, 0, buf.Length)) > 0)
|
||||
{
|
||||
ms.Write(buf, 0, count);
|
||||
}
|
||||
inputStream.CopyTo(ms);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Org.OpenAPITools.Client
|
||||
@ -19,13 +18,13 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// A dictionary in which one key has many associated values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the key</typeparam>
|
||||
/// <typeparam name="TKey">The type of the key</typeparam>
|
||||
/// <typeparam name="TValue">The type of the value associated with the key.</typeparam>
|
||||
public class Multimap<T, TValue> : IDictionary<T, IList<TValue>>
|
||||
public class Multimap<TKey, TValue> : IDictionary<TKey, IList<TValue>>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly ConcurrentDictionary<T, IList<TValue>> _dictionary;
|
||||
private readonly Dictionary<TKey, IList<TValue>> _dictionary;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@ -36,16 +35,16 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
public Multimap()
|
||||
{
|
||||
_dictionary = new ConcurrentDictionary<T, IList<TValue>>();
|
||||
_dictionary = new Dictionary<TKey, IList<TValue>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with comparer.
|
||||
/// </summary>
|
||||
/// <param name="comparer"></param>
|
||||
public Multimap(IEqualityComparer<T> comparer)
|
||||
public Multimap(IEqualityComparer<TKey> comparer)
|
||||
{
|
||||
_dictionary = new ConcurrentDictionary<T, IList<TValue>>(comparer);
|
||||
_dictionary = new Dictionary<TKey, IList<TValue>>(comparer);
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
@ -56,7 +55,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// To get the enumerator.
|
||||
/// </summary>
|
||||
/// <returns>Enumerator</returns>
|
||||
public IEnumerator<KeyValuePair<T, IList<TValue>>> GetEnumerator()
|
||||
public IEnumerator<KeyValuePair<TKey, IList<TValue>>> GetEnumerator()
|
||||
{
|
||||
return _dictionary.GetEnumerator();
|
||||
}
|
||||
@ -77,12 +76,25 @@ namespace Org.OpenAPITools.Client
|
||||
/// Add values to Multimap
|
||||
/// </summary>
|
||||
/// <param name="item">Key value pair</param>
|
||||
public void Add(KeyValuePair<T, IList<TValue>> item)
|
||||
public void Add(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
if (!TryAdd(item.Key, item.Value))
|
||||
throw new InvalidOperationException("Could not add values to Multimap.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Multimap to Multimap
|
||||
/// </summary>
|
||||
/// <param name="multimap">Multimap</param>
|
||||
public void Add(Multimap<TKey, TValue> multimap)
|
||||
{
|
||||
foreach (var item in multimap)
|
||||
{
|
||||
if (!TryAdd(item.Key, item.Value))
|
||||
throw new InvalidOperationException("Could not add values to Multimap.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear Multimap
|
||||
/// </summary>
|
||||
@ -97,7 +109,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="item">Key value pair</param>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
/// <returns>true if the Multimap contains the item; otherwise, false.</returns>
|
||||
public bool Contains(KeyValuePair<T, IList<TValue>> item)
|
||||
public bool Contains(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -110,7 +122,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// from Multimap. The array must have zero-based indexing.</param>
|
||||
/// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
public void CopyTo(KeyValuePair<T, IList<TValue>>[] array, int arrayIndex)
|
||||
public void CopyTo(KeyValuePair<TKey, IList<TValue>>[] array, int arrayIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -121,7 +133,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="item">Key value pair</param>
|
||||
/// <returns>true if the item is successfully removed; otherwise, false.</returns>
|
||||
/// <exception cref="NotImplementedException">Method needs to be implemented</exception>
|
||||
public bool Remove(KeyValuePair<T, IList<TValue>> item)
|
||||
public bool Remove(KeyValuePair<TKey, IList<TValue>> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -129,24 +141,12 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Gets the number of items contained in the Multimap.
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Count;
|
||||
}
|
||||
}
|
||||
public int Count => _dictionary.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the Multimap is read-only.
|
||||
/// </summary>
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item with the provided key and value to the Multimap.
|
||||
@ -154,12 +154,11 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="key">The object to use as the key of the item to add.</param>
|
||||
/// <param name="value">The object to use as the value of the item to add.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when couldn't add the value to Multimap.</exception>
|
||||
public void Add(T key, IList<TValue> value)
|
||||
public void Add(TKey key, IList<TValue> value)
|
||||
{
|
||||
if (value != null && value.Count > 0)
|
||||
{
|
||||
IList<TValue> list;
|
||||
if (_dictionary.TryGetValue(key, out list))
|
||||
if (_dictionary.TryGetValue(key, out var list))
|
||||
{
|
||||
foreach (var k in value) list.Add(k);
|
||||
}
|
||||
@ -178,7 +177,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="key">The key to locate in the Multimap.</param>
|
||||
/// <returns>true if the Multimap contains an item with
|
||||
/// the key; otherwise, false.</returns>
|
||||
public bool ContainsKey(T key)
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _dictionary.ContainsKey(key);
|
||||
}
|
||||
@ -188,10 +187,9 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
/// <param name="key">The key to locate in the Multimap.</param>
|
||||
/// <returns>true if the item is successfully removed; otherwise, false.</returns>
|
||||
public bool Remove(T key)
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
IList<TValue> list;
|
||||
return TryRemove(key, out list);
|
||||
return TryRemove(key, out var _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -203,7 +201,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// This parameter is passed uninitialized.</param>
|
||||
/// <returns> true if the object that implements Multimap contains
|
||||
/// an item with the specified key; otherwise, false.</returns>
|
||||
public bool TryGetValue(T key, out IList<TValue> value)
|
||||
public bool TryGetValue(TKey key, out IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryGetValue(key, out value);
|
||||
}
|
||||
@ -213,36 +211,21 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
/// <param name="key">The key of the item to get or set.</param>
|
||||
/// <returns>The value of the specified key.</returns>
|
||||
public IList<TValue> this[T key]
|
||||
public IList<TValue> this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary[key];
|
||||
}
|
||||
set { _dictionary[key] = value; }
|
||||
get => _dictionary[key];
|
||||
set => _dictionary[key] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Collections.Generic.ICollection containing the keys of the Multimap.
|
||||
/// </summary>
|
||||
public ICollection<T> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Keys;
|
||||
}
|
||||
}
|
||||
public ICollection<TKey> Keys => _dictionary.Keys;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Collections.Generic.ICollection containing the values of the Multimap.
|
||||
/// </summary>
|
||||
public ICollection<IList<TValue>> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary.Values;
|
||||
}
|
||||
}
|
||||
public ICollection<IList<TValue>> Values => _dictionary.Values;
|
||||
|
||||
/// <summary>
|
||||
/// Copy the items of the Multimap to an System.Array,
|
||||
@ -253,7 +236,7 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="index">The zero-based index in array at which copying begins.</param>
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection) _dictionary).CopyTo(array, index);
|
||||
((ICollection)_dictionary).CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -262,19 +245,17 @@ namespace Org.OpenAPITools.Client
|
||||
/// <param name="key">The object to use as the key of the item to add.</param>
|
||||
/// <param name="value">The object to use as the value of the item to add.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when couldn't add value to Multimap.</exception>
|
||||
public void Add(T key, TValue value)
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
IList<TValue> list;
|
||||
if (_dictionary.TryGetValue(key, out list))
|
||||
if (_dictionary.TryGetValue(key, out var list))
|
||||
{
|
||||
list.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new List<TValue>();
|
||||
list.Add(value);
|
||||
list = new List<TValue> { value };
|
||||
if (!TryAdd(key, list))
|
||||
throw new InvalidOperationException("Could not add value to Multimap.");
|
||||
}
|
||||
@ -288,18 +269,27 @@ namespace Org.OpenAPITools.Client
|
||||
/**
|
||||
* Helper method to encapsulate generator differences between dictionary types.
|
||||
*/
|
||||
private bool TryRemove(T key, out IList<TValue> value)
|
||||
private bool TryRemove(TKey key, out IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryRemove(key, out value);
|
||||
|
||||
_dictionary.TryGetValue(key, out value);
|
||||
return _dictionary.Remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to encapsulate generator differences between dictionary types.
|
||||
*/
|
||||
private bool TryAdd(T key, IList<TValue> value)
|
||||
private bool TryAdd(TKey key, IList<TValue> value)
|
||||
{
|
||||
return _dictionary.TryAdd(key, value);
|
||||
try
|
||||
{
|
||||
_dictionary.Add(key, value);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion Private Members
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user