[aspnetcore] Add TypeConverter for enum string conversion (#3557)

* Add TypeConverter for enum
This commit is contained in:
Juang, Yi-Lin 2019-08-11 10:57:36 +08:00 committed by Jim Schubert
parent 42d6420400
commit 22d022b2d5
15 changed files with 149 additions and 80 deletions

View File

@ -327,6 +327,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
supportingFiles.add(new SupportingFile("typeConverter.mustache", packageFolder + File.separator + "Converters", "CustomEnumConverter.cs"));
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, packageName + ".csproj"));
if (!isLibrary) {
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));

View File

@ -5,7 +5,8 @@
{{#description}}
/// <value>{{{description}}}</value>
{{/description}}
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}[TypeConverter(typeof(CustomEnumConverter<{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}>))]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
{
{{#allowableValues}}{{#enumVars}}

View File

@ -3,9 +3,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using {{packageName}}.Converters;
{{#models}}
{{#model}}

View File

@ -0,0 +1,33 @@
using System;
using System.ComponentModel;
using System.Globalization;
using Newtonsoft.Json;
namespace {{packageName}}.Converters
{
/// <summary>
/// Custom string to enum converter
/// </summary>
public class CustomEnumConverter<T> : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var s = value as string;
if (string.IsNullOrEmpty(s))
{
return null;
}
return JsonConvert.DeserializeObject<T>(@"""" + value.ToString() + @"""");
}
}
}

View File

@ -1 +1 @@
4.0.1-SNAPSHOT
4.1.0-SNAPSHOT

View File

@ -16,8 +16,8 @@ using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using Org.OpenAPITools.Attributes;
using Org.OpenAPITools.Models;
using Microsoft.AspNetCore.Authorization;
using Org.OpenAPITools.Models;
namespace Org.OpenAPITools.Controllers
{
@ -38,10 +38,10 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("AddPet")]
public virtual IActionResult AddPet([FromBody]Pet body)
{
//TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(405);
throw new NotImplementedException();
}
@ -55,12 +55,12 @@ namespace Org.OpenAPITools.Controllers
[Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("DeletePet")]
public virtual IActionResult DeletePet([FromRoute][Required]long? petId, [FromHeader]string apiKey)
public virtual IActionResult DeletePet([FromRoute][Required]long petId, [FromHeader]string apiKey)
{
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
throw new NotImplementedException();
}
@ -78,12 +78,11 @@ namespace Org.OpenAPITools.Controllers
[SwaggerResponse(statusCode: 200, type: typeof(List<Pet>), description: "successful operation")]
public virtual IActionResult FindPetsByStatus([FromQuery][Required()]List<string> status)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(List<Pet>));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
string exampleJson = null;
exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}";
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
@ -109,12 +108,11 @@ namespace Org.OpenAPITools.Controllers
[SwaggerResponse(statusCode: 200, type: typeof(List<Pet>), description: "successful operation")]
public virtual IActionResult FindPetsByTags([FromQuery][Required()]List<string> tags)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(List<Pet>));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
string exampleJson = null;
exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}";
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
@ -140,17 +138,15 @@ namespace Org.OpenAPITools.Controllers
[ValidateModelState]
[SwaggerOperation("GetPetById")]
[SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")]
public virtual IActionResult GetPetById([FromRoute][Required]long? petId)
public virtual IActionResult GetPetById([FromRoute][Required]long petId)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(Pet));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
string exampleJson = null;
exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}";
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
@ -175,16 +171,14 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("UpdatePet")]
public virtual IActionResult UpdatePet([FromBody]Pet body)
{
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
//TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(405);
throw new NotImplementedException();
}
@ -199,12 +193,12 @@ namespace Org.OpenAPITools.Controllers
[Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("UpdatePetWithForm")]
public virtual IActionResult UpdatePetWithForm([FromRoute][Required]long? petId, [FromForm]string name, [FromForm]string status)
public virtual IActionResult UpdatePetWithForm([FromRoute][Required]long petId, [FromForm]string name, [FromForm]string status)
{
//TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(405);
throw new NotImplementedException();
}
@ -220,11 +214,11 @@ namespace Org.OpenAPITools.Controllers
[ValidateModelState]
[SwaggerOperation("UploadFile")]
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
public virtual IActionResult UploadFile([FromRoute][Required]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file)
public virtual IActionResult UploadFile([FromRoute][Required]long petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(ApiResponse));
string exampleJson = null;
exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}";

View File

@ -16,8 +16,8 @@ using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using Org.OpenAPITools.Attributes;
using Org.OpenAPITools.Models;
using Microsoft.AspNetCore.Authorization;
using Org.OpenAPITools.Models;
namespace Org.OpenAPITools.Controllers
{
@ -40,13 +40,12 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("DeleteOrder")]
public virtual IActionResult DeleteOrder([FromRoute][Required]string orderId)
{
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
throw new NotImplementedException();
}
@ -60,17 +59,17 @@ namespace Org.OpenAPITools.Controllers
[Authorize(Policy = "api_key")]
[ValidateModelState]
[SwaggerOperation("GetInventory")]
[SwaggerResponse(statusCode: 200, type: typeof(Dictionary<string, int?>), description: "successful operation")]
[SwaggerResponse(statusCode: 200, type: typeof(Dictionary<string, int>), description: "successful operation")]
public virtual IActionResult GetInventory()
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(Dictionary<string, int?>));
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(Dictionary<string, int>));
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<Dictionary<string, int?>>(exampleJson)
: default(Dictionary<string, int?>);
? JsonConvert.DeserializeObject<Dictionary<string, int>>(exampleJson)
: default(Dictionary<string, int>);
//TODO: Change the data returned
return new ObjectResult(example);
}
@ -88,17 +87,15 @@ namespace Org.OpenAPITools.Controllers
[ValidateModelState]
[SwaggerOperation("GetOrderById")]
[SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")]
public virtual IActionResult GetOrderById([FromRoute][Required][Range(1, 5)]long? orderId)
public virtual IActionResult GetOrderById([FromRoute][Required][Range(1, 5)]long orderId)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(Order));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
string exampleJson = null;
exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}";
exampleJson = "<Order>\n <id>123456789</id>\n <petId>123456789</petId>\n <quantity>123</quantity>\n <shipDate>2000-01-23T04:56:07.000Z</shipDate>\n <status>aeiou</status>\n <complete>true</complete>\n</Order>";
@ -123,12 +120,11 @@ namespace Org.OpenAPITools.Controllers
[SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")]
public virtual IActionResult PlaceOrder([FromBody]Order body)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(Order));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
string exampleJson = null;
exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}";
exampleJson = "<Order>\n <id>123456789</id>\n <petId>123456789</petId>\n <quantity>123</quantity>\n <shipDate>2000-01-23T04:56:07.000Z</shipDate>\n <status>aeiou</status>\n <complete>true</complete>\n</Order>";

View File

@ -16,8 +16,8 @@ using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using Org.OpenAPITools.Attributes;
using Org.OpenAPITools.Models;
using Microsoft.AspNetCore.Authorization;
using Org.OpenAPITools.Models;
namespace Org.OpenAPITools.Controllers
{
@ -39,10 +39,10 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("CreateUser")]
public virtual IActionResult CreateUser([FromBody]User body)
{
//TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(0);
throw new NotImplementedException();
}
@ -57,10 +57,10 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("CreateUsersWithArrayInput")]
public virtual IActionResult CreateUsersWithArrayInput([FromBody]List<User> body)
{
//TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(0);
throw new NotImplementedException();
}
@ -75,10 +75,10 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("CreateUsersWithListInput")]
public virtual IActionResult CreateUsersWithListInput([FromBody]List<User> body)
{
//TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(0);
throw new NotImplementedException();
}
@ -95,13 +95,12 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("DeleteUser")]
public virtual IActionResult DeleteUser([FromRoute][Required]string username)
{
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
throw new NotImplementedException();
}
@ -119,15 +118,13 @@ namespace Org.OpenAPITools.Controllers
[SwaggerResponse(statusCode: 200, type: typeof(User), description: "successful operation")]
public virtual IActionResult GetUserByName([FromRoute][Required]string username)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(User));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
string exampleJson = null;
exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}";
exampleJson = "<User>\n <id>123456789</id>\n <username>aeiou</username>\n <firstName>aeiou</firstName>\n <lastName>aeiou</lastName>\n <email>aeiou</email>\n <password>aeiou</password>\n <phone>aeiou</phone>\n <userStatus>123</userStatus>\n</User>";
@ -153,12 +150,11 @@ namespace Org.OpenAPITools.Controllers
[SwaggerResponse(statusCode: 200, type: typeof(string), description: "successful operation")]
public virtual IActionResult LoginUser([FromQuery][Required()]string username, [FromQuery][Required()]string password)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(string));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
string exampleJson = null;
var example = exampleJson != null
@ -178,10 +174,10 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("LogoutUser")]
public virtual IActionResult LogoutUser()
{
//TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(0);
throw new NotImplementedException();
}
@ -199,13 +195,12 @@ namespace Org.OpenAPITools.Controllers
[SwaggerOperation("UpdateUser")]
public virtual IActionResult UpdateUser([FromRoute][Required]string username, [FromBody]User body)
{
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400);
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404);
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.ComponentModel;
using System.Globalization;
using Newtonsoft.Json;
namespace Org.OpenAPITools.Converters
{
/// <summary>
/// Custom string to enum converter
/// </summary>
public class CustomEnumConverter<T> : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var s = value as string;
if (string.IsNullOrEmpty(s))
{
return null;
}
return JsonConvert.DeserializeObject<T>(@"""" + value.ToString() + @"""");
}
}
}

View File

@ -12,9 +12,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
@ -28,7 +30,7 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Code
/// </summary>
[DataMember(Name="code", EmitDefaultValue=false)]
public int? Code { get; set; }
public int Code { get; set; }
/// <summary>
/// Gets or Sets Type
@ -91,7 +93,7 @@ namespace Org.OpenAPITools.Models
return
(
Code == other.Code ||
Code != null &&
Code.Equals(other.Code)
) &&
(
@ -116,7 +118,7 @@ namespace Org.OpenAPITools.Models
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Code != null)
hashCode = hashCode * 59 + Code.GetHashCode();
if (Type != null)
hashCode = hashCode * 59 + Type.GetHashCode();

View File

@ -12,9 +12,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
@ -28,7 +30,7 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
public long Id { get; set; }
/// <summary>
/// Gets or Sets Name
@ -84,7 +86,7 @@ namespace Org.OpenAPITools.Models
return
(
Id == other.Id ||
Id != null &&
Id.Equals(other.Id)
) &&
(
@ -104,7 +106,7 @@ namespace Org.OpenAPITools.Models
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Name != null)
hashCode = hashCode * 59 + Name.GetHashCode();

View File

@ -12,9 +12,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
@ -28,30 +30,31 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
public long Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
[DataMember(Name="petId", EmitDefaultValue=false)]
public long? PetId { get; set; }
public long PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
[DataMember(Name="quantity", EmitDefaultValue=false)]
public int? Quantity { get; set; }
public int Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
[DataMember(Name="shipDate", EmitDefaultValue=false)]
public DateTime? ShipDate { get; set; }
public DateTime ShipDate { get; set; }
/// <summary>
/// Order Status
/// </summary>
/// <value>Order Status</value>
[TypeConverter(typeof(CustomEnumConverter<StatusEnum>))]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum StatusEnum
{
@ -86,7 +89,7 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Complete
/// </summary>
[DataMember(Name="complete", EmitDefaultValue=false)]
public bool? Complete { get; set; }
public bool Complete { get; set; } = false;
/// <summary>
/// Returns the string presentation of the object
@ -140,17 +143,17 @@ namespace Org.OpenAPITools.Models
return
(
Id == other.Id ||
Id != null &&
Id.Equals(other.Id)
) &&
(
PetId == other.PetId ||
PetId != null &&
PetId.Equals(other.PetId)
) &&
(
Quantity == other.Quantity ||
Quantity != null &&
Quantity.Equals(other.Quantity)
) &&
(
@ -165,7 +168,7 @@ namespace Org.OpenAPITools.Models
) &&
(
Complete == other.Complete ||
Complete != null &&
Complete.Equals(other.Complete)
);
}
@ -180,17 +183,17 @@ namespace Org.OpenAPITools.Models
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (PetId != null)
hashCode = hashCode * 59 + PetId.GetHashCode();
if (Quantity != null)
hashCode = hashCode * 59 + Quantity.GetHashCode();
if (ShipDate != null)
hashCode = hashCode * 59 + ShipDate.GetHashCode();
hashCode = hashCode * 59 + Status.GetHashCode();
if (Complete != null)
hashCode = hashCode * 59 + Complete.GetHashCode();
return hashCode;
}

View File

@ -12,9 +12,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
@ -28,7 +30,7 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
public long Id { get; set; }
/// <summary>
/// Gets or Sets Category
@ -60,6 +62,7 @@ namespace Org.OpenAPITools.Models
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
[TypeConverter(typeof(CustomEnumConverter<StatusEnum>))]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum StatusEnum
{
@ -142,7 +145,7 @@ namespace Org.OpenAPITools.Models
return
(
Id == other.Id ||
Id != null &&
Id.Equals(other.Id)
) &&
(
@ -184,7 +187,7 @@ namespace Org.OpenAPITools.Models
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Category != null)
hashCode = hashCode * 59 + Category.GetHashCode();

View File

@ -12,9 +12,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
@ -28,7 +30,7 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
public long Id { get; set; }
/// <summary>
/// Gets or Sets Name
@ -84,7 +86,7 @@ namespace Org.OpenAPITools.Models
return
(
Id == other.Id ||
Id != null &&
Id.Equals(other.Id)
) &&
(
@ -104,7 +106,7 @@ namespace Org.OpenAPITools.Models
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Name != null)
hashCode = hashCode * 59 + Name.GetHashCode();

View File

@ -12,9 +12,11 @@ using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
@ -28,7 +30,7 @@ namespace Org.OpenAPITools.Models
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
public long Id { get; set; }
/// <summary>
/// Gets or Sets Username
@ -71,7 +73,7 @@ namespace Org.OpenAPITools.Models
/// </summary>
/// <value>User Status</value>
[DataMember(Name="userStatus", EmitDefaultValue=false)]
public int? UserStatus { get; set; }
public int UserStatus { get; set; }
/// <summary>
/// Returns the string presentation of the object
@ -127,7 +129,7 @@ namespace Org.OpenAPITools.Models
return
(
Id == other.Id ||
Id != null &&
Id.Equals(other.Id)
) &&
(
@ -162,7 +164,7 @@ namespace Org.OpenAPITools.Models
) &&
(
UserStatus == other.UserStatus ||
UserStatus != null &&
UserStatus.Equals(other.UserStatus)
);
}
@ -177,7 +179,7 @@ namespace Org.OpenAPITools.Models
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Username != null)
hashCode = hashCode * 59 + Username.GetHashCode();
@ -191,7 +193,7 @@ namespace Org.OpenAPITools.Models
hashCode = hashCode * 59 + Password.GetHashCode();
if (Phone != null)
hashCode = hashCode * 59 + Phone.GetHashCode();
if (UserStatus != null)
hashCode = hashCode * 59 + UserStatus.GetHashCode();
return hashCode;
}