Merge pull request #2818 from wing328/bug/fix_2795

[C#] fix constructor with readonly property at the end
This commit is contained in:
wing328 2016-05-10 19:08:17 +08:00
commit 5aaf570782
16 changed files with 122 additions and 30 deletions

View File

@ -32,7 +32,7 @@
/// <param name="{{name}}">{{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.</param>
{{/isReadOnly}}
{{/vars}}
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} = null{{#hasMore}}, {{/hasMore}}{{/isReadOnly}}{{/vars}})
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} = null{{/isReadOnly}}{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/vars}})
{
{{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
if ({{name}} == null)

View File

@ -818,6 +818,9 @@ definitions:
format: int32
property:
type: string
123Number:
type: integer
readOnly: true
xml:
name: Name
200_response:

View File

@ -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", "{AC0D0300-7030-473F-B672-17C40187815A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}"
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
{AC0D0300-7030-473F-B672-17C40187815A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC0D0300-7030-473F-B672-17C40187815A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC0D0300-7030-473F-B672-17C40187815A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC0D0300-7030-473F-B672-17C40187815A}.Release|Any CPU.Build.0 = Release|Any CPU
{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}.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

View File

@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
- API version: 1.0.0
- SDK version: 1.0.0
- Build date: 2016-05-07T17:39:09.181+08:00
- Build date: 2016-05-10T17:39:13.582+08:00
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
## Frameworks supported
@ -69,7 +69,7 @@ namespace Example
try
{
// Fake endpoint for testing various parameters
// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
apiInstance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
}
catch (Exception e)
@ -87,7 +87,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status

View File

@ -4,6 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ClassName** | **string** | |
**Color** | **string** | | [optional] [default to "red"]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -4,6 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ClassName** | **string** | |
**Color** | **string** | | [optional] [default to "red"]
**Declawed** | **bool?** | | [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)

View File

@ -4,6 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ClassName** | **string** | |
**Color** | **string** | | [optional] [default to "red"]
**Breed** | **string** | | [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)

View File

@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters
[**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# **TestEndpointParameters**
> 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)
Fake endpoint for testing various parameters
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
### Example
```csharp
@ -45,7 +45,7 @@ namespace Example
try
{
// Fake endpoint for testing various parameters
// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
apiInstance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
}
catch (Exception e)

View File

@ -6,6 +6,7 @@ Name | Type | Description | Notes
**_Name** | **int?** | |
**SnakeCase** | **int?** | | [optional]
**Property** | **string** | | [optional]
**_123Number** | **int?** | | [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)

View File

@ -65,7 +65,7 @@
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
<Project>{AC0D0300-7030-473F-B672-17C40187815A}</Project>
<Project>{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}</Project>
<Name>IO.Swagger</Name>
</ProjectReference>
</ItemGroup>

View File

@ -14,10 +14,10 @@ namespace IO.Swagger.Api
{
#region Synchronous Operations
/// <summary>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -36,10 +36,10 @@ namespace IO.Swagger.Api
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);
/// <summary>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -59,10 +59,10 @@ namespace IO.Swagger.Api
#endregion Synchronous Operations
#region Asynchronous Operations
/// <summary>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -81,10 +81,10 @@ namespace IO.Swagger.Api
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);
/// <summary>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -192,7 +192,7 @@ namespace IO.Swagger.Api
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -214,7 +214,7 @@ namespace IO.Swagger.Api
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -303,7 +303,7 @@ namespace IO.Swagger.Api
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
@ -326,7 +326,7 @@ namespace IO.Swagger.Api
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AC0D0300-7030-473F-B672-17C40187815A}</ProjectGuid>
<ProjectGuid>{C075FB79-0DDE-43E3-9FA5-E239EE9B9B5A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Swagger Library</RootNamespace>

View File

@ -21,7 +21,8 @@ namespace IO.Swagger.Model
/// Initializes a new instance of the <see cref="Animal" /> class.
/// </summary>
/// <param name="ClassName">ClassName (required).</param>
public Animal(string ClassName = null)
/// <param name="Color">Color (default to &quot;red&quot;).</param>
public Animal(string ClassName = null, string Color = null)
{
// to ensure "ClassName" is required (not null)
if (ClassName == null)
@ -34,6 +35,16 @@ namespace IO.Swagger.Model
}
// use default value if no "Color" provided
if (Color == null)
{
this.Color = "red";
}
else
{
this.Color = Color;
}
}
/// <summary>
@ -42,6 +53,11 @@ namespace IO.Swagger.Model
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Color
/// </summary>
[DataMember(Name="color", EmitDefaultValue=false)]
public string Color { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
@ -50,6 +66,7 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Animal {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" Color: ").Append(Color).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
@ -90,6 +107,11 @@ namespace IO.Swagger.Model
this.ClassName == other.ClassName ||
this.ClassName != null &&
this.ClassName.Equals(other.ClassName)
) &&
(
this.Color == other.Color ||
this.Color != null &&
this.Color.Equals(other.Color)
);
}
@ -106,6 +128,8 @@ namespace IO.Swagger.Model
// Suitable nullity checks etc, of course :)
if (this.ClassName != null)
hash = hash * 59 + this.ClassName.GetHashCode();
if (this.Color != null)
hash = hash * 59 + this.Color.GetHashCode();
return hash;
}
}

View File

@ -21,8 +21,9 @@ namespace IO.Swagger.Model
/// Initializes a new instance of the <see cref="Cat" /> class.
/// </summary>
/// <param name="ClassName">ClassName (required).</param>
/// <param name="Color">Color (default to &quot;red&quot;).</param>
/// <param name="Declawed">Declawed.</param>
public Cat(string ClassName = null, bool? Declawed = null)
public Cat(string ClassName = null, string Color = null, bool? Declawed = null)
{
// to ensure "ClassName" is required (not null)
if (ClassName == null)
@ -35,6 +36,16 @@ namespace IO.Swagger.Model
}
// use default value if no "Color" provided
if (Color == null)
{
this.Color = "red";
}
else
{
this.Color = Color;
}
this.Declawed = Declawed;
}
@ -45,6 +56,11 @@ namespace IO.Swagger.Model
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Color
/// </summary>
[DataMember(Name="color", EmitDefaultValue=false)]
public string Color { get; set; }
/// <summary>
/// Gets or Sets Declawed
/// </summary>
[DataMember(Name="declawed", EmitDefaultValue=false)]
@ -58,6 +74,7 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Cat {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" Color: ").Append(Color).Append("\n");
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -100,6 +117,11 @@ sb.Append(" Declawed: ").Append(Declawed).Append("\n");
this.ClassName != null &&
this.ClassName.Equals(other.ClassName)
) &&
(
this.Color == other.Color ||
this.Color != null &&
this.Color.Equals(other.Color)
) &&
(
this.Declawed == other.Declawed ||
this.Declawed != null &&
@ -120,6 +142,8 @@ sb.Append(" Declawed: ").Append(Declawed).Append("\n");
// Suitable nullity checks etc, of course :)
if (this.ClassName != null)
hash = hash * 59 + this.ClassName.GetHashCode();
if (this.Color != null)
hash = hash * 59 + this.Color.GetHashCode();
if (this.Declawed != null)
hash = hash * 59 + this.Declawed.GetHashCode();
return hash;

View File

@ -21,8 +21,9 @@ namespace IO.Swagger.Model
/// Initializes a new instance of the <see cref="Dog" /> class.
/// </summary>
/// <param name="ClassName">ClassName (required).</param>
/// <param name="Color">Color (default to &quot;red&quot;).</param>
/// <param name="Breed">Breed.</param>
public Dog(string ClassName = null, string Breed = null)
public Dog(string ClassName = null, string Color = null, string Breed = null)
{
// to ensure "ClassName" is required (not null)
if (ClassName == null)
@ -35,6 +36,16 @@ namespace IO.Swagger.Model
}
// use default value if no "Color" provided
if (Color == null)
{
this.Color = "red";
}
else
{
this.Color = Color;
}
this.Breed = Breed;
}
@ -45,6 +56,11 @@ namespace IO.Swagger.Model
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Color
/// </summary>
[DataMember(Name="color", EmitDefaultValue=false)]
public string Color { get; set; }
/// <summary>
/// Gets or Sets Breed
/// </summary>
[DataMember(Name="breed", EmitDefaultValue=false)]
@ -58,6 +74,7 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Dog {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" Color: ").Append(Color).Append("\n");
sb.Append(" Breed: ").Append(Breed).Append("\n");
sb.Append("}\n");
return sb.ToString();
@ -100,6 +117,11 @@ sb.Append(" Breed: ").Append(Breed).Append("\n");
this.ClassName != null &&
this.ClassName.Equals(other.ClassName)
) &&
(
this.Color == other.Color ||
this.Color != null &&
this.Color.Equals(other.Color)
) &&
(
this.Breed == other.Breed ||
this.Breed != null &&
@ -120,6 +142,8 @@ sb.Append(" Breed: ").Append(Breed).Append("\n");
// Suitable nullity checks etc, of course :)
if (this.ClassName != null)
hash = hash * 59 + this.ClassName.GetHashCode();
if (this.Color != null)
hash = hash * 59 + this.Color.GetHashCode();
if (this.Breed != null)
hash = hash * 59 + this.Breed.GetHashCode();
return hash;

View File

@ -55,6 +55,11 @@ namespace IO.Swagger.Model
[DataMember(Name="property", EmitDefaultValue=false)]
public string Property { get; set; }
/// <summary>
/// Gets or Sets _123Number
/// </summary>
[DataMember(Name="123Number", EmitDefaultValue=false)]
public int? _123Number { get; private set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
@ -65,6 +70,7 @@ namespace IO.Swagger.Model
sb.Append(" _Name: ").Append(_Name).Append("\n");
sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n");
sb.Append(" Property: ").Append(Property).Append("\n");
sb.Append(" _123Number: ").Append(_123Number).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
@ -115,6 +121,11 @@ sb.Append(" Property: ").Append(Property).Append("\n");
this.Property == other.Property ||
this.Property != null &&
this.Property.Equals(other.Property)
) &&
(
this._123Number == other._123Number ||
this._123Number != null &&
this._123Number.Equals(other._123Number)
);
}
@ -135,6 +146,8 @@ sb.Append(" Property: ").Append(Property).Append("\n");
hash = hash * 59 + this.SnakeCase.GetHashCode();
if (this.Property != null)
hash = hash * 59 + this.Property.GetHashCode();
if (this._123Number != null)
hash = hash * 59 + this._123Number.GetHashCode();
return hash;
}
}