mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
[aspnetcore] Fix string enum generation (#7581)
* [aspnetcore] Fix enum strings generation regression * [aspnetcore] Regenerate sample
This commit is contained in:
parent
b184fb1d9c
commit
8668175879
@ -1,13 +1,18 @@
|
||||
|
||||
/// <summary>
|
||||
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
/// <value>{{{description}}}</value>{{/description}}
|
||||
/// </summary>
|
||||
{{#description}}
|
||||
/// <value>{{{description}}}</value>
|
||||
{{/description}}
|
||||
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}
|
||||
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
|
||||
{ {{#allowableValues}}{{#enumVars}}
|
||||
{
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
/// <summary>
|
||||
/// Enum {{name}} for {{{value}}}
|
||||
/// </summary>
|
||||
[EnumMember(Value = {{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isFloat}}"{{/isFloat}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isFloat}}"{{/isFloat}})]
|
||||
{{name}}{{#isLong}} = {{{value}}}{{/isLong}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^isInteger}} = {{-index}}{{/isInteger}}{{^-last}},
|
||||
{{#isString}}[EnumMember(Value = "{{{value}}}")]{{/isString}}
|
||||
{{name}}{{^isString}} = {{{value}}}{{/isString}}{{#isString}} = {{-index}}{{/isString}}{{^-last}},
|
||||
{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.4.0-SNAPSHOT
|
@ -92,7 +92,7 @@ namespace IO.Swagger.Controllers
|
||||
|
||||
string exampleJson = null;
|
||||
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>";
|
||||
exampleJson = "[ {\n \"tags\" : [ {\n \"id\" : 1,\n \"name\" : \"name\"\n }, {\n \"id\" : 1,\n \"name\" : \"name\"\n } ],\n \"id\" : 0,\n \"category\" : {\n \"id\" : 6,\n \"name\" : \"name\"\n },\n \"status\" : \"available\",\n \"name\" : \"doggie\",\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ]\n}, {\n \"tags\" : [ {\n \"id\" : 1,\n \"name\" : \"name\"\n }, {\n \"id\" : 1,\n \"name\" : \"name\"\n } ],\n \"id\" : 0,\n \"category\" : {\n \"id\" : 6,\n \"name\" : \"name\"\n },\n \"status\" : \"available\",\n \"name\" : \"doggie\",\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ]\n} ]";
|
||||
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}, {\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} ]";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
|
||||
@ -123,7 +123,7 @@ namespace IO.Swagger.Controllers
|
||||
|
||||
string exampleJson = null;
|
||||
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>";
|
||||
exampleJson = "[ {\n \"tags\" : [ {\n \"id\" : 1,\n \"name\" : \"name\"\n }, {\n \"id\" : 1,\n \"name\" : \"name\"\n } ],\n \"id\" : 0,\n \"category\" : {\n \"id\" : 6,\n \"name\" : \"name\"\n },\n \"status\" : \"available\",\n \"name\" : \"doggie\",\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ]\n}, {\n \"tags\" : [ {\n \"id\" : 1,\n \"name\" : \"name\"\n }, {\n \"id\" : 1,\n \"name\" : \"name\"\n } ],\n \"id\" : 0,\n \"category\" : {\n \"id\" : 6,\n \"name\" : \"name\"\n },\n \"status\" : \"available\",\n \"name\" : \"doggie\",\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ]\n} ]";
|
||||
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}, {\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} ]";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
|
||||
@ -158,7 +158,7 @@ namespace IO.Swagger.Controllers
|
||||
|
||||
string exampleJson = null;
|
||||
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>";
|
||||
exampleJson = "{\n \"tags\" : [ {\n \"id\" : 1,\n \"name\" : \"name\"\n }, {\n \"id\" : 1,\n \"name\" : \"name\"\n } ],\n \"id\" : 0,\n \"category\" : {\n \"id\" : 6,\n \"name\" : \"name\"\n },\n \"status\" : \"available\",\n \"name\" : \"doggie\",\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ]\n}";
|
||||
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}";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<Pet>(exampleJson)
|
||||
@ -234,7 +234,7 @@ namespace IO.Swagger.Controllers
|
||||
// return StatusCode(200, default(ApiResponse));
|
||||
|
||||
string exampleJson = null;
|
||||
exampleJson = "{\n \"message\" : \"message\",\n \"code\" : 0,\n \"type\" : \"type\"\n}";
|
||||
exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<ApiResponse>(exampleJson)
|
||||
|
@ -105,7 +105,7 @@ namespace IO.Swagger.Controllers
|
||||
|
||||
string exampleJson = null;
|
||||
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>";
|
||||
exampleJson = "{\n \"id\" : 0,\n \"petId\" : 6,\n \"complete\" : false,\n \"status\" : \"placed\",\n \"quantity\" : 1,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\"\n}";
|
||||
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}";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<Order>(exampleJson)
|
||||
@ -136,7 +136,7 @@ namespace IO.Swagger.Controllers
|
||||
|
||||
string exampleJson = null;
|
||||
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>";
|
||||
exampleJson = "{\n \"id\" : 0,\n \"petId\" : 6,\n \"complete\" : false,\n \"status\" : \"placed\",\n \"quantity\" : 1,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\"\n}";
|
||||
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}";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<Order>(exampleJson)
|
||||
|
@ -137,7 +137,7 @@ namespace IO.Swagger.Controllers
|
||||
|
||||
string exampleJson = null;
|
||||
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>";
|
||||
exampleJson = "{\n \"id\" : 0,\n \"lastName\" : \"lastName\",\n \"phone\" : \"phone\",\n \"username\" : \"username\",\n \"email\" : \"email\",\n \"userStatus\" : 6,\n \"firstName\" : \"firstName\",\n \"password\" : \"password\"\n}";
|
||||
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}";
|
||||
|
||||
var example = exampleJson != null
|
||||
? JsonConvert.DeserializeObject<User>(exampleJson)
|
||||
|
@ -50,26 +50,29 @@ namespace IO.Swagger.Models
|
||||
/// </summary>
|
||||
[DataMember(Name="shipDate")]
|
||||
public DateTime? ShipDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
/// <value>Order Status</value>
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public enum StatusEnum
|
||||
{
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum PlacedEnum for "placed"
|
||||
/// Enum PlacedEnum for placed
|
||||
/// </summary>
|
||||
[EnumMember(Value = "placed")]
|
||||
PlacedEnum = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Enum ApprovedEnum for "approved"
|
||||
/// Enum ApprovedEnum for approved
|
||||
/// </summary>
|
||||
[EnumMember(Value = "approved")]
|
||||
ApprovedEnum = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Enum DeliveredEnum for "delivered"
|
||||
/// Enum DeliveredEnum for delivered
|
||||
/// </summary>
|
||||
[EnumMember(Value = "delivered")]
|
||||
DeliveredEnum = 3
|
||||
|
@ -58,26 +58,29 @@ namespace IO.Swagger.Models
|
||||
/// </summary>
|
||||
[DataMember(Name="tags")]
|
||||
public List<Tag> Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
/// <value>pet status in the store</value>
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public enum StatusEnum
|
||||
{
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum AvailableEnum for "available"
|
||||
/// Enum AvailableEnum for available
|
||||
/// </summary>
|
||||
[EnumMember(Value = "available")]
|
||||
AvailableEnum = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Enum PendingEnum for "pending"
|
||||
/// Enum PendingEnum for pending
|
||||
/// </summary>
|
||||
[EnumMember(Value = "pending")]
|
||||
PendingEnum = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Enum SoldEnum for "sold"
|
||||
/// Enum SoldEnum for sold
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sold")]
|
||||
SoldEnum = 3
|
||||
|
@ -108,8 +108,8 @@
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string",
|
||||
"enum" : [ "available", "pending", "sold" ],
|
||||
"default" : "available"
|
||||
"default" : "available",
|
||||
"enum" : [ "available", "pending", "sold" ]
|
||||
},
|
||||
"collectionFormat" : "csv"
|
||||
} ],
|
||||
@ -685,12 +685,12 @@
|
||||
"title" : "Pet Order",
|
||||
"description" : "An order for a pets from the pet store",
|
||||
"example" : {
|
||||
"id" : 0,
|
||||
"petId" : 6,
|
||||
"complete" : false,
|
||||
"status" : "placed",
|
||||
"quantity" : 1,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Order"
|
||||
@ -710,8 +710,8 @@
|
||||
"title" : "Pet category",
|
||||
"description" : "A category for a pet",
|
||||
"example" : {
|
||||
"id" : 6,
|
||||
"name" : "name"
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Category"
|
||||
@ -751,14 +751,14 @@
|
||||
"title" : "a User",
|
||||
"description" : "A User who is purchasing from the pet store",
|
||||
"example" : {
|
||||
"id" : 0,
|
||||
"lastName" : "lastName",
|
||||
"phone" : "phone",
|
||||
"username" : "username",
|
||||
"email" : "email",
|
||||
"userStatus" : 6,
|
||||
"firstName" : "firstName",
|
||||
"password" : "password"
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
@ -778,8 +778,8 @@
|
||||
"title" : "Pet Tag",
|
||||
"description" : "A tag for a pet",
|
||||
"example" : {
|
||||
"id" : 1,
|
||||
"name" : "name"
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Tag"
|
||||
@ -829,21 +829,21 @@
|
||||
"title" : "a Pet",
|
||||
"description" : "A pet for sale in the pet store",
|
||||
"example" : {
|
||||
"tags" : [ {
|
||||
"id" : 1,
|
||||
"name" : "name"
|
||||
}, {
|
||||
"id" : 1,
|
||||
"name" : "name"
|
||||
} ],
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"id" : 6,
|
||||
"name" : "name"
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"status" : "available",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ]
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Pet"
|
||||
@ -866,9 +866,9 @@
|
||||
"title" : "An uploaded response",
|
||||
"description" : "Describes the result of uploading an image resource",
|
||||
"example" : {
|
||||
"message" : "message",
|
||||
"code" : 0,
|
||||
"type" : "type"
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user