Skip to content

Commit 5ea2e2f

Browse files
committed
2 parents 7be14f0 + 3051ca2 commit 5ea2e2f

File tree

16 files changed

+375
-199
lines changed

16 files changed

+375
-199
lines changed

modules/swagger-codegen/src/main/resources/csharp/IApiAccessor.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ namespace {{packageName}}.Client
2424
/// </summary>
2525
/// <value>The base path</value>
2626
String GetBasePath();
27+
28+
/// <summary>
29+
/// Provides a factory method hook for the creation of exceptions.
30+
/// </summary>
31+
ExceptionFactory ExceptionFactory { get; set; }
2732
}
2833
}

samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2012
33
VisualStudioVersion = 12.0.0.0
44
MinimumVisualStudioVersion = 10.0.0.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{C81D6286-7BA5-4920-8591-F59169CCE4A4}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{EE727567-9CAF-4258-AA0E-FDF89487D7D6}"
66
EndProject
77
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
88
EndProject
@@ -12,10 +12,10 @@ Debug|Any CPU = Debug|Any CPU
1212
Release|Any CPU = Release|Any CPU
1313
EndGlobalSection
1414
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15-
{C81D6286-7BA5-4920-8591-F59169CCE4A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16-
{C81D6286-7BA5-4920-8591-F59169CCE4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
17-
{C81D6286-7BA5-4920-8591-F59169CCE4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
18-
{C81D6286-7BA5-4920-8591-F59169CCE4A4}.Release|Any CPU.Build.0 = Release|Any CPU
15+
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
1919
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2020
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
2121
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU

samples/client/petstore/csharp/SwaggerClient/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
66

77
- API version: 1.0.0
88
- SDK version: 1.0.0
9-
- Build date: 2016-05-29T17:27:36.037+08:00
9+
- Build date: 2016-06-10T08:07:39.769-04:00
1010
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
1111

1212
## Frameworks supported
@@ -54,7 +54,7 @@ namespace Example
5454
{
5555

5656
var apiInstance = new FakeApi();
57-
var number = 3.4; // double? | None
57+
var number = 3.4; // decimal? | None
5858
var _double = 1.2; // double? | None
5959
var _string = _string_example; // string | None
6060
var _byte = B; // byte[] | None
@@ -138,12 +138,6 @@ Class | Method | HTTP request | Description
138138
## Documentation for Authorization
139139

140140

141-
### api_key
142-
143-
- **Type**: API key
144-
- **API key parameter name**: api_key
145-
- **Location**: HTTP header
146-
147141
### petstore_auth
148142

149143
- **Type**: OAuth
@@ -153,3 +147,9 @@ Class | Method | HTTP request | Description
153147
- write:pets: modify pets in your account
154148
- read:pets: read your pets
155149

150+
### api_key
151+
152+
- **Type**: API key
153+
- **API key parameter name**: api_key
154+
- **Location**: HTTP header
155+

samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Method | HTTP request | Description
88

99

1010
# **TestEndpointParameters**
11-
> void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
11+
> void TestEndpointParameters (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
1212
1313
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
1414

@@ -30,7 +30,7 @@ namespace Example
3030
{
3131

3232
var apiInstance = new FakeApi();
33-
var number = 3.4; // double? | None
33+
var number = 3.4; // decimal? | None
3434
var _double = 1.2; // double? | None
3535
var _string = _string_example; // string | None
3636
var _byte = B; // byte[] | None
@@ -61,7 +61,7 @@ namespace Example
6161

6262
Name | Type | Description | Notes
6363
------------- | ------------- | ------------- | -------------
64-
**number** | **double?**| None |
64+
**number** | **decimal?**| None |
6565
**_double** | **double?**| None |
6666
**_string** | **string**| None |
6767
**_byte** | **byte[]**| None |

samples/client/petstore/csharp/SwaggerClient/docs/FormatTest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
66
**Integer** | **int?** | | [optional]
77
**Int32** | **int?** | | [optional]
88
**Int64** | **long?** | | [optional]
9-
**Number** | **double?** | |
9+
**Number** | **decimal?** | |
1010
**_Float** | **float?** | | [optional]
1111
**_Double** | **double?** | | [optional]
1212
**_String** | **string** | | [optional]

samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ limitations under the License.
8686
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
8787
<ItemGroup>
8888
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
89-
<Project>{C81D6286-7BA5-4920-8591-F59169CCE4A4}</Project>
89+
<Project>{EE727567-9CAF-4258-AA0E-FDF89487D7D6}</Project>
9090
<Name>IO.Swagger</Name>
9191
</ProjectReference>
9292
</ItemGroup>

samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public interface IFakeApi : IApiAccessor
5555
/// <param name="dateTime">None (optional)</param>
5656
/// <param name="password">None (optional)</param>
5757
/// <returns></returns>
58-
void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
58+
void TestEndpointParameters (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
5959

6060
/// <summary>
6161
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -77,7 +77,7 @@ public interface IFakeApi : IApiAccessor
7777
/// <param name="dateTime">None (optional)</param>
7878
/// <param name="password">None (optional)</param>
7979
/// <returns>ApiResponse of Object(void)</returns>
80-
ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
80+
ApiResponse<Object> TestEndpointParametersWithHttpInfo (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
8181
#endregion Synchronous Operations
8282
#region Asynchronous Operations
8383
/// <summary>
@@ -100,7 +100,7 @@ public interface IFakeApi : IApiAccessor
100100
/// <param name="dateTime">None (optional)</param>
101101
/// <param name="password">None (optional)</param>
102102
/// <returns>Task of void</returns>
103-
System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
103+
System.Threading.Tasks.Task TestEndpointParametersAsync (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
104104

105105
/// <summary>
106106
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -122,7 +122,7 @@ public interface IFakeApi : IApiAccessor
122122
/// <param name="dateTime">None (optional)</param>
123123
/// <param name="password">None (optional)</param>
124124
/// <returns>Task of ApiResponse</returns>
125-
System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
125+
System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
126126
#endregion Asynchronous Operations
127127
}
128128

@@ -131,6 +131,8 @@ public interface IFakeApi : IApiAccessor
131131
/// </summary>
132132
public partial class FakeApi : IFakeApi
133133
{
134+
private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
135+
134136
/// <summary>
135137
/// Initializes a new instance of the <see cref="FakeApi"/> class.
136138
/// </summary>
@@ -139,6 +141,8 @@ public FakeApi(String basePath)
139141
{
140142
this.Configuration = new Configuration(new ApiClient(basePath));
141143

144+
ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory;
145+
142146
// ensure API client has configuration ready
143147
if (Configuration.ApiClient.Configuration == null)
144148
{
@@ -159,6 +163,8 @@ public FakeApi(Configuration configuration = null)
159163
else
160164
this.Configuration = configuration;
161165

166+
ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory;
167+
162168
// ensure API client has configuration ready
163169
if (Configuration.ApiClient.Configuration == null)
164170
{
@@ -191,6 +197,22 @@ public void SetBasePath(String basePath)
191197
/// <value>An instance of the Configuration</value>
192198
public Configuration Configuration {get; set;}
193199

200+
/// <summary>
201+
/// Provides a factory method hook for the creation of exceptions.
202+
/// </summary>
203+
public IO.Swagger.Client.ExceptionFactory ExceptionFactory
204+
{
205+
get
206+
{
207+
if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1)
208+
{
209+
throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported.");
210+
}
211+
return _exceptionFactory;
212+
}
213+
set { _exceptionFactory = value; }
214+
}
215+
194216
/// <summary>
195217
/// Gets the default header.
196218
/// </summary>
@@ -230,7 +252,7 @@ public void AddDefaultHeader(string key, string value)
230252
/// <param name="dateTime">None (optional)</param>
231253
/// <param name="password">None (optional)</param>
232254
/// <returns></returns>
233-
public void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
255+
public void TestEndpointParameters (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
234256
{
235257
TestEndpointParametersWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
236258
}
@@ -252,7 +274,7 @@ public void TestEndpointParameters (double? number, double? _double, string _str
252274
/// <param name="dateTime">None (optional)</param>
253275
/// <param name="password">None (optional)</param>
254276
/// <returns>ApiResponse of Object(void)</returns>
255-
public ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
277+
public ApiResponse<Object> TestEndpointParametersWithHttpInfo (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
256278
{
257279
// verify the required parameter 'number' is set
258280
if (number == null)
@@ -315,10 +337,11 @@ public ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, d
315337

316338
int localVarStatusCode = (int) localVarResponse.StatusCode;
317339

318-
if (localVarStatusCode >= 400)
319-
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content);
320-
else if (localVarStatusCode == 0)
321-
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
340+
if (ExceptionFactory != null)
341+
{
342+
Exception exception = ExceptionFactory("TestEndpointParameters", localVarResponse);
343+
if (exception != null) throw exception;
344+
}
322345

323346

324347
return new ApiResponse<Object>(localVarStatusCode,
@@ -343,7 +366,7 @@ public ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, d
343366
/// <param name="dateTime">None (optional)</param>
344367
/// <param name="password">None (optional)</param>
345368
/// <returns>Task of void</returns>
346-
public async System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
369+
public async System.Threading.Tasks.Task TestEndpointParametersAsync (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
347370
{
348371
await TestEndpointParametersAsyncWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
349372

@@ -366,7 +389,7 @@ public async System.Threading.Tasks.Task TestEndpointParametersAsync (double? nu
366389
/// <param name="dateTime">None (optional)</param>
367390
/// <param name="password">None (optional)</param>
368391
/// <returns>Task of ApiResponse</returns>
369-
public async System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
392+
public async System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (decimal? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
370393
{
371394
// verify the required parameter 'number' is set
372395
if (number == null)
@@ -429,10 +452,11 @@ public async System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParame
429452

430453
int localVarStatusCode = (int) localVarResponse.StatusCode;
431454

432-
if (localVarStatusCode >= 400)
433-
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content);
434-
else if (localVarStatusCode == 0)
435-
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
455+
if (ExceptionFactory != null)
456+
{
457+
Exception exception = ExceptionFactory("TestEndpointParameters", localVarResponse);
458+
if (exception != null) throw exception;
459+
}
436460

437461

438462
return new ApiResponse<Object>(localVarStatusCode,

0 commit comments

Comments
 (0)