Skip to content

Commit c39bf41

Browse files
committed
Merge pull request #2477 from wing328/csharp_fix_docstring
[C#] minor fix to docstring in csharp
2 parents 94f8661 + 13712ee commit c39bf41

File tree

13 files changed

+450
-6
lines changed

13 files changed

+450
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace {{packageName}}.Client
2525
/// <param name="tempFolderPath">Temp folder path</param>
2626
/// <param name="dateTimeFormat">DateTime format string</param>
2727
/// <param name="timeout">HTTP connection timeout (in milliseconds)</param>
28+
/// <param name="userAgent">HTTP user agent</param>
2829
public Configuration(ApiClient apiClient = null,
2930
Dictionary<String, String> defaultHeader = null,
3031
string username = null,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
public enum {{vendorExtensions.plainDatatypeWithEnum}} {
1+
public enum {{vendorExtensions.plainDatatypeWithEnum}} {
22
{{#allowableValues}}{{#enumVars}}
33
[EnumMember(Value = "{{jsonname}}")]
44
{{name}}{{^-last}},
55
{{/-last}}{{#-last}}{{/-last}}{{/enumVars}}{{/allowableValues}}
6-
}
6+
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ namespace {{packageName}}.Model
2020
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
2121
{ {{#vars}}{{#isEnum}}
2222

23+
/// <summary>
24+
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
25+
/// </summary>{{#description}}
26+
/// <value>{{{description}}}</value>{{/description}}
2327
[JsonConverter(typeof(StringEnumConverter))]
24-
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
25-
{{>enumClass}}{{/items}}{{/items.isEnum}}{{/vars}}
28+
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
29+
{{>enumClass}}{{/items}}{{/items.isEnum}}{{/vars}}
2630
{{#vars}}{{#isEnum}}
2731
/// <summary>
2832
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public void _NameTest()
6060
// TODO: unit test for the property '_Name'
6161
}
6262

63+
/// <summary>
64+
/// Test the property 'SnakeCase'
65+
/// </summary>
66+
[Test]
67+
public void SnakeCaseTest()
68+
{
69+
// TODO: unit test for the property 'SnakeCase'
70+
}
71+
6372

6473
}
6574

samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class Configuration
2525
/// <param name="tempFolderPath">Temp folder path</param>
2626
/// <param name="dateTimeFormat">DateTime format string</param>
2727
/// <param name="timeout">HTTP connection timeout (in milliseconds)</param>
28+
/// <param name="userAgent">HTTP user agent</param>
2829
public Configuration(ApiClient apiClient = null,
2930
Dictionary<String, String> defaultHeader = null,
3031
string username = null,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System;
2+
using System.Linq;
3+
using System.IO;
4+
using System.Text;
5+
using System.Collections;
6+
using System.Collections.Generic;
7+
using System.Collections.ObjectModel;
8+
using System.Runtime.Serialization;
9+
using Newtonsoft.Json;
10+
using Newtonsoft.Json.Converters;
11+
12+
namespace IO.Swagger.Model
13+
{
14+
/// <summary>
15+
///
16+
/// </summary>
17+
[DataContract]
18+
public partial class Animal : IEquatable<Animal>
19+
{
20+
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="Animal" /> class.
23+
/// Initializes a new instance of the <see cref="Animal" />class.
24+
/// </summary>
25+
/// <param name="ClassName">ClassName (required).</param>
26+
27+
public Animal(string ClassName = null)
28+
{
29+
// to ensure "ClassName" is required (not null)
30+
if (ClassName == null)
31+
{
32+
throw new InvalidDataException("ClassName is a required property for Animal and cannot be null");
33+
}
34+
else
35+
{
36+
this.ClassName = ClassName;
37+
}
38+
39+
}
40+
41+
42+
/// <summary>
43+
/// Gets or Sets ClassName
44+
/// </summary>
45+
[DataMember(Name="className", EmitDefaultValue=false)]
46+
public string ClassName { get; set; }
47+
48+
/// <summary>
49+
/// Returns the string presentation of the object
50+
/// </summary>
51+
/// <returns>String presentation of the object</returns>
52+
public override string ToString()
53+
{
54+
var sb = new StringBuilder();
55+
sb.Append("class Animal {\n");
56+
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
57+
58+
sb.Append("}\n");
59+
return sb.ToString();
60+
}
61+
62+
/// <summary>
63+
/// Returns the JSON string presentation of the object
64+
/// </summary>
65+
/// <returns>JSON string presentation of the object</returns>
66+
public string ToJson()
67+
{
68+
return JsonConvert.SerializeObject(this, Formatting.Indented);
69+
}
70+
71+
/// <summary>
72+
/// Returns true if objects are equal
73+
/// </summary>
74+
/// <param name="obj">Object to be compared</param>
75+
/// <returns>Boolean</returns>
76+
public override bool Equals(object obj)
77+
{
78+
// credit: http://stackoverflow.com/a/10454552/677735
79+
return this.Equals(obj as Animal);
80+
}
81+
82+
/// <summary>
83+
/// Returns true if Animal instances are equal
84+
/// </summary>
85+
/// <param name="other">Instance of Animal to be compared</param>
86+
/// <returns>Boolean</returns>
87+
public bool Equals(Animal other)
88+
{
89+
// credit: http://stackoverflow.com/a/10454552/677735
90+
if (other == null)
91+
return false;
92+
93+
return
94+
(
95+
this.ClassName == other.ClassName ||
96+
this.ClassName != null &&
97+
this.ClassName.Equals(other.ClassName)
98+
);
99+
}
100+
101+
/// <summary>
102+
/// Gets the hash code
103+
/// </summary>
104+
/// <returns>Hash code</returns>
105+
public override int GetHashCode()
106+
{
107+
// credit: http://stackoverflow.com/a/263416/677735
108+
unchecked // Overflow is fine, just wrap
109+
{
110+
int hash = 41;
111+
// Suitable nullity checks etc, of course :)
112+
113+
if (this.ClassName != null)
114+
hash = hash * 59 + this.ClassName.GetHashCode();
115+
116+
return hash;
117+
}
118+
}
119+
120+
}
121+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using System;
2+
using System.Linq;
3+
using System.IO;
4+
using System.Text;
5+
using System.Collections;
6+
using System.Collections.Generic;
7+
using System.Collections.ObjectModel;
8+
using System.Runtime.Serialization;
9+
using Newtonsoft.Json;
10+
using Newtonsoft.Json.Converters;
11+
12+
namespace IO.Swagger.Model
13+
{
14+
/// <summary>
15+
///
16+
/// </summary>
17+
[DataContract]
18+
public partial class Cat : Animal, IEquatable<Cat>
19+
{
20+
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="Cat" /> class.
23+
/// Initializes a new instance of the <see cref="Cat" />class.
24+
/// </summary>
25+
/// <param name="ClassName">ClassName (required).</param>
26+
/// <param name="Declawed">Declawed.</param>
27+
28+
public Cat(string ClassName = null, bool? Declawed = null)
29+
{
30+
// to ensure "ClassName" is required (not null)
31+
if (ClassName == null)
32+
{
33+
throw new InvalidDataException("ClassName is a required property for Cat and cannot be null");
34+
}
35+
else
36+
{
37+
this.ClassName = ClassName;
38+
}
39+
this.Declawed = Declawed;
40+
41+
}
42+
43+
44+
/// <summary>
45+
/// Gets or Sets ClassName
46+
/// </summary>
47+
[DataMember(Name="className", EmitDefaultValue=false)]
48+
public string ClassName { get; set; }
49+
50+
/// <summary>
51+
/// Gets or Sets Declawed
52+
/// </summary>
53+
[DataMember(Name="declawed", EmitDefaultValue=false)]
54+
public bool? Declawed { get; set; }
55+
56+
/// <summary>
57+
/// Returns the string presentation of the object
58+
/// </summary>
59+
/// <returns>String presentation of the object</returns>
60+
public override string ToString()
61+
{
62+
var sb = new StringBuilder();
63+
sb.Append("class Cat {\n");
64+
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
65+
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
66+
67+
sb.Append("}\n");
68+
return sb.ToString();
69+
}
70+
71+
/// <summary>
72+
/// Returns the JSON string presentation of the object
73+
/// </summary>
74+
/// <returns>JSON string presentation of the object</returns>
75+
public new string ToJson()
76+
{
77+
return JsonConvert.SerializeObject(this, Formatting.Indented);
78+
}
79+
80+
/// <summary>
81+
/// Returns true if objects are equal
82+
/// </summary>
83+
/// <param name="obj">Object to be compared</param>
84+
/// <returns>Boolean</returns>
85+
public override bool Equals(object obj)
86+
{
87+
// credit: http://stackoverflow.com/a/10454552/677735
88+
return this.Equals(obj as Cat);
89+
}
90+
91+
/// <summary>
92+
/// Returns true if Cat instances are equal
93+
/// </summary>
94+
/// <param name="other">Instance of Cat to be compared</param>
95+
/// <returns>Boolean</returns>
96+
public bool Equals(Cat other)
97+
{
98+
// credit: http://stackoverflow.com/a/10454552/677735
99+
if (other == null)
100+
return false;
101+
102+
return
103+
(
104+
this.ClassName == other.ClassName ||
105+
this.ClassName != null &&
106+
this.ClassName.Equals(other.ClassName)
107+
) &&
108+
(
109+
this.Declawed == other.Declawed ||
110+
this.Declawed != null &&
111+
this.Declawed.Equals(other.Declawed)
112+
);
113+
}
114+
115+
/// <summary>
116+
/// Gets the hash code
117+
/// </summary>
118+
/// <returns>Hash code</returns>
119+
public override int GetHashCode()
120+
{
121+
// credit: http://stackoverflow.com/a/263416/677735
122+
unchecked // Overflow is fine, just wrap
123+
{
124+
int hash = 41;
125+
// Suitable nullity checks etc, of course :)
126+
127+
if (this.ClassName != null)
128+
hash = hash * 59 + this.ClassName.GetHashCode();
129+
130+
if (this.Declawed != null)
131+
hash = hash * 59 + this.Declawed.GetHashCode();
132+
133+
return hash;
134+
}
135+
}
136+
137+
}
138+
}

0 commit comments

Comments
 (0)