mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #927 from wing328/csharp_file_response
[C# ] Add file response
This commit is contained in:
commit
5821e41185
@ -446,6 +446,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
operations.put("imports", imports);
|
||||
|
||||
// add a flag to indicate whether there's any {{import}}
|
||||
if (imports.size() > 0) {
|
||||
operations.put("hasImport", true);
|
||||
}
|
||||
|
||||
config.postProcessOperations(operations);
|
||||
if (objs.size() > 0) {
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
|
||||
|
@ -37,6 +37,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"string",
|
||||
"bool?",
|
||||
"double?",
|
||||
@ -53,6 +54,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Stream", // not really a primitive, we include it to avoid model import
|
||||
"Object")
|
||||
);
|
||||
instantiationTypes.put("array", "List");
|
||||
@ -68,7 +70,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("number", "double?");
|
||||
typeMapping.put("datetime", "DateTime?");
|
||||
typeMapping.put("date", "DateTime?");
|
||||
typeMapping.put("file", "string"); // path to file
|
||||
typeMapping.put("file", "Stream");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("list", "List");
|
||||
typeMapping.put("map", "Dictionary");
|
||||
@ -110,6 +112,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll"));
|
||||
supportingFiles.add(new SupportingFile("RestSharp.dll", "bin", "RestSharp.dll"));
|
||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
|
||||
}
|
||||
|
||||
@ -163,8 +166,24 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// camelize(lower) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,217 +1,337 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using RestSharp.Extensions;
|
||||
|
||||
namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// API client is mainly responible for making the HTTP call to the API backend
|
||||
/// </summary>
|
||||
public class ApiClient {
|
||||
|
||||
namespace {{packageName}}.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiClient"/> class.
|
||||
/// API client is mainly responible for making the HTTP call to the API backend.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiClient(String basePath="{{basePath}}") {
|
||||
this.basePath = basePath;
|
||||
this.restClient = new RestClient(this.basePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path.</value>
|
||||
public string basePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient
|
||||
/// </summary>
|
||||
/// <value>The RestClient.</value>
|
||||
public RestClient restClient { get; set; }
|
||||
|
||||
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
public Object CallApi(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody,
|
||||
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, String> FileParams, String[] AuthSettings) {
|
||||
var response = Task.Run(async () => {
|
||||
var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings);
|
||||
return resp;
|
||||
});
|
||||
return response.Result;
|
||||
}
|
||||
|
||||
public async Task<Object> CallApiAsync(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody,
|
||||
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, String> FileParams, String[] AuthSettings) {
|
||||
|
||||
var request = new RestRequest(Path, Method);
|
||||
|
||||
UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(KeyValuePair<string, string> defaultHeader in this.defaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in HeaderParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in QueryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in FormParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in FileParams)
|
||||
request.AddFile(param.Key, param.Value);
|
||||
|
||||
if (PostBody != null) {
|
||||
request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter
|
||||
}
|
||||
|
||||
return (Object) await restClient.ExecuteTaskAsync(request);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header
|
||||
/// </summary>
|
||||
/// <param name="key"> Header field name
|
||||
/// <param name="value"> Header field value
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value) {
|
||||
defaultHeaderMap.Add(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get default header
|
||||
/// </summary>
|
||||
/// <returns>Dictionary of default header</returns>
|
||||
public Dictionary<String, String> GetDefaultHeader() {
|
||||
return defaultHeaderMap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// escape string (url-encoded)
|
||||
/// </summary>
|
||||
/// <param name="str"> String to be escaped
|
||||
/// <returns>Escaped string</returns>
|
||||
public string EscapeString(string str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if parameter is DateTime, output in ISO8601 format
|
||||
/// if parameter is a list of string, join the list with ","
|
||||
/// otherwise just return the string
|
||||
/// </summary>
|
||||
/// <param name="obj"> The parameter (header, path, query, form)
|
||||
/// <returns>Formatted string</returns>
|
||||
public string ParameterToString(object obj)
|
||||
public class ApiClient
|
||||
{
|
||||
if (obj is DateTime) {
|
||||
return ((DateTime)obj).ToString ("u");
|
||||
} else if (obj is List<string>) {
|
||||
return String.Join(",", obj as List<string>);
|
||||
} else {
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object
|
||||
/// </summary>
|
||||
/// <param name="json"> JSON string
|
||||
/// <param name="type"> Object type
|
||||
/// <returns>Object representation of the JSON string</returns>
|
||||
public object Deserialize(string content, Type type) {
|
||||
if (type.GetType() == typeof(Object))
|
||||
return (Object)content;
|
||||
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(content, type);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <returns>JSON string</returns>
|
||||
public string Serialize(object obj) {
|
||||
try
|
||||
{
|
||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the API key with prefix
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <returns>API key with prefix</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKey)
|
||||
{
|
||||
var apiKeyValue = "";
|
||||
Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue);
|
||||
var apiKeyPrefix = "";
|
||||
if (Configuration.apiKeyPrefix.TryGetValue (apiKey, out apiKeyPrefix)) {
|
||||
return apiKeyPrefix + " " + apiKeyValue;
|
||||
} else {
|
||||
return apiKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update parameters based on authentication
|
||||
/// </summary>
|
||||
/// <param name="QueryParams">Query parameters</param>
|
||||
/// <param name="HeaderParams">Header parameters</param>
|
||||
/// <param name="AuthSettings">Authentication settings</param>
|
||||
public void UpdateParamsForAuth(Dictionary<String, String> QueryParams, Dictionary<String, String> HeaderParams, string[] AuthSettings) {
|
||||
if (AuthSettings == null || AuthSettings.Length == 0)
|
||||
return;
|
||||
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
foreach (string auth in AuthSettings) {
|
||||
// determine which one to use
|
||||
switch(auth) {
|
||||
{{#authMethods}}
|
||||
case "{{name}}":
|
||||
{{#isApiKey}}{{#isKeyInHeader}}HeaderParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}QueryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}HeaderParams["Authorization"] = "Basic " + Base64Encode(Configuration.username + ":" + Configuration.password);{{/isBasic}}
|
||||
{{#isOAuth}}//TODO support oauth{{/isOAuth}}
|
||||
break;
|
||||
{{/authMethods}}
|
||||
default:
|
||||
//TODO show warning about security definition not found
|
||||
break;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiClient" /> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiClient(String basePath="{{basePath}}")
|
||||
{
|
||||
BasePath = basePath;
|
||||
RestClient = new RestClient(BasePath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public string BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient.
|
||||
/// </summary>
|
||||
/// <value>An instance of the RestClient</value>
|
||||
public RestClient RestClient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default header.
|
||||
/// </summary>
|
||||
public Dictionary<String, String> DefaultHeader
|
||||
{
|
||||
get { return _defaultHeaderMap; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the HTTP request (Sync).
|
||||
/// </summary>
|
||||
/// <param name="path">URL path.</param>
|
||||
/// <param name="method">HTTP method.</param>
|
||||
/// <param name="queryParams">Query parameters.</param>
|
||||
/// <param name="postBody">HTTP body (POST request).</param>
|
||||
/// <param name="headerParams">Header parameters.</param>
|
||||
/// <param name="formParams">Form parameters.</param>
|
||||
/// <param name="fileParams">File parameters.</param>
|
||||
/// <param name="authSettings">Authentication settings.</param>
|
||||
/// <returns>Object</returns>
|
||||
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
||||
Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||
{
|
||||
|
||||
var request = new RestRequest(path, method);
|
||||
|
||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(var defaultHeader in _defaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(var param in headerParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(var param in queryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(var param in formParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(var param in fileParams)
|
||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||
|
||||
if (postBody != null) // http body (model) parameter
|
||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||
|
||||
return (Object)RestClient.Execute(request);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the asynchronous HTTP request.
|
||||
/// </summary>
|
||||
/// <param name="path">URL path.</param>
|
||||
/// <param name="method">HTTP method.</param>
|
||||
/// <param name="queryParams">Query parameters.</param>
|
||||
/// <param name="postBody">HTTP body (POST request).</param>
|
||||
/// <param name="headerParams">Header parameters.</param>
|
||||
/// <param name="formParams">Form parameters.</param>
|
||||
/// <param name="fileParams">File parameters.</param>
|
||||
/// <param name="authSettings">Authentication settings.</param>
|
||||
/// <returns>The Task instance.</returns>
|
||||
public async System.Threading.Tasks.Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||
{
|
||||
|
||||
var request = new RestRequest(path, method);
|
||||
|
||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(var defaultHeader in _defaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(var param in headerParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(var param in queryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(var param in formParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(var param in fileParams)
|
||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||
|
||||
if (postBody != null) // http body (model) parameter
|
||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||
|
||||
return (Object) await RestClient.ExecuteTaskAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header.
|
||||
/// </summary>
|
||||
/// <param name="key">Header field name.</param>
|
||||
/// <param name="value">Header field value.</param>
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value)
|
||||
{
|
||||
_defaultHeaderMap.Add(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Escape string (url-encoded).
|
||||
/// </summary>
|
||||
/// <param name="str">String to be escaped.</param>
|
||||
/// <returns>Escaped string.</returns>
|
||||
public string EscapeString(string str)
|
||||
{
|
||||
return HttpUtility.UrlEncode(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create FileParameter based on Stream.
|
||||
/// </summary>
|
||||
/// <param name="name">Parameter name.</param>
|
||||
/// <param name="stream">Input stream.</param>
|
||||
/// <returns>FileParameter.</returns>
|
||||
public FileParameter ParameterToFile(string name, Stream stream)
|
||||
{
|
||||
if (stream is FileStream)
|
||||
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
||||
else
|
||||
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If parameter is DateTime, output in ISO8601 format.
|
||||
/// If parameter is a list of string, join the list with ",".
|
||||
/// Otherwise just return the string.
|
||||
/// </summary>
|
||||
/// <param name="obj">The parameter (header, path, query, form).</param>
|
||||
/// <returns>Formatted string.</returns>
|
||||
public string ParameterToString(object obj)
|
||||
{
|
||||
if (obj is DateTime)
|
||||
return ((DateTime)obj).ToString ("u");
|
||||
else if (obj is List<string>)
|
||||
return String.Join(",", obj as List<string>);
|
||||
else
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object.
|
||||
/// </summary>
|
||||
/// <param name="content">HTTP body (e.g. string, JSON).</param>
|
||||
/// <param name="type">Object type.</param>
|
||||
/// <returns>Object representation of the JSON string.</returns>
|
||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null)
|
||||
{
|
||||
if (type == typeof(Object)) // return an object
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
if (type == typeof(Stream))
|
||||
{
|
||||
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
|
||||
? Path.GetTempPath()
|
||||
: Configuration.TempFolderPath;
|
||||
|
||||
var fileName = filePath + Guid.NewGuid();
|
||||
if (headers != null)
|
||||
{
|
||||
var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
var match = regex.Match(headers.ToString());
|
||||
if (match.Success)
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
|
||||
}
|
||||
File.WriteAllText(fileName, content);
|
||||
return new FileStream(fileName, FileMode.Open);
|
||||
|
||||
}
|
||||
|
||||
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||
{
|
||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
}
|
||||
|
||||
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||
{
|
||||
return ConvertType(content, type);
|
||||
}
|
||||
|
||||
// at this point, it must be a model (json)
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(content, type);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string.
|
||||
/// </summary>
|
||||
/// <param name="obj">Object.</param>
|
||||
/// <returns>JSON string.</returns>
|
||||
public string Serialize(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the API key with prefix.
|
||||
/// </summary>
|
||||
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
||||
/// <returns>API key with prefix.</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||
{
|
||||
var apiKeyValue = "";
|
||||
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
||||
var apiKeyPrefix = "";
|
||||
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
|
||||
return apiKeyPrefix + " " + apiKeyValue;
|
||||
else
|
||||
return apiKeyValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update parameters based on authentication.
|
||||
/// </summary>
|
||||
/// <param name="queryParams">Query parameters.</param>
|
||||
/// <param name="headerParams">Header parameters.</param>
|
||||
/// <param name="authSettings">Authentication settings.</param>
|
||||
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings)
|
||||
{
|
||||
if (authSettings == null || authSettings.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (string auth in authSettings)
|
||||
{
|
||||
// determine which one to use
|
||||
switch(auth)
|
||||
{
|
||||
{{#authMethods}}
|
||||
case "{{name}}":
|
||||
{{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}
|
||||
{{#isOAuth}}//TODO support oauth{{/isOAuth}}
|
||||
break;
|
||||
{{/authMethods}}
|
||||
default:
|
||||
//TODO show warning about security definition not found
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encode string in base64 format.
|
||||
/// </summary>
|
||||
/// <param name="text">String to be encoded.</param>
|
||||
/// <returns>Encoded string.</returns>
|
||||
public static string Base64Encode(string text)
|
||||
{
|
||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
return System.Convert.ToBase64String(textByte);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dynamically cast the object into target type.
|
||||
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
||||
/// </summary>
|
||||
/// <param name="source">Object to be casted</param>
|
||||
/// <param name="dest">Target type</param>
|
||||
/// <returns>Casted object</returns>
|
||||
public static dynamic ConvertType(dynamic source, Type dest) {
|
||||
return Convert.ChangeType(source, dest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encode string in base64 format
|
||||
/// </summary>
|
||||
/// <param name="text">String to be encoded</param>
|
||||
public static string Base64Encode(string text) {
|
||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
return System.Convert.ToBase64String(textByte);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,37 +5,43 @@ namespace {{packageName}}.Client {
|
||||
/// API Exception
|
||||
/// </summary>
|
||||
public class ApiException : Exception {
|
||||
/// <summary>
|
||||
/// Gets or sets the error code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The error code (HTTP status code).</value>
|
||||
public int ErrorCode { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the error code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The error code (HTTP status code).</value>
|
||||
public int ErrorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the error content (body json object)
|
||||
/// </summary>
|
||||
/// <value>The error content (Http response body).</value>
|
||||
public dynamic ErrorContent { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the error content (body json object)
|
||||
/// </summary>
|
||||
/// <value>The error content (Http response body).</value>
|
||||
public dynamic ErrorContent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiException() {}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiException() {}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</param>
|
||||
public ApiException(int errorCode, string message) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</param>
|
||||
public ApiException(int errorCode, string message) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
}
|
||||
|
||||
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
this.ErrorContent = errorContent;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</param>
|
||||
/// <param name="errorContent">Error content.</param>
|
||||
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
this.ErrorContent = errorContent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,51 +1,99 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// Represents a set of configuration settings
|
||||
/// </summary>
|
||||
public class Configuration{
|
||||
|
||||
namespace {{packageName}}.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Version of the package
|
||||
/// Represents a set of configuration settings
|
||||
/// </summary>
|
||||
public const string Version = "{{packageVersion}}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client. This is the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public static ApiClient apiClient = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication)
|
||||
/// </summary>
|
||||
/// <value>The username.</value>
|
||||
public static String username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password (HTTP basic authentication)
|
||||
/// </summary>
|
||||
/// <value>The password.</value>
|
||||
public static String password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API key based on the authentication name
|
||||
/// </summary>
|
||||
/// <value>The API key.</value>
|
||||
public static Dictionary<String, String> apiKey = new Dictionary<String, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
|
||||
/// </summary>
|
||||
/// <value>The prefix of the API key.</value>
|
||||
public static Dictionary<String, String> apiKeyPrefix = new Dictionary<String, String>();
|
||||
|
||||
|
||||
}
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Version of the package.
|
||||
/// </summary>
|
||||
/// <value>Version of the package.</value>
|
||||
public const string Version = "{{packageVersion}}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public static ApiClient DefaultApiClient = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication).
|
||||
/// </summary>
|
||||
/// <value>The username.</value>
|
||||
public static String Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password (HTTP basic authentication).
|
||||
/// </summary>
|
||||
/// <value>The password.</value>
|
||||
public static String Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API key based on the authentication name.
|
||||
/// </summary>
|
||||
/// <value>The API key.</value>
|
||||
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
||||
/// </summary>
|
||||
/// <value>The prefix of the API key.</value>
|
||||
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
||||
|
||||
private static string _tempFolderPath = Path.GetTempPath();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
||||
/// </summary>
|
||||
/// <value>Folder path.</value>
|
||||
public static String TempFolderPath
|
||||
{
|
||||
get { return _tempFolderPath; }
|
||||
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
_tempFolderPath = value;
|
||||
return;
|
||||
}
|
||||
|
||||
// create the directory if it does not exist
|
||||
if (!Directory.Exists(value))
|
||||
Directory.CreateDirectory(value);
|
||||
|
||||
// check if the path contains directory separator at the end
|
||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
||||
_tempFolderPath = value;
|
||||
else
|
||||
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string with essential information for debugging.
|
||||
/// </summary>
|
||||
public static String ToDebugReport()
|
||||
{
|
||||
String report = "C# SDK ({{packageName}}) Debug Report:\n";
|
||||
report += " OS: " + Environment.OSVersion + "\n";
|
||||
report += " .NET Framework Version: " + Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetReferencedAssemblies()
|
||||
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
||||
report += " Version of the API: {{version}}\n";
|
||||
report += " SDK Package Version: {{packageVersion}}\n";
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
15
modules/swagger-codegen/src/main/resources/csharp/README.md
Normal file
15
modules/swagger-codegen/src/main/resources/csharp/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
## Frameworks supported
|
||||
- .NET 3.5 or later
|
||||
- Windows Phone 7.1 (Mango)
|
||||
|
||||
## Dependencies
|
||||
- [RestSharp] (https://www.nuget.org/packages/RestSharp)
|
||||
- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/)
|
||||
|
||||
|
||||
NOTE: The DLLs included in the package may not be the latest version. We recommned using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
|
||||
```
|
||||
Install-Package RestSharp
|
||||
Install-Package Newtonsoft.Json
|
||||
```
|
||||
|
@ -1,173 +1,176 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using {{packageName}}.Client;
|
||||
using {{packageName}}.Model;
|
||||
{{#imports}}
|
||||
{{/imports}}
|
||||
{{#hasImport}}using {{packageName}}.Model;
|
||||
{{/hasImport}}
|
||||
|
||||
namespace {{packageName}}.Api {
|
||||
{{#operations}}
|
||||
|
||||
public interface I{{classname}} {
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
|
||||
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
|
||||
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
{{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public class {{classname}} : I{{classname}} {
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient"> an instance of ApiClient (optional)
|
||||
/// <returns></returns>
|
||||
public {{classname}}(ApiClient apiClient = null) {
|
||||
if (apiClient == null) { // use the default one in Configuration
|
||||
this.apiClient = Configuration.apiClient;
|
||||
} else {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public {{classname}}(String basePath)
|
||||
namespace {{packageName}}.Api
|
||||
{
|
||||
{{#operations}}
|
||||
public interface I{{classname}}
|
||||
{
|
||||
this.apiClient = new ApiClient(basePath);
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath) {
|
||||
this.apiClient.basePath = basePath;
|
||||
public class {{classname}} : I{{classname}}
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
||||
/// <returns></returns>
|
||||
public {{classname}}(ApiClient apiClient = null)
|
||||
{
|
||||
if (apiClient == null) // use the default one in Configuration
|
||||
this.ApiClient = Configuration.DefaultApiClient;
|
||||
else
|
||||
this.ApiClient = apiClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public {{classname}}(String basePath)
|
||||
{
|
||||
this.ApiClient = new ApiClient(basePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
this.ApiClient.BasePath = basePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath)
|
||||
{
|
||||
return this.ApiClient.BasePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>An instance of the ApiClient</param>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
var path = "{{path}}";
|
||||
path = path.Replace("{format}", "json");
|
||||
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
|
||||
{{/pathParams}}
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
|
||||
{{/queryParams}}
|
||||
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
|
||||
{{/headerParams}}
|
||||
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
||||
{{/bodyParam}}
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
else if (((int)response.StatusCode) == 0)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.ErrorMessage, response.ErrorMessage);
|
||||
|
||||
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}return;{{/returnType}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{
|
||||
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
var path = "{{path}}";
|
||||
path = path.Replace("{format}", "json");
|
||||
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
|
||||
{{/pathParams}}
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
|
||||
{{/queryParams}}
|
||||
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
|
||||
{{/headerParams}}
|
||||
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
||||
{{/bodyParam}}
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
|
||||
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}
|
||||
return;{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath) {
|
||||
return this.apiClient.basePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>The API client</value>
|
||||
public ApiClient apiClient {get; set;}
|
||||
|
||||
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
|
||||
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
var path = "{{path}}";
|
||||
path = path.Replace("{format}", "json");
|
||||
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", apiClient.ParameterToString({{{paramName}}}));
|
||||
{{/pathParams}}
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // query parameter
|
||||
{{/queryParams}}
|
||||
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // header parameter
|
||||
{{/headerParams}}
|
||||
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}postBody = apiClient.Serialize({{paramName}}); // http body (model) parameter
|
||||
{{/bodyParam}}
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
}
|
||||
{{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
|
||||
return;{{/returnType}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
|
||||
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||
public async {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
var path = "{{path}}";
|
||||
path = path.Replace("{format}", "json");
|
||||
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", apiClient.ParameterToString({{{paramName}}}));
|
||||
{{/pathParams}}
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // query parameter
|
||||
{{/queryParams}}
|
||||
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // header parameter
|
||||
{{/headerParams}}
|
||||
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}postBody = apiClient.Serialize({{paramName}}); // http body (model) parameter
|
||||
{{/bodyParam}}
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||
}
|
||||
{{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
|
||||
return;{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ namespace {{packageName}}.Model {
|
||||
[DataContract]
|
||||
public class {{classname}}{{#parent}} : {{{parent}}}{{/parent}} {
|
||||
{{#vars}}
|
||||
{{#description}}/* {{{description}}} */{{/description}}
|
||||
/// <summary>
|
||||
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
/// <value>{{{description}}}</value>{{/description}}
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
|
||||
public {{{datatype}}} {{name}} { get; set; }
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
## Frameworks supported
|
||||
- .NET 3.5 or later
|
||||
- Windows Phone 7.1 (Mango)
|
||||
|
||||
## Dependencies
|
||||
- [RestSharp] (https://www.nuget.org/packages/RestSharp)
|
||||
- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/)
|
||||
|
||||
|
||||
NOTE: The DLLs included in the package may not be the latest version. We recommned using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
|
||||
```
|
||||
Install-Package RestSharp
|
||||
Install-Package Newtonsoft.Json
|
||||
```
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,428 +1,433 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
namespace IO.Swagger.Api {
|
||||
|
||||
|
||||
public interface IStoreApi {
|
||||
namespace IO.Swagger.Api
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
Dictionary<String, int?> GetInventory ();
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
Task<Dictionary<String, int?>> GetInventoryAsync ();
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="Body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
Order PlaceOrder (Order Body);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="Body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
Task<Order> PlaceOrderAsync (Order Body);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
Order GetOrderById (string OrderId);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
Task<Order> GetOrderByIdAsync (string OrderId);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
void DeleteOrder (string OrderId);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOrderAsync (string OrderId);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public class StoreApi : IStoreApi {
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient"> an instance of ApiClient (optional)
|
||||
/// <returns></returns>
|
||||
public StoreApi(ApiClient apiClient = null) {
|
||||
if (apiClient == null) { // use the default one in Configuration
|
||||
this.apiClient = Configuration.apiClient;
|
||||
} else {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StoreApi(String basePath)
|
||||
public interface IStoreApi
|
||||
{
|
||||
this.apiClient = new ApiClient(basePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath) {
|
||||
this.apiClient.basePath = basePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath) {
|
||||
return this.apiClient.basePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>The API client</value>
|
||||
public ApiClient apiClient {get; set;}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
public Dictionary<String, int?> GetInventory () {
|
||||
|
||||
|
||||
|
||||
var path = "/store/inventory";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { "api_key" };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
||||
}
|
||||
return (Dictionary<String, int?>) apiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
public async Task<Dictionary<String, int?>> GetInventoryAsync () {
|
||||
|
||||
|
||||
|
||||
var path = "/store/inventory";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { "api_key" };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
||||
}
|
||||
return (Dictionary<String, int?>) apiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="Body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
public Order PlaceOrder (Order Body) {
|
||||
|
||||
|
||||
|
||||
var path = "/store/order";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
postBody = apiClient.Serialize(Body); // http body (model) parameter
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
||||
}
|
||||
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="Body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
public async Task<Order> PlaceOrderAsync (Order Body) {
|
||||
|
||||
|
||||
|
||||
var path = "/store/order";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
postBody = apiClient.Serialize(Body); // http body (model) parameter
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
||||
}
|
||||
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
public Order GetOrderById (string OrderId) {
|
||||
|
||||
|
||||
// verify the required parameter 'OrderId' is set
|
||||
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
||||
}
|
||||
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
public async Task<Order> GetOrderByIdAsync (string OrderId) {
|
||||
|
||||
|
||||
// verify the required parameter 'OrderId' is set
|
||||
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
||||
}
|
||||
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
public void DeleteOrder (string OrderId) {
|
||||
|
||||
|
||||
// verify the required parameter 'OrderId' is set
|
||||
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="OrderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOrderAsync (string OrderId) {
|
||||
|
||||
|
||||
// verify the required parameter 'OrderId' is set
|
||||
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, String>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400) {
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
Dictionary<String, int?> GetInventory ();
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
System.Threading.Tasks.Task<Dictionary<String, int?>> GetInventoryAsync ();
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
Order PlaceOrder (Order body);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
Order GetOrderById (string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
System.Threading.Tasks.Task<Order> GetOrderByIdAsync (string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
void DeleteOrder (string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
System.Threading.Tasks.Task DeleteOrderAsync (string orderId);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public class StoreApi : IStoreApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
||||
/// <returns></returns>
|
||||
public StoreApi(ApiClient apiClient = null)
|
||||
{
|
||||
if (apiClient == null) // use the default one in Configuration
|
||||
this.ApiClient = Configuration.DefaultApiClient;
|
||||
else
|
||||
this.ApiClient = apiClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StoreApi(String basePath)
|
||||
{
|
||||
this.ApiClient = new ApiClient(basePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
this.ApiClient.BasePath = basePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath)
|
||||
{
|
||||
return this.ApiClient.BasePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>An instance of the ApiClient</param>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
public Dictionary<String, int?> GetInventory ()
|
||||
{
|
||||
|
||||
|
||||
var path = "/store/inventory";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { "api_key" };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
||||
else if (((int)response.StatusCode) == 0)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
|
||||
|
||||
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <returns>Dictionary<String, int?></returns>
|
||||
public async System.Threading.Tasks.Task<Dictionary<String, int?>> GetInventoryAsync ()
|
||||
{
|
||||
|
||||
|
||||
var path = "/store/inventory";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { "api_key" };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
||||
|
||||
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
public Order PlaceOrder (Order body)
|
||||
{
|
||||
|
||||
|
||||
var path = "/store/order";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
postBody = ApiClient.Serialize(body); // http body (model) parameter
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
||||
else if (((int)response.StatusCode) == 0)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage);
|
||||
|
||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
/// <returns>Order</returns>
|
||||
public async System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body)
|
||||
{
|
||||
|
||||
|
||||
var path = "/store/order";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
postBody = ApiClient.Serialize(body); // http body (model) parameter
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
||||
|
||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
public Order GetOrderById (string orderId)
|
||||
{
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(orderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
||||
else if (((int)response.StatusCode) == 0)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage);
|
||||
|
||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
public async System.Threading.Tasks.Task<Order> GetOrderByIdAsync (string orderId)
|
||||
{
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(orderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
||||
|
||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
public void DeleteOrder (string orderId)
|
||||
{
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(orderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
||||
else if (((int)response.StatusCode) == 0)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task DeleteOrderAsync (string orderId)
|
||||
{
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
||||
|
||||
|
||||
var path = "/store/order/{orderId}";
|
||||
path = path.Replace("{format}", "json");
|
||||
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(orderId));
|
||||
|
||||
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, String>();
|
||||
var fileParams = new Dictionary<String, FileParameter>();
|
||||
String postBody = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
String[] authSettings = new String[] { };
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
if (((int)response.StatusCode) >= 400)
|
||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,222 +1,342 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using RestSharp.Extensions;
|
||||
|
||||
namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// API client is mainly responible for making the HTTP call to the API backend
|
||||
/// </summary>
|
||||
public class ApiClient {
|
||||
|
||||
namespace IO.Swagger.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiClient"/> class.
|
||||
/// API client is mainly responible for making the HTTP call to the API backend.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiClient(String basePath="http://petstore.swagger.io/v2") {
|
||||
this.basePath = basePath;
|
||||
this.restClient = new RestClient(this.basePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path.</value>
|
||||
public string basePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient
|
||||
/// </summary>
|
||||
/// <value>The RestClient.</value>
|
||||
public RestClient restClient { get; set; }
|
||||
|
||||
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
public Object CallApi(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody,
|
||||
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, String> FileParams, String[] AuthSettings) {
|
||||
var response = Task.Run(async () => {
|
||||
var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings);
|
||||
return resp;
|
||||
});
|
||||
return response.Result;
|
||||
}
|
||||
|
||||
public async Task<Object> CallApiAsync(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody,
|
||||
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, String> FileParams, String[] AuthSettings) {
|
||||
|
||||
var request = new RestRequest(Path, Method);
|
||||
|
||||
UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(KeyValuePair<string, string> defaultHeader in this.defaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in HeaderParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in QueryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in FormParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in FileParams)
|
||||
request.AddFile(param.Key, param.Value);
|
||||
|
||||
if (PostBody != null) {
|
||||
request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter
|
||||
}
|
||||
|
||||
return (Object) await restClient.ExecuteTaskAsync(request);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header
|
||||
/// </summary>
|
||||
/// <param name="key"> Header field name
|
||||
/// <param name="value"> Header field value
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value) {
|
||||
defaultHeaderMap.Add(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get default header
|
||||
/// </summary>
|
||||
/// <returns>Dictionary of default header</returns>
|
||||
public Dictionary<String, String> GetDefaultHeader() {
|
||||
return defaultHeaderMap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// escape string (url-encoded)
|
||||
/// </summary>
|
||||
/// <param name="str"> String to be escaped
|
||||
/// <returns>Escaped string</returns>
|
||||
public string EscapeString(string str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if parameter is DateTime, output in ISO8601 format
|
||||
/// if parameter is a list of string, join the list with ","
|
||||
/// otherwise just return the string
|
||||
/// </summary>
|
||||
/// <param name="obj"> The parameter (header, path, query, form)
|
||||
/// <returns>Formatted string</returns>
|
||||
public string ParameterToString(object obj)
|
||||
public class ApiClient
|
||||
{
|
||||
if (obj is DateTime) {
|
||||
return ((DateTime)obj).ToString ("u");
|
||||
} else if (obj is List<string>) {
|
||||
return String.Join(",", obj as List<string>);
|
||||
} else {
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object
|
||||
/// </summary>
|
||||
/// <param name="json"> JSON string
|
||||
/// <param name="type"> Object type
|
||||
/// <returns>Object representation of the JSON string</returns>
|
||||
public object Deserialize(string content, Type type) {
|
||||
if (type.GetType() == typeof(Object))
|
||||
return (Object)content;
|
||||
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(content, type);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <returns>JSON string</returns>
|
||||
public string Serialize(object obj) {
|
||||
try
|
||||
{
|
||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the API key with prefix
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <returns>API key with prefix</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKey)
|
||||
{
|
||||
var apiKeyValue = "";
|
||||
Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue);
|
||||
var apiKeyPrefix = "";
|
||||
if (Configuration.apiKeyPrefix.TryGetValue (apiKey, out apiKeyPrefix)) {
|
||||
return apiKeyPrefix + " " + apiKeyValue;
|
||||
} else {
|
||||
return apiKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update parameters based on authentication
|
||||
/// </summary>
|
||||
/// <param name="QueryParams">Query parameters</param>
|
||||
/// <param name="HeaderParams">Header parameters</param>
|
||||
/// <param name="AuthSettings">Authentication settings</param>
|
||||
public void UpdateParamsForAuth(Dictionary<String, String> QueryParams, Dictionary<String, String> HeaderParams, string[] AuthSettings) {
|
||||
if (AuthSettings == null || AuthSettings.Length == 0)
|
||||
return;
|
||||
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
foreach (string auth in AuthSettings) {
|
||||
// determine which one to use
|
||||
switch(auth) {
|
||||
|
||||
case "api_key":
|
||||
HeaderParams["api_key"] = GetApiKeyWithPrefix("api_key");
|
||||
|
||||
break;
|
||||
|
||||
case "petstore_auth":
|
||||
|
||||
//TODO support oauth
|
||||
break;
|
||||
|
||||
default:
|
||||
//TODO show warning about security definition not found
|
||||
break;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiClient" /> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiClient(String basePath="http://petstore.swagger.io/v2")
|
||||
{
|
||||
BasePath = basePath;
|
||||
RestClient = new RestClient(BasePath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public string BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient.
|
||||
/// </summary>
|
||||
/// <value>An instance of the RestClient</value>
|
||||
public RestClient RestClient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default header.
|
||||
/// </summary>
|
||||
public Dictionary<String, String> DefaultHeader
|
||||
{
|
||||
get { return _defaultHeaderMap; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the HTTP request (Sync).
|
||||
/// </summary>
|
||||
/// <param name="path">URL path.</param>
|
||||
/// <param name="method">HTTP method.</param>
|
||||
/// <param name="queryParams">Query parameters.</param>
|
||||
/// <param name="postBody">HTTP body (POST request).</param>
|
||||
/// <param name="headerParams">Header parameters.</param>
|
||||
/// <param name="formParams">Form parameters.</param>
|
||||
/// <param name="fileParams">File parameters.</param>
|
||||
/// <param name="authSettings">Authentication settings.</param>
|
||||
/// <returns>Object</returns>
|
||||
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
||||
Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||
{
|
||||
|
||||
var request = new RestRequest(path, method);
|
||||
|
||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(var defaultHeader in _defaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(var param in headerParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(var param in queryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(var param in formParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(var param in fileParams)
|
||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||
|
||||
if (postBody != null) // http body (model) parameter
|
||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||
|
||||
return (Object)RestClient.Execute(request);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the asynchronous HTTP request.
|
||||
/// </summary>
|
||||
/// <param name="path">URL path.</param>
|
||||
/// <param name="method">HTTP method.</param>
|
||||
/// <param name="queryParams">Query parameters.</param>
|
||||
/// <param name="postBody">HTTP body (POST request).</param>
|
||||
/// <param name="headerParams">Header parameters.</param>
|
||||
/// <param name="formParams">Form parameters.</param>
|
||||
/// <param name="fileParams">File parameters.</param>
|
||||
/// <param name="authSettings">Authentication settings.</param>
|
||||
/// <returns>The Task instance.</returns>
|
||||
public async System.Threading.Tasks.Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||
{
|
||||
|
||||
var request = new RestRequest(path, method);
|
||||
|
||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(var defaultHeader in _defaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(var param in headerParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(var param in queryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(var param in formParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(var param in fileParams)
|
||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||
|
||||
if (postBody != null) // http body (model) parameter
|
||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||
|
||||
return (Object) await RestClient.ExecuteTaskAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header.
|
||||
/// </summary>
|
||||
/// <param name="key">Header field name.</param>
|
||||
/// <param name="value">Header field value.</param>
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value)
|
||||
{
|
||||
_defaultHeaderMap.Add(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Escape string (url-encoded).
|
||||
/// </summary>
|
||||
/// <param name="str">String to be escaped.</param>
|
||||
/// <returns>Escaped string.</returns>
|
||||
public string EscapeString(string str)
|
||||
{
|
||||
return HttpUtility.UrlEncode(str);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create FileParameter based on Stream.
|
||||
/// </summary>
|
||||
/// <param name="name">Parameter name.</param>
|
||||
/// <param name="stream">Input stream.</param>
|
||||
/// <returns>FileParameter.</returns>
|
||||
public FileParameter ParameterToFile(string name, Stream stream)
|
||||
{
|
||||
if (stream is FileStream)
|
||||
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
||||
else
|
||||
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If parameter is DateTime, output in ISO8601 format.
|
||||
/// If parameter is a list of string, join the list with ",".
|
||||
/// Otherwise just return the string.
|
||||
/// </summary>
|
||||
/// <param name="obj">The parameter (header, path, query, form).</param>
|
||||
/// <returns>Formatted string.</returns>
|
||||
public string ParameterToString(object obj)
|
||||
{
|
||||
if (obj is DateTime)
|
||||
return ((DateTime)obj).ToString ("u");
|
||||
else if (obj is List<string>)
|
||||
return String.Join(",", obj as List<string>);
|
||||
else
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object.
|
||||
/// </summary>
|
||||
/// <param name="content">HTTP body (e.g. string, JSON).</param>
|
||||
/// <param name="type">Object type.</param>
|
||||
/// <returns>Object representation of the JSON string.</returns>
|
||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null)
|
||||
{
|
||||
if (type == typeof(Object)) // return an object
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
if (type == typeof(Stream))
|
||||
{
|
||||
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
|
||||
? Path.GetTempPath()
|
||||
: Configuration.TempFolderPath;
|
||||
|
||||
var fileName = filePath + Guid.NewGuid();
|
||||
if (headers != null)
|
||||
{
|
||||
var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
var match = regex.Match(headers.ToString());
|
||||
if (match.Success)
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
|
||||
}
|
||||
File.WriteAllText(fileName, content);
|
||||
return new FileStream(fileName, FileMode.Open);
|
||||
|
||||
}
|
||||
|
||||
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||
{
|
||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
}
|
||||
|
||||
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||
{
|
||||
return ConvertType(content, type);
|
||||
}
|
||||
|
||||
// at this point, it must be a model (json)
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(content, type);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string.
|
||||
/// </summary>
|
||||
/// <param name="obj">Object.</param>
|
||||
/// <returns>JSON string.</returns>
|
||||
public string Serialize(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the API key with prefix.
|
||||
/// </summary>
|
||||
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
||||
/// <returns>API key with prefix.</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||
{
|
||||
var apiKeyValue = "";
|
||||
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
||||
var apiKeyPrefix = "";
|
||||
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
|
||||
return apiKeyPrefix + " " + apiKeyValue;
|
||||
else
|
||||
return apiKeyValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update parameters based on authentication.
|
||||
/// </summary>
|
||||
/// <param name="queryParams">Query parameters.</param>
|
||||
/// <param name="headerParams">Header parameters.</param>
|
||||
/// <param name="authSettings">Authentication settings.</param>
|
||||
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings)
|
||||
{
|
||||
if (authSettings == null || authSettings.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (string auth in authSettings)
|
||||
{
|
||||
// determine which one to use
|
||||
switch(auth)
|
||||
{
|
||||
|
||||
case "api_key":
|
||||
headerParams["api_key"] = GetApiKeyWithPrefix("api_key");
|
||||
|
||||
break;
|
||||
|
||||
case "petstore_auth":
|
||||
|
||||
//TODO support oauth
|
||||
break;
|
||||
|
||||
default:
|
||||
//TODO show warning about security definition not found
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encode string in base64 format.
|
||||
/// </summary>
|
||||
/// <param name="text">String to be encoded.</param>
|
||||
/// <returns>Encoded string.</returns>
|
||||
public static string Base64Encode(string text)
|
||||
{
|
||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
return System.Convert.ToBase64String(textByte);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dynamically cast the object into target type.
|
||||
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
||||
/// </summary>
|
||||
/// <param name="source">Object to be casted</param>
|
||||
/// <param name="dest">Target type</param>
|
||||
/// <returns>Casted object</returns>
|
||||
public static dynamic ConvertType(dynamic source, Type dest) {
|
||||
return Convert.ChangeType(source, dest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encode string in base64 format
|
||||
/// </summary>
|
||||
/// <param name="text">String to be encoded</param>
|
||||
public static string Base64Encode(string text) {
|
||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
return System.Convert.ToBase64String(textByte);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,37 +5,43 @@ namespace IO.Swagger.Client {
|
||||
/// API Exception
|
||||
/// </summary>
|
||||
public class ApiException : Exception {
|
||||
/// <summary>
|
||||
/// Gets or sets the error code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The error code (HTTP status code).</value>
|
||||
public int ErrorCode { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the error code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The error code (HTTP status code).</value>
|
||||
public int ErrorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the error content (body json object)
|
||||
/// </summary>
|
||||
/// <value>The error content (Http response body).</value>
|
||||
public dynamic ErrorContent { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the error content (body json object)
|
||||
/// </summary>
|
||||
/// <value>The error content (Http response body).</value>
|
||||
public dynamic ErrorContent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiException() {}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiException() {}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</param>
|
||||
public ApiException(int errorCode, string message) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</param>
|
||||
public ApiException(int errorCode, string message) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
}
|
||||
|
||||
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
this.ErrorContent = errorContent;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</param>
|
||||
/// <param name="errorContent">Error content.</param>
|
||||
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
|
||||
this.ErrorCode = errorCode;
|
||||
this.ErrorContent = errorContent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,51 +1,99 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// Represents a set of configuration settings
|
||||
/// </summary>
|
||||
public class Configuration{
|
||||
|
||||
namespace IO.Swagger.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Version of the package
|
||||
/// Represents a set of configuration settings
|
||||
/// </summary>
|
||||
public const string Version = "1.0.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client. This is the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public static ApiClient apiClient = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication)
|
||||
/// </summary>
|
||||
/// <value>The username.</value>
|
||||
public static String username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password (HTTP basic authentication)
|
||||
/// </summary>
|
||||
/// <value>The password.</value>
|
||||
public static String password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API key based on the authentication name
|
||||
/// </summary>
|
||||
/// <value>The API key.</value>
|
||||
public static Dictionary<String, String> apiKey = new Dictionary<String, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
|
||||
/// </summary>
|
||||
/// <value>The prefix of the API key.</value>
|
||||
public static Dictionary<String, String> apiKeyPrefix = new Dictionary<String, String>();
|
||||
|
||||
|
||||
}
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Version of the package.
|
||||
/// </summary>
|
||||
/// <value>Version of the package.</value>
|
||||
public const string Version = "1.0.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public static ApiClient DefaultApiClient = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication).
|
||||
/// </summary>
|
||||
/// <value>The username.</value>
|
||||
public static String Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password (HTTP basic authentication).
|
||||
/// </summary>
|
||||
/// <value>The password.</value>
|
||||
public static String Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API key based on the authentication name.
|
||||
/// </summary>
|
||||
/// <value>The API key.</value>
|
||||
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
||||
/// </summary>
|
||||
/// <value>The prefix of the API key.</value>
|
||||
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
||||
|
||||
private static string _tempFolderPath = Path.GetTempPath();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
||||
/// </summary>
|
||||
/// <value>Folder path.</value>
|
||||
public static String TempFolderPath
|
||||
{
|
||||
get { return _tempFolderPath; }
|
||||
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
_tempFolderPath = value;
|
||||
return;
|
||||
}
|
||||
|
||||
// create the directory if it does not exist
|
||||
if (!Directory.Exists(value))
|
||||
Directory.CreateDirectory(value);
|
||||
|
||||
// check if the path contains directory separator at the end
|
||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
||||
_tempFolderPath = value;
|
||||
else
|
||||
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string with essential information for debugging.
|
||||
/// </summary>
|
||||
public static String ToDebugReport()
|
||||
{
|
||||
String report = "C# SDK (IO.Swagger) Debug Report:\n";
|
||||
report += " OS: " + Environment.OSVersion + "\n";
|
||||
report += " .NET Framework Version: " + Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetReferencedAssemblies()
|
||||
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
||||
report += " Version of the API: 1.0.0\n";
|
||||
report += " SDK Package Version: 1.0.0\n";
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,16 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Category {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -13,32 +13,45 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Order {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PetId
|
||||
/// </summary>
|
||||
[DataMember(Name="petId", EmitDefaultValue=false)]
|
||||
public long? PetId { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Quantity
|
||||
/// </summary>
|
||||
[DataMember(Name="quantity", EmitDefaultValue=false)]
|
||||
public int? Quantity { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ShipDate
|
||||
/// </summary>
|
||||
[DataMember(Name="shipDate", EmitDefaultValue=false)]
|
||||
public DateTime? ShipDate { get; set; }
|
||||
|
||||
|
||||
/* Order Status */
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
/// <value>Order Status</value>
|
||||
[DataMember(Name="status", EmitDefaultValue=false)]
|
||||
public string Status { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Complete
|
||||
/// </summary>
|
||||
[DataMember(Name="complete", EmitDefaultValue=false)]
|
||||
public bool? Complete { get; set; }
|
||||
|
||||
|
@ -13,32 +13,45 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Pet {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Category
|
||||
/// </summary>
|
||||
[DataMember(Name="category", EmitDefaultValue=false)]
|
||||
public Category Category { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PhotoUrls
|
||||
/// </summary>
|
||||
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
|
||||
public List<string> PhotoUrls { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Tags
|
||||
/// </summary>
|
||||
[DataMember(Name="tags", EmitDefaultValue=false)]
|
||||
public List<Tag> Tags { get; set; }
|
||||
|
||||
|
||||
/* pet status in the store */
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
/// <value>pet status in the store</value>
|
||||
[DataMember(Name="status", EmitDefaultValue=false)]
|
||||
public string Status { get; set; }
|
||||
|
||||
|
@ -13,12 +13,16 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Tag {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -13,42 +13,59 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class User {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Username
|
||||
/// </summary>
|
||||
[DataMember(Name="username", EmitDefaultValue=false)]
|
||||
public string Username { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets FirstName
|
||||
/// </summary>
|
||||
[DataMember(Name="firstName", EmitDefaultValue=false)]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets LastName
|
||||
/// </summary>
|
||||
[DataMember(Name="lastName", EmitDefaultValue=false)]
|
||||
public string LastName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Email
|
||||
/// </summary>
|
||||
[DataMember(Name="email", EmitDefaultValue=false)]
|
||||
public string Email { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Password
|
||||
/// </summary>
|
||||
[DataMember(Name="password", EmitDefaultValue=false)]
|
||||
public string Password { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Phone
|
||||
/// </summary>
|
||||
[DataMember(Name="phone", EmitDefaultValue=false)]
|
||||
public string Phone { get; set; }
|
||||
|
||||
|
||||
/* User Status */
|
||||
/// <summary>
|
||||
/// User Status
|
||||
/// </summary>
|
||||
/// <value>User Status</value>
|
||||
[DataMember(Name="userStatus", EmitDefaultValue=false)]
|
||||
public int? UserStatus { get; set; }
|
||||
|
||||
|
@ -29,9 +29,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>Lib\SwaggerClient\bin\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
@ -39,6 +36,11 @@
|
||||
<HintPath>Lib\SwaggerClient\bin\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\PetApi.cs" />
|
||||
@ -56,10 +58,10 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Lib\SwaggerClient\compile.bat" />
|
||||
<None Include="Lib\SwaggerClient\bin\Newtonsoft.Json.dll" />
|
||||
<None Include="Lib\SwaggerClient\bin\RestSharp.dll" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Lib\" />
|
||||
|
@ -1,9 +1,8 @@
|
||||
<Properties StartupItem="SwaggerClientTest.csproj">
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs">
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
||||
<Files>
|
||||
<File FileName="TestPet.cs" Line="110" Column="1" />
|
||||
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs" Line="11" Column="7" />
|
||||
<File FileName="TestPet.cs" Line="28" Column="64" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using IO.Swagger.Api;
|
||||
using IO.Swagger.Model;
|
||||
@ -48,6 +49,30 @@ namespace SwaggerClient.TestPet
|
||||
}
|
||||
|
||||
|
||||
[Test ()]
|
||||
public void TestGetPetByIdAsync ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var task = petApi.GetPetByIdAsync (petId);
|
||||
Pet response = task.Result;
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual ("available", response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestGetPetById ()
|
||||
{
|
||||
@ -89,6 +114,16 @@ namespace SwaggerClient.TestPet
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestUploadFile ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
//NOTE: please provide a valid file (full path)
|
||||
FileStream fileStream = new FileStream("/var/tmp/small.gif", FileMode.Open);
|
||||
petApi.UploadFile(petId, "new form name", fileStream);
|
||||
}
|
||||
|
||||
|
||||
[Test ()]
|
||||
public void TestFindPetByStatus ()
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.3" targetFramework="net45" />
|
||||
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||
</packages>
|
Binary file not shown.
Binary file not shown.
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.4/NUnit.2.6.4.nupkg
vendored
Normal file
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.4/NUnit.2.6.4.nupkg
vendored
Normal file
Binary file not shown.
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.4/lib/nunit.framework.dll
vendored
Normal file
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.4/lib/nunit.framework.dll
vendored
Normal file
Binary file not shown.
@ -3581,49 +3581,49 @@
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.CollectionAssert.IsNotSubsetOf(System.Collections.IEnumerable,System.Collections.IEnumerable)">
|
||||
<summary>
|
||||
Asserts that superset is not a subject of subset.
|
||||
Asserts that the superset does not contain the subset
|
||||
</summary>
|
||||
<param name="subset">The IEnumerable superset to be considered</param>
|
||||
<param name="superset">The IEnumerable subset to be considered</param>
|
||||
<param name="subset">The IEnumerable subset to be considered</param>
|
||||
<param name="superset">The IEnumerable superset to be considered</param>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.CollectionAssert.IsNotSubsetOf(System.Collections.IEnumerable,System.Collections.IEnumerable,System.String)">
|
||||
<summary>
|
||||
Asserts that superset is not a subject of subset.
|
||||
Asserts that the superset does not contain the subset
|
||||
</summary>
|
||||
<param name="subset">The IEnumerable superset to be considered</param>
|
||||
<param name="superset">The IEnumerable subset to be considered</param>
|
||||
<param name="subset">The IEnumerable subset to be considered</param>
|
||||
<param name="superset">The IEnumerable superset to be considered</param>
|
||||
<param name="message">The message that will be displayed on failure</param>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.CollectionAssert.IsNotSubsetOf(System.Collections.IEnumerable,System.Collections.IEnumerable,System.String,System.Object[])">
|
||||
<summary>
|
||||
Asserts that superset is not a subject of subset.
|
||||
Asserts that the superset does not contain the subset
|
||||
</summary>
|
||||
<param name="subset">The IEnumerable superset to be considered</param>
|
||||
<param name="superset">The IEnumerable subset to be considered</param>
|
||||
<param name="subset">The IEnumerable subset to be considered</param>
|
||||
<param name="superset">The IEnumerable superset to be considered</param>
|
||||
<param name="message">The message that will be displayed on failure</param>
|
||||
<param name="args">Arguments to be used in formatting the message</param>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.CollectionAssert.IsSubsetOf(System.Collections.IEnumerable,System.Collections.IEnumerable)">
|
||||
<summary>
|
||||
Asserts that superset is a subset of subset.
|
||||
Asserts that the superset contains the subset.
|
||||
</summary>
|
||||
<param name="subset">The IEnumerable superset to be considered</param>
|
||||
<param name="superset">The IEnumerable subset to be considered</param>
|
||||
<param name="subset">The IEnumerable subset to be considered</param>
|
||||
<param name="superset">The IEnumerable superset to be considered</param>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.CollectionAssert.IsSubsetOf(System.Collections.IEnumerable,System.Collections.IEnumerable,System.String)">
|
||||
<summary>
|
||||
Asserts that superset is a subset of subset.
|
||||
Asserts that the superset contains the subset.
|
||||
</summary>
|
||||
<param name="subset">The IEnumerable superset to be considered</param>
|
||||
<param name="superset">The IEnumerable subset to be considered</param>
|
||||
<param name="subset">The IEnumerable subset to be considered</param>
|
||||
<param name="superset">The IEnumerable superset to be considered</param>
|
||||
<param name="message">The message that will be displayed on failure</param>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.CollectionAssert.IsSubsetOf(System.Collections.IEnumerable,System.Collections.IEnumerable,System.String,System.Object[])">
|
||||
<summary>
|
||||
Asserts that superset is a subset of subset.
|
||||
Asserts that the superset contains the subset.
|
||||
</summary>
|
||||
<param name="subset">The IEnumerable superset to be considered</param>
|
||||
<param name="superset">The IEnumerable subset to be considered</param>
|
||||
<param name="subset">The IEnumerable subset to be considered</param>
|
||||
<param name="superset">The IEnumerable superset to be considered</param>
|
||||
<param name="message">The message that will be displayed on failure</param>
|
||||
<param name="args">Arguments to be used in formatting the message</param>
|
||||
</member>
|
||||
@ -6551,6 +6551,23 @@
|
||||
</summary>
|
||||
<returns>The target for the action attribute</returns>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.TestActionAttribute.BeforeTest(NUnit.Framework.TestDetails)">
|
||||
<summary>
|
||||
Method called before each test
|
||||
</summary>
|
||||
<param name="testDetails">Info about the test to be run</param>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.TestActionAttribute.AfterTest(NUnit.Framework.TestDetails)">
|
||||
<summary>
|
||||
Method called after each test
|
||||
</summary>
|
||||
<param name="testDetails">Info about the test that was just run</param>
|
||||
</member>
|
||||
<member name="P:NUnit.Framework.TestActionAttribute.Targets">
|
||||
<summary>
|
||||
Gets or sets the ActionTargets for this attribute
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:NUnit.Framework.TestAttribute">
|
||||
<summary>
|
||||
Adding this attribute to a method within a <seealso cref="T:NUnit.Framework.TestFixtureAttribute"/>
|
||||
@ -8066,7 +8083,7 @@
|
||||
presence of a particular attribute on an object.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.Constraints.ConstraintExpression.Matches(NUnit.Framework.Constraints.Constraint)">
|
||||
<member name="M:NUnit.Framework.Constraints.ConstraintExpression.Matches(NUnit.Framework.Constraints.IResolveConstraint)">
|
||||
<summary>
|
||||
Returns the constraint provided as an argument - used to allow custom
|
||||
custom constraints to easily participate in the syntax.
|
||||
@ -10352,6 +10369,13 @@
|
||||
<param name="actual">The value to be tested</param>
|
||||
<returns>True if no exception is thrown, otherwise false</returns>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.Constraints.ThrowsNothingConstraint.Matches``1(NUnit.Framework.Constraints.ActualValueDelegate{``0})">
|
||||
<summary>
|
||||
Test whether the constraint is satisfied by a given delegate
|
||||
</summary>
|
||||
<param name="del">Delegate returning the value to be tested</param>
|
||||
<returns>True if no exception is thrown, otherwise false</returns>
|
||||
</member>
|
||||
<member name="M:NUnit.Framework.Constraints.ThrowsNothingConstraint.WriteDescriptionTo(NUnit.Framework.Constraints.MessageWriter)">
|
||||
<summary>
|
||||
Write the constraint description to a MessageWriter
|
@ -1,15 +1,15 @@
|
||||
Copyright © 2002-2013 Charlie Poole
|
||||
Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
|
||||
Copyright © 2000-2002 Philip A. Craig
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.
|
||||
|
||||
Portions Copyright © 2002-2013 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
Copyright © 2002-2014 Charlie Poole
|
||||
Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
|
||||
Copyright © 2000-2002 Philip A. Craig
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.
|
||||
|
||||
Portions Copyright © 2002-2014 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
Loading…
Reference in New Issue
Block a user