Skip to content

Commit cee45bc

Browse files
authored
Merge pull request #3360 from wing328/csharp_escape_double_hyphen
[C#] fix double hyphen in c# generator
2 parents cf02d17 + 8da6e0a commit cee45bc

File tree

24 files changed

+170
-168
lines changed

24 files changed

+170
-168
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public String escapeQuotationMark(String input) {
669669

670670
@Override
671671
public String escapeUnsafeCharacters(String input) {
672-
return input.replace("*/", "*_/").replace("/*", "/_*");
672+
return input.replace("*/", "*_/").replace("/*", "/_*").replace("--", "- -");
673673
}
674674

675675
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ public String toEnumVarName(String value, String datatype) {
414414

415415
// string
416416
String var = value.replaceAll("_", " ");
417-
var = WordUtils.capitalizeFully(var);
417+
//var = WordUtils.capitalizeFully(var);
418+
var = camelize(var);
418419
var = var.replaceAll("\\W+", "");
419420

420-
421421
if (var.matches("\\d.*")) {
422422
return "_" + var;
423423
} else {
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
swagger: '2.0'
22
info:
3-
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"
4-
version: 1.0.0 */ ' " =end \r\n \n \r
5-
title: Swagger Petstore */ ' " =end \r\n \n \r
6-
termsOfService: http://swagger.io/terms/ */ ' " =end \r\n \n \r
3+
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"
4+
version: 1.0.0 */ ' " =end -- \r\n \n \r
5+
title: Swagger Petstore */ ' " =end -- \r\n \n \r
6+
termsOfService: http://swagger.io/terms/ */ ' " =end -- \r\n \n \r
77
contact:
8-
email: [email protected] */ ' " =end \r\n \n \r
8+
email: [email protected] */ ' " =end -- \r\n \n \r
99
license:
10-
name: Apache 2.0 */ ' " =end \r\n \n \r
11-
url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end \r\n \n \r
12-
host: petstore.swagger.io */ ' " =end \r\n \n \r
13-
basePath: /v2 */ ' " =end \r\n \n \r
10+
name: Apache 2.0 */ ' " =end -- \r\n \n \r
11+
url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end -- \r\n \n \r
12+
host: petstore.swagger.io */ ' " =end -- \r\n \n \r
13+
basePath: /v2 */ ' " =end -- \r\n \n \r
1414
tags:
1515
- name: fake
16-
description: Everything about your Pets */ ' " =end \r\n \n \r
16+
description: Everything about your Pets */ ' " =end -- \r\n \n \r
1717
externalDocs:
18-
description: Find out more */ ' " =end \r\n \n \r
18+
description: Find out more */ ' " =end -- \r\n \n \r
1919
url: 'http://swagger.io'
2020
schemes:
21-
- http */ ' " =end \r\n \n \r
21+
- http */ ' " =end -- \r\n \n \r
2222
paths:
2323
/fake:
2424
put:
2525
tags:
2626
- fake
27-
summary: To test code injection */ ' " =end \r\n \n \r
28-
descriptions: To test code injection */ ' " =end \r\n \n \r
29-
operationId: testCodeInject */ ' " =end \r\n \n \r
27+
summary: To test code injection */ ' " =end -- \r\n \n \r
28+
descriptions: To test code injection */ ' " =end -- \r\n \n \r
29+
operationId: testCodeInject */ ' " =end -- \r\n \n \r
3030
consumes:
3131
- application/json
32-
- "*/ ' \" =end \r\n \n \r"
32+
- "*/ ' \" =end -- \r\n \n \r"
3333
produces:
3434
- application/json
35-
- "*/ ' \" =end \r\n \n \r"
35+
- "*/ ' \" =end -- \r\n \n \r"
3636
parameters:
37-
- name: test code inject */ ' " =end \r\n \n \r
37+
- name: test code inject */ ' " =end -- \r\n \n \r
3838
type: string
3939
in: formData
40-
description: To test code injection */ ' " =end \r\n \n \r
40+
description: To test code injection */ ' " =end -- \r\n \n \r
4141
responses:
4242
'400':
43-
description: To test code injection */ ' " =end \r\n \n \r
43+
description: To test code injection */ ' " =end -- \r\n \n \r
4444
securityDefinitions:
4545
petstore_auth:
4646
type: oauth2
4747
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
4848
flow: implicit
4949
scopes:
50-
'write:pets': modify pets in your account */ ' " =end \r\n \n \r
51-
'read:pets': read your pets */ ' " =end \r\n \n \r
50+
'write:pets': modify pets in your account */ ' " =end -- \r\n \n \r
51+
'read:pets': read your pets */ ' " =end -- \r\n \n \r
5252
api_key:
5353
type: apiKey
54-
name: api_key */ ' " =end \r\n \n \r
54+
name: api_key */ ' " =end -- \r\n \n \r
5555
in: header
5656
definitions:
5757
Return:
58-
description: Model for testing reserved words */ ' " =end \r\n \n \r
58+
description: Model for testing reserved words */ ' " =end -- \r\n \n \r
5959
properties:
6060
return:
61-
description: property description */ ' " =end \r\n \n \r
61+
description: property description */ ' " =end -- \r\n \n \r
6262
type: integer
6363
format: int32
6464
xml:
6565
name: Return
6666
externalDocs:
67-
description: Find out more about Swagger */ ' " =end \r\n \n \r
67+
description: Find out more about Swagger */ ' " =end -- \r\n \n \r
6868
url: 'http://swagger.io'

samples/client/petstore-security-test/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", "{29125490-71E4-47ED-B0D7-34505F58103C}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{8CE139DF-64BC-4591-85F8-8506C2B67514}"
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-
{29125490-71E4-47ED-B0D7-34505F58103C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16-
{29125490-71E4-47ED-B0D7-34505F58103C}.Debug|Any CPU.Build.0 = Debug|Any CPU
17-
{29125490-71E4-47ED-B0D7-34505F58103C}.Release|Any CPU.ActiveCfg = Release|Any CPU
18-
{29125490-71E4-47ED-B0D7-34505F58103C}.Release|Any CPU.Build.0 = Release|Any CPU
15+
{8CE139DF-64BC-4591-85F8-8506C2B67514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{8CE139DF-64BC-4591-85F8-8506C2B67514}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{8CE139DF-64BC-4591-85F8-8506C2B67514}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{8CE139DF-64BC-4591-85F8-8506C2B67514}.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-security-test/csharp/SwaggerClient/IO.Swagger.userprefs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<Properties>
1+
<Properties StartupItem="src/IO.Swagger/IO.Swagger.csproj">
22
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
33
<MonoDevelop.Ide.Workbench ActiveDocument="src/IO.Swagger/Client/Configuration.cs">
44
<Files>
5-
<File FileName="src/IO.Swagger/Client/ApiClient.cs" Line="72" Column="77" />
6-
<File FileName="src/IO.Swagger/Client/Configuration.cs" Line="311" Column="58" />
5+
<File FileName="src/IO.Swagger/Client/ApiClient.cs" Line="1" Column="1" />
6+
<File FileName="src/IO.Swagger/Client/Configuration.cs" Line="22" Column="1" />
77
</Files>
88
</MonoDevelop.Ide.Workbench>
99
<MonoDevelop.Ide.DebuggingService.Breakpoints>

samples/client/petstore-security-test/csharp/SwaggerClient/README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# IO.Swagger - the C# library for the Swagger Petstore &#39; \&quot; &#x3D;end
1+
# IO.Swagger - the C# library for the Swagger Petstore *_/ &#39; \&quot; &#x3D;end - - \\r\\n \\n \\r
22

3-
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
3+
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 - -
44

55
This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
66

7-
- API version: 1.0.0 &#39; \&quot; &#x3D;end
7+
- API version: 1.0.0 *_/ &#39; \&quot; &#x3D;end - - \\r\\n \\n \\r
88
- SDK version: 1.0.0
9-
- Build date: 2016-06-29T22:47:27.264+08:00
9+
- Build date: 2016-07-13T18:16:08.689+08:00
1010
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
1111

1212
## Frameworks supported
1313
- .NET 4.0 or later
1414
- Windows Phone 7.1 (Mango)
1515

1616
## Dependencies
17-
- [RestSharp] (https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
18-
- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
17+
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
18+
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
1919

2020
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:
2121
```
@@ -54,43 +54,44 @@ namespace Example
5454
{
5555

5656
var apiInstance = new FakeApi();
57-
var testCodeInjectEnd = testCodeInjectEnd_example; // string | To test code injection ' \" =end (optional)
57+
var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional)
5858
5959
try
6060
{
61-
// To test code injection ' \" =end
62-
apiInstance.TestCodeInjectEnd(testCodeInjectEnd);
61+
// To test code injection *_/ ' \" =end - - \\r\\n \\n \\r
62+
apiInstance.TestCodeInjectEndRnNR(testCodeInjectEndRnNR);
6363
}
6464
catch (Exception e)
6565
{
66-
Debug.Print("Exception when calling FakeApi.TestCodeInjectEnd: " + e.Message );
66+
Debug.Print("Exception when calling FakeApi.TestCodeInjectEndRnNR: " + e.Message );
6767
}
6868
}
6969
}
7070
}
7171
```
7272

73+
<a name="documentation-for-api-endpoints"></a>
7374
## Documentation for API Endpoints
7475

75-
All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end*
76+
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end - - \\r\\n \\n \\r/v2 *_/ ' \" =end - - \\r\\n \\n \\r*
7677

7778
Class | Method | HTTP request | Description
7879
------------ | ------------- | ------------- | -------------
79-
*FakeApi* | [**TestCodeInjectEnd**](docs/FakeApi.md#testcodeinjectend) | **PUT** /fake | To test code injection ' \" =end
80+
*FakeApi* | [**TestCodeInjectEndRnNR**](docs/FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r
8081

8182

83+
<a name="documentation-for-models"></a>
8284
## Documentation for Models
8385

8486
- [Model.ModelReturn](docs/ModelReturn.md)
8587

8688

8789
## Documentation for Authorization
8890

89-
9091
### api_key
9192

9293
- **Type**: API key
93-
- **API key parameter name**: api_key */ &#39; &quot; &#x3D;end
94+
- **API key parameter name**: api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r
9495
- **Location**: HTTP header
9596

9697
### petstore_auth
@@ -99,6 +100,6 @@ Class | Method | HTTP request | Description
99100
- **Flow**: implicit
100101
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
101102
- **Scopes**:
102-
- write:pets: modify pets in your account */ &#39; &quot; &#x3D;end
103-
- read:pets: read your pets */ &#39; &quot; &#x3D;end
103+
- write:pets: modify pets in your account */ &#39; &quot; &#x3D;end -- \r\n \n \r
104+
- read:pets: read your pets */ &#39; &quot; &#x3D;end -- \r\n \n \r
104105

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# IO.Swagger.Api.FakeApi
22

3-
All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end*
3+
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end - - \\r\\n \\n \\r/v2 *_/ ' \" =end - - \\r\\n \\n \\r*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**TestCodeInjectEnd**](FakeApi.md#testcodeinjectend) | **PUT** /fake | To test code injection &#39; \&quot; &#x3D;end
7+
[**TestCodeInjectEndRnNR**](FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end - - \\r\\n \\n \\r
88

99

10-
# **TestCodeInjectEnd**
11-
> void TestCodeInjectEnd (string testCodeInjectEnd = null)
10+
<a name="testcodeinjectendrnnr"></a>
11+
# **TestCodeInjectEndRnNR**
12+
> void TestCodeInjectEndRnNR (string testCodeInjectEndRnNR = null)
1213
13-
To test code injection ' \" =end
14+
To test code injection *_/ ' \" =end - - \\r\\n \\n \\r
1415

1516
### Example
1617
```csharp
@@ -22,22 +23,22 @@ using IO.Swagger.Model;
2223

2324
namespace Example
2425
{
25-
public class TestCodeInjectEndExample
26+
public class TestCodeInjectEndRnNRExample
2627
{
2728
public void main()
2829
{
2930

3031
var apiInstance = new FakeApi();
31-
var testCodeInjectEnd = testCodeInjectEnd_example; // string | To test code injection ' \" =end (optional)
32+
var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional)
3233
3334
try
3435
{
35-
// To test code injection ' \" =end
36-
apiInstance.TestCodeInjectEnd(testCodeInjectEnd);
36+
// To test code injection *_/ ' \" =end - - \\r\\n \\n \\r
37+
apiInstance.TestCodeInjectEndRnNR(testCodeInjectEndRnNR);
3738
}
3839
catch (Exception e)
3940
{
40-
Debug.Print("Exception when calling FakeApi.TestCodeInjectEnd: " + e.Message );
41+
Debug.Print("Exception when calling FakeApi.TestCodeInjectEndRnNR: " + e.Message );
4142
}
4243
}
4344
}
@@ -48,7 +49,7 @@ namespace Example
4849

4950
Name | Type | Description | Notes
5051
------------- | ------------- | ------------- | -------------
51-
**testCodeInjectEnd** | **string**| To test code injection &#39; \&quot; &#x3D;end | [optional]
52+
**testCodeInjectEndRnNR** | **string**| To test code injection *_/ &#39; \&quot; &#x3D;end - - \\r\\n \\n \\r | [optional]
5253

5354
### Return type
5455

@@ -60,8 +61,8 @@ No authorization required
6061

6162
### HTTP request headers
6263

63-
- **Content-Type**: application/json, */ ' =end
64-
- **Accept**: application/json, */ ' =end
64+
- **Content-Type**: application/json, *_/ ' =end - -
65+
- **Accept**: application/json, *_/ ' =end - -
6566

6667
[[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)
6768

samples/client/petstore-security-test/csharp/SwaggerClient/docs/ModelReturn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**_Return** | **int?** | property description &#39; \&quot; &#x3D;end | [optional]
6+
**_Return** | **int?** | property description *_/ &#39; \&quot; &#x3D;end - - \\r\\n \\n \\r | [optional]
77

88
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
99

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
Swagger Petstore ' \" =end
3+
Swagger Petstore *_/ ' \" =end - - \\r\\n \\n \\r
44
5-
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
5+
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 - -
66
7-
OpenAPI spec version: 1.0.0 ' \" =end
8-
Contact: [email protected] ' \" =end
7+
OpenAPI spec version: 1.0.0 *_/ ' \" =end - - \\r\\n \\n \\r
8+
Contact: [email protected] *_/ ' \" =end - - \\r\\n \\n \\r
99
Generated by: https://github.com/swagger-api/swagger-codegen.git
1010
1111
Licensed under the Apache License, Version 2.0 (the "License");
@@ -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>{29125490-71E4-47ED-B0D7-34505F58103C}</Project>
89+
<Project>{8CE139DF-64BC-4591-85F8-8506C2B67514}</Project>
9090
<Name>IO.Swagger</Name>
9191
</ProjectReference>
9292
</ItemGroup>

0 commit comments

Comments
 (0)