From e2d74de6ca4f58d7d552f0cff55dff4842643be8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 13 Jul 2016 18:16:52 +0800 Subject: [PATCH 1/2] fix double hyphen in c# generator --- .../languages/AbstractCSharpCodegen.java | 2 +- .../resources/2_0/petstore-security-test.yaml | 52 ++++++------- .../csharp/SwaggerClient/IO.Swagger.sln | 10 +-- .../csharp/SwaggerClient/IO.Swagger.userprefs | 6 +- .../csharp/SwaggerClient/README.md | 33 ++++---- .../csharp/SwaggerClient/docs/FakeApi.md | 27 +++---- .../csharp/SwaggerClient/docs/ModelReturn.md | 2 +- .../IO.Swagger.Test/IO.Swagger.Test.csproj | 10 +-- .../src/IO.Swagger/Api/FakeApi.cs | 76 +++++++++---------- .../src/IO.Swagger/Client/ApiClient.cs | 18 ++--- .../src/IO.Swagger/Client/ApiException.cs | 8 +- .../src/IO.Swagger/Client/ApiResponse.cs | 8 +- .../src/IO.Swagger/Client/Configuration.cs | 10 +-- .../src/IO.Swagger/Client/ExceptionFactory.cs | 8 +- .../src/IO.Swagger/Client/IApiAccessor.cs | 8 +- .../src/IO.Swagger/IO.Swagger.csproj | 10 +-- .../src/IO.Swagger/Model/ModelReturn.cs | 16 ++-- 17 files changed, 153 insertions(+), 151 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java index 8c8b2d77730..f2db3b5e095 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java @@ -669,7 +669,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co @Override public String escapeUnsafeCharacters(String input) { - return input.replace("*/", "*_/").replace("/*", "/_*"); + return input.replace("*/", "*_/").replace("/*", "/_*").replace("--", "- -"); } } diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml index 6a201ba7b3d..16bce94ac7d 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml @@ -1,68 +1,68 @@ swagger: '2.0' info: - description: "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end \r\n \n \r" - version: 1.0.0 */ ' " =end \r\n \n \r - title: Swagger Petstore */ ' " =end \r\n \n \r - termsOfService: http://swagger.io/terms/ */ ' " =end \r\n \n \r + description: "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- \r\n \n \r" + version: 1.0.0 */ ' " =end -- \r\n \n \r + title: Swagger Petstore */ ' " =end -- \r\n \n \r + termsOfService: http://swagger.io/terms/ */ ' " =end -- \r\n \n \r contact: - email: apiteam@swagger.io */ ' " =end \r\n \n \r + email: apiteam@swagger.io */ ' " =end -- \r\n \n \r license: - name: Apache 2.0 */ ' " =end \r\n \n \r - url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end \r\n \n \r -host: petstore.swagger.io */ ' " =end \r\n \n \r -basePath: /v2 */ ' " =end \r\n \n \r + name: Apache 2.0 */ ' " =end -- \r\n \n \r + url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end -- \r\n \n \r +host: petstore.swagger.io */ ' " =end -- \r\n \n \r +basePath: /v2 */ ' " =end -- \r\n \n \r tags: - name: fake - description: Everything about your Pets */ ' " =end \r\n \n \r + description: Everything about your Pets */ ' " =end -- \r\n \n \r externalDocs: - description: Find out more */ ' " =end \r\n \n \r + description: Find out more */ ' " =end -- \r\n \n \r url: 'http://swagger.io' schemes: - - http */ ' " =end \r\n \n \r + - http */ ' " =end -- \r\n \n \r paths: /fake: put: tags: - fake - summary: To test code injection */ ' " =end \r\n \n \r - descriptions: To test code injection */ ' " =end \r\n \n \r - operationId: testCodeInject */ ' " =end \r\n \n \r + summary: To test code injection */ ' " =end -- \r\n \n \r + descriptions: To test code injection */ ' " =end -- \r\n \n \r + operationId: testCodeInject */ ' " =end -- \r\n \n \r consumes: - application/json - - "*/ ' \" =end \r\n \n \r" + - "*/ ' \" =end -- \r\n \n \r" produces: - application/json - - "*/ ' \" =end \r\n \n \r" + - "*/ ' \" =end -- \r\n \n \r" parameters: - - name: test code inject */ ' " =end \r\n \n \r + - name: test code inject */ ' " =end -- \r\n \n \r type: string in: formData - description: To test code injection */ ' " =end \r\n \n \r + description: To test code injection */ ' " =end -- \r\n \n \r responses: '400': - description: To test code injection */ ' " =end \r\n \n \r + description: To test code injection */ ' " =end -- \r\n \n \r securityDefinitions: petstore_auth: type: oauth2 authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' flow: implicit scopes: - 'write:pets': modify pets in your account */ ' " =end \r\n \n \r - 'read:pets': read your pets */ ' " =end \r\n \n \r + 'write:pets': modify pets in your account */ ' " =end -- \r\n \n \r + 'read:pets': read your pets */ ' " =end -- \r\n \n \r api_key: type: apiKey - name: api_key */ ' " =end \r\n \n \r + name: api_key */ ' " =end -- \r\n \n \r in: header definitions: Return: - description: Model for testing reserved words */ ' " =end \r\n \n \r + description: Model for testing reserved words */ ' " =end -- \r\n \n \r properties: return: - description: property description */ ' " =end \r\n \n \r + description: property description */ ' " =end -- \r\n \n \r type: integer format: int32 xml: name: Return externalDocs: - description: Find out more about Swagger */ ' " =end \r\n \n \r + description: Find out more about Swagger */ ' " =end -- \r\n \n \r url: 'http://swagger.io' diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.sln b/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.sln index 3f6c7053bf8..8dcf7f24348 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.sln +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.sln @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 VisualStudioVersion = 12.0.0.0 MinimumVisualStudioVersion = 10.0.0.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{29125490-71E4-47ED-B0D7-34505F58103C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{8CE139DF-64BC-4591-85F8-8506C2B67514}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" EndProject @@ -12,10 +12,10 @@ Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution -{29125490-71E4-47ED-B0D7-34505F58103C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{29125490-71E4-47ED-B0D7-34505F58103C}.Debug|Any CPU.Build.0 = Debug|Any CPU -{29125490-71E4-47ED-B0D7-34505F58103C}.Release|Any CPU.ActiveCfg = Release|Any CPU -{29125490-71E4-47ED-B0D7-34505F58103C}.Release|Any CPU.Build.0 = Release|Any CPU +{8CE139DF-64BC-4591-85F8-8506C2B67514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{8CE139DF-64BC-4591-85F8-8506C2B67514}.Debug|Any CPU.Build.0 = Debug|Any CPU +{8CE139DF-64BC-4591-85F8-8506C2B67514}.Release|Any CPU.ActiveCfg = Release|Any CPU +{8CE139DF-64BC-4591-85F8-8506C2B67514}.Release|Any CPU.Build.0 = Release|Any CPU {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.userprefs b/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.userprefs index 39b58c92731..5e7da6799fe 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.userprefs +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/IO.Swagger.userprefs @@ -1,9 +1,9 @@ - + - - + + diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/README.md b/samples/client/petstore-security-test/csharp/SwaggerClient/README.md index dc258722110..44f3ab7c368 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/README.md +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/README.md @@ -1,12 +1,12 @@ -# IO.Swagger - the C# library for the Swagger Petstore ' \" =end +# IO.Swagger - the C# library for the Swagger Petstore *_/ ' \" =end - - \\r\\n \\n \\r -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end - - This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API version: 1.0.0 ' \" =end +- API version: 1.0.0 *_/ ' \" =end - - \\r\\n \\n \\r - SDK version: 1.0.0 -- Build date: 2016-06-29T22:47:27.264+08:00 +- Build date: 2016-07-13T18:16:08.689+08:00 - Build package: class io.swagger.codegen.languages.CSharpClientCodegen ## Frameworks supported @@ -14,8 +14,8 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c - Windows Phone 7.1 (Mango) ## Dependencies -- [RestSharp] (https://www.nuget.org/packages/RestSharp) - 105.1.0 or later -- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later +- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later +- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later 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: ``` @@ -54,31 +54,33 @@ namespace Example { var apiInstance = new FakeApi(); - var testCodeInjectEnd = testCodeInjectEnd_example; // string | To test code injection ' \" =end (optional) + var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional) try { - // To test code injection ' \" =end - apiInstance.TestCodeInjectEnd(testCodeInjectEnd); + // To test code injection *_/ ' \" =end - - \\r\\n \\n \\r + apiInstance.TestCodeInjectEndRnNR(testCodeInjectEndRnNR); } catch (Exception e) { - Debug.Print("Exception when calling FakeApi.TestCodeInjectEnd: " + e.Message ); + Debug.Print("Exception when calling FakeApi.TestCodeInjectEndRnNR: " + e.Message ); } } } } ``` + ## Documentation for API Endpoints -All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end* +All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end - - \\r\\n \\n \\r/v2 *_/ ' \" =end - - \\r\\n \\n \\r* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*FakeApi* | [**TestCodeInjectEnd**](docs/FakeApi.md#testcodeinjectend) | **PUT** /fake | To test code injection ' \" =end +*FakeApi* | [**TestCodeInjectEndRnNR**](docs/FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r + ## Documentation for Models - [Model.ModelReturn](docs/ModelReturn.md) @@ -86,11 +88,10 @@ Class | Method | HTTP request | Description ## Documentation for Authorization - ### api_key - **Type**: API key -- **API key parameter name**: api_key */ ' " =end +- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r - **Location**: HTTP header ### petstore_auth @@ -99,6 +100,6 @@ Class | Method | HTTP request | Description - **Flow**: implicit - **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Scopes**: - - write:pets: modify pets in your account */ ' " =end - - read:pets: read your pets */ ' " =end + - write:pets: modify pets in your account */ ' " =end -- \r\n \n \r + - read:pets: read your pets */ ' " =end -- \r\n \n \r diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md b/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md index 962ba5fc6e0..39a951cbede 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md @@ -1,16 +1,17 @@ # IO.Swagger.Api.FakeApi -All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end* +All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end - - \\r\\n \\n \\r/v2 *_/ ' \" =end - - \\r\\n \\n \\r* Method | HTTP request | Description ------------- | ------------- | ------------- -[**TestCodeInjectEnd**](FakeApi.md#testcodeinjectend) | **PUT** /fake | To test code injection ' \" =end +[**TestCodeInjectEndRnNR**](FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r -# **TestCodeInjectEnd** -> void TestCodeInjectEnd (string testCodeInjectEnd = null) + +# **TestCodeInjectEndRnNR** +> void TestCodeInjectEndRnNR (string testCodeInjectEndRnNR = null) -To test code injection ' \" =end +To test code injection *_/ ' \" =end - - \\r\\n \\n \\r ### Example ```csharp @@ -22,22 +23,22 @@ using IO.Swagger.Model; namespace Example { - public class TestCodeInjectEndExample + public class TestCodeInjectEndRnNRExample { public void main() { var apiInstance = new FakeApi(); - var testCodeInjectEnd = testCodeInjectEnd_example; // string | To test code injection ' \" =end (optional) + var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional) try { - // To test code injection ' \" =end - apiInstance.TestCodeInjectEnd(testCodeInjectEnd); + // To test code injection *_/ ' \" =end - - \\r\\n \\n \\r + apiInstance.TestCodeInjectEndRnNR(testCodeInjectEndRnNR); } catch (Exception e) { - Debug.Print("Exception when calling FakeApi.TestCodeInjectEnd: " + e.Message ); + Debug.Print("Exception when calling FakeApi.TestCodeInjectEndRnNR: " + e.Message ); } } } @@ -48,7 +49,7 @@ namespace Example Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **testCodeInjectEnd** | **string**| To test code injection ' \" =end | [optional] + **testCodeInjectEndRnNR** | **string**| To test code injection *_/ ' \" =end - - \\r\\n \\n \\r | [optional] ### Return type @@ -60,8 +61,8 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json, */ ' =end - - **Accept**: application/json, */ ' =end + - **Content-Type**: application/json, *_/ ' =end - - + - **Accept**: application/json, *_/ ' =end - - [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/docs/ModelReturn.md b/samples/client/petstore-security-test/csharp/SwaggerClient/docs/ModelReturn.md index 57af1de2bdc..ba83e94b8ce 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/docs/ModelReturn.md +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/docs/ModelReturn.md @@ -3,7 +3,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_Return** | **int?** | property description ' \" =end | [optional] +**_Return** | **int?** | property description *_/ ' \" =end - - \\r\\n \\n \\r | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj index 35bf372e00a..dc7be6546d9 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj @@ -1,11 +1,11 @@