diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
index 1b49d9b5347a..142b2e6bbb98 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
@@ -232,7 +232,7 @@ namespace {{packageName}}.Client
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
? Path.GetTempPath()
: Configuration.TempFolderPath;
- var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
+ var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
foreach (var header in headers)
{
var match = regex.Match(header.ToString());
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json
index 66762d74b2bc..ad9cbead5e97 100644
--- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json
+++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json
@@ -402,6 +402,23 @@
]
}
},
+ "/pet/{petId}/downloadImage" : {
+ "get" : {
+ "tags" : [ "pet" ],
+ "summary" : "downloads an image",
+ "description" : "",
+ "operationId" : "downloadFile",
+ "produces" : [ "application/octet-stream" ],
+ "responses" : {
+ "200" : {
+ "description" : "successful operation",
+ "schema" : {
+ "$ref" : "#/definitions/File"
+ }
+ }
+ }
+ }
+ },
"/store/inventory": {
"get": {
"tags": [
@@ -972,6 +989,65 @@
"xml": {
"name": "Order"
}
+ },
+ "definitions" : {
+ "File": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "canonicalPath": {
+ "type": "string"
+ },
+ "parent": {
+ "type": "string"
+ },
+ "absolute": {
+ "type": "boolean",
+ "default": false
+ },
+ "absoluteFile": {
+ "$ref": "#/definitions/File"
+ },
+ "absolutePath": {
+ "type": "string"
+ },
+ "canonicalFile": {
+ "$ref": "#/definitions/File"
+ },
+ "freeSpace": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "parentFile": {
+ "$ref": "#/definitions/File"
+ },
+ "totalSpace": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "usableSpace": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "directory": {
+ "type": "boolean",
+ "default": false
+ },
+ "file": {
+ "type": "boolean",
+ "default": false
+ },
+ "hidden": {
+ "type": "boolean",
+ "default": false
+ }
+ }
+ }
}
}
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
index ba58eeac9e0e..4537144f930b 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
@@ -6,6 +6,7 @@ using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
+
namespace IO.Swagger.Api
{
@@ -307,6 +308,42 @@ namespace IO.Swagger.Api
/// Task of ApiResponse
System.Threading.Tasks.Task> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null);
+ ///
+ /// downloads an image
+ ///
+ ///
+ ///
+ ///
+ /// Stream
+ Stream DownloadFile ();
+
+ ///
+ /// downloads an image
+ ///
+ ///
+ ///
+ ///
+ /// ApiResponse of Stream
+ ApiResponse DownloadFileWithHttpInfo ();
+
+ ///
+ /// downloads an image
+ ///
+ ///
+ ///
+ ///
+ /// Task of Stream
+ System.Threading.Tasks.Task DownloadFileAsync ();
+
+ ///
+ /// downloads an image
+ ///
+ ///
+ ///
+ ///
+ /// Task of ApiResponse (Stream)
+ System.Threading.Tasks.Task> DownloadFileAsyncWithHttpInfo ();
+
///
/// uploads an image
///
@@ -1487,6 +1524,131 @@ namespace IO.Swagger.Api
null);
}
+ ///
+ /// downloads an image
+ ///
+ /// Stream
+ public Stream DownloadFile ()
+ {
+ ApiResponse response = DownloadFileWithHttpInfo();
+ return response.Data;
+ }
+
+ ///
+ /// downloads an image
+ ///
+ /// ApiResponse of Stream
+ public ApiResponse< Stream > DownloadFileWithHttpInfo ()
+ {
+
+
+ var path_ = "/pet/{petId}/downloadImage";
+
+ var pathParams = new Dictionary();
+ var queryParams = new Dictionary();
+ var headerParams = new Dictionary(Configuration.DefaultHeader);
+ var formParams = new Dictionary();
+ var fileParams = new Dictionary();
+ String postBody = null;
+
+ // to determine the Accept header
+ String[] http_header_accepts = new String[] {
+ "application/octet-stream"
+ };
+ String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
+ if (http_header_accept != null)
+ headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));
+
+ // set "format" to json by default
+ // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
+ pathParams.Add("format", "json");
+
+
+
+
+
+
+
+
+ // make the HTTP request
+ IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
+
+ int statusCode = (int) response.StatusCode;
+
+ if (statusCode >= 400)
+ throw new ApiException (statusCode, "Error calling DownloadFile: " + response.Content, response.Content);
+ else if (statusCode == 0)
+ throw new ApiException (statusCode, "Error calling DownloadFile: " + response.ErrorMessage, response.ErrorMessage);
+
+ return new ApiResponse(statusCode,
+ response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
+ (Stream) Configuration.ApiClient.Deserialize(response, typeof(Stream)));
+
+ }
+
+ ///
+ /// downloads an image
+ ///
+ /// Task of Stream
+ public async System.Threading.Tasks.Task DownloadFileAsync ()
+ {
+ ApiResponse response = await DownloadFileAsyncWithHttpInfo();
+ return response.Data;
+
+ }
+
+ ///
+ /// downloads an image
+ ///
+ /// Task of ApiResponse (Stream)
+ public async System.Threading.Tasks.Task> DownloadFileAsyncWithHttpInfo ()
+ {
+
+
+ var path_ = "/pet/{petId}/downloadImage";
+
+ var pathParams = new Dictionary();
+ var queryParams = new Dictionary();
+ var headerParams = new Dictionary();
+ var formParams = new Dictionary();
+ var fileParams = new Dictionary();
+ String postBody = null;
+
+ // to determine the Accept header
+ String[] http_header_accepts = new String[] {
+ "application/octet-stream"
+ };
+ String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
+ if (http_header_accept != null)
+ headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));
+
+ // set "format" to json by default
+ // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
+ pathParams.Add("format", "json");
+
+
+
+
+
+
+
+
+ // make the HTTP request
+ IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
+
+ int statusCode = (int) response.StatusCode;
+
+ if (statusCode >= 400)
+ throw new ApiException (statusCode, "Error calling DownloadFile: " + response.Content, response.Content);
+ else if (statusCode == 0)
+ throw new ApiException (statusCode, "Error calling DownloadFile: " + response.ErrorMessage, response.ErrorMessage);
+
+ return new ApiResponse(statusCode,
+ response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
+ (Stream) Configuration.ApiClient.Deserialize(response, typeof(Stream)));
+
+ }
+
///
/// uploads an image
///
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs
index a9e9d6e9b741..db82bf8e6440 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs
@@ -6,6 +6,7 @@ using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
+
namespace IO.Swagger.Api
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs
index 5502fe15da17..ac4f138c568b 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs
@@ -6,6 +6,7 @@ using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
+
namespace IO.Swagger.Api
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
index 58ade0637180..7e6807f16a45 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
@@ -196,13 +196,14 @@ namespace IO.Swagger.Client
return ((DateTime)obj).ToString (Configuration.DateTimeFormat);
else if (obj is IList)
{
- string flattenString = "";
- string separator = ",";
+ var flattenedString = new StringBuilder();
foreach (var param in (IList)obj)
{
- flattenString += param.ToString() + separator;
+ if (flattenedString.Length > 0)
+ flattenedString.Append(",");
+ flattenedString.Append(param);
}
- return flattenString.Remove(flattenString.Length - 1);;
+ return flattenedString.ToString();
}
else
return Convert.ToString (obj);
@@ -231,13 +232,16 @@ namespace IO.Swagger.Client
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
? Path.GetTempPath()
: Configuration.TempFolderPath;
- var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
- var match = regex.Match(headers.ToString());
- if (match.Success)
+ var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
+ foreach (var header in headers)
{
- string fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
- File.WriteAllBytes(fileName, data);
- return new FileStream(fileName, FileMode.Open);
+ var match = regex.Match(header.ToString());
+ if (match.Success)
+ {
+ string fileName = filePath + match.Groups[1].Value.Replace("\"", "").Replace("'", "");
+ File.WriteAllBytes(fileName, data);
+ return new FileStream(fileName, FileMode.Open);
+ }
}
}
var stream = new MemoryStream(data);
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs
index bfbb9d7479d3..13d16c9ce57f 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs
@@ -24,15 +24,15 @@ namespace IO.Swagger.Client
/// Dictionary of API key prefix
/// Temp folder path
/// DateTime format string
- public Configuration(ApiClient apiClient = null,
- Dictionary defaultHeader = null,
- string username = null,
- string password = null,
- string accessToken = null,
- Dictionary apiKey = null,
- Dictionary apiKeyPrefix = null,
- string tempFolderPath = null,
- string dateTimeFormat = null
+ public Configuration(ApiClient apiClient,
+ Dictionary defaultHeader,
+ string username,
+ string password,
+ string accessToken,
+ Dictionary apiKey,
+ Dictionary apiKeyPrefix,
+ string tempFolderPath,
+ string dateTimeFormat
)
{
if (apiClient == null)
@@ -43,11 +43,8 @@ namespace IO.Swagger.Client
Username = username;
Password = password;
AccessToken = accessToken;
-
- if (apiKey != null)
- ApiKey = apiKey;
- if (apiKeyPrefix != null)
- ApiKeyPrefix = apiKeyPrefix;
+ ApiKey = apiKey;
+ ApiKeyPrefix = apiKeyPrefix;
TempFolderPath = tempFolderPath;
DateTimeFormat = dateTimeFormat;
@@ -58,7 +55,7 @@ namespace IO.Swagger.Client
/// Initializes a new instance of the Configuration class.
///
/// Api client.
- public Configuration(ApiClient apiClient)
+ public Configuration(ApiClient apiClient=null)
{
if (apiClient == null)
ApiClient = ApiClient.Default;
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
index d9cb6b21005d..03551f9492bc 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
@@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
+
+
namespace IO.Swagger.Model
{
@@ -122,4 +124,6 @@ namespace IO.Swagger.Model
}
}
+
+
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
index 2191707bd091..1d214430ec86 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
@@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
+
+
namespace IO.Swagger.Model
{
@@ -187,4 +189,6 @@ namespace IO.Swagger.Model
}
}
+
+
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
index 10c44fb46a7b..ab60577e85af 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
@@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
+
+
namespace IO.Swagger.Model
{
@@ -187,4 +189,6 @@ namespace IO.Swagger.Model
}
}
+
+
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
index 93210505bf0f..cf77c2470b2d 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
@@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
+
+
namespace IO.Swagger.Model
{
@@ -122,4 +124,6 @@ namespace IO.Swagger.Model
}
}
+
+
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
index 1fbd17da993a..eca977c3b183 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
@@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
+
+
namespace IO.Swagger.Model
{
@@ -219,4 +221,6 @@ namespace IO.Swagger.Model
}
}
+
+
}