-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Milestone
Description
SwashBuckle will generate a swagger json similar to the following for List. The generated client code contains a couple mistakes.
- The name is missing
- Missing [JsonConverter(typeof(StringEnumConverter))]
- The generic type in the list is correct in the constructor, but incorrect in the property
public enum {
[EnumMember(Value = "food")]
Food,
[EnumMember(Value = "bar")]
Bar
}
public ResponseContract(GoodEnumEnum? GoodEnum = null, List<listOfEnumsEnum?> ListOfEnums = null)
{
this.GoodEnum = GoodEnum;
this.ListOfEnums = ListOfEnums;
}
/// <summary>
/// Some Description
/// </summary>
/// <value>Some Description</value>
[DataMember(Name="listOfEnums", EmitDefaultValue=false)]
public List<string> ListOfEnums { get; set; }
Swagger Doc:
{
"swagger": "2.0",
"info": {
"version": "V1",
"title": "Title"
},
"host": "example.com",
"schemes": [ "https" ],
"paths": {
"/v1.0/example": {
"post": {
"tags": ["Tag"],
"summary": "Summary",
"operationId": "Some Id",
"consumes": ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"],
"produces": ["application/json", "text/json", "application/xml", "text/xml"],
"parameters": [{
"name": "request",
"in": "body",
"description": "request",
"required": true,
"schema": {
"$ref": "#/definitions/ResponseContract"
}
}],
"responses": {
"200": {
"description": "Some description",
"schema": {
"$ref": "#/definitions/ResponseContract"
}
}
},
"deprecated": false
}
}
},
"definitions": {
"ResponseContract": {
"description": "Some Description",
"type": "object",
"properties": {
"goodEnum": {
"description": "Some Description",
"enum": ["food", "bar"],
"type": "string"
},
"listOfEnums": {
"description": "Some Description",
"type": "array",
"items": {
"enum": ["food", "bar"],
"type": "string"
},
"readOnly": true
}
}
}
}
}
I have a fix, but it is leveraging a hack written by a previous contributor. I'll submit a pull request so that we can discuss.
Reactions are currently unavailable