Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Support C#7 value tuples
Add support for c# 7 value tuple. Example. Consider following action
public (IEnumerable<string> Collection, string Token) TestAction()
{
return (new string[] { "value1", "value2" }, "TokenValue");
}
expected definition:
"definitions": {
"ValueTuple[IEnumerable[String],String]": {
"type": "object",
"properties": {
"Collection": {
"type": "array",
"items": {
"type": "string"
}
},
"Token": {
"type": "string"
}
}
}
},
actual definition
"definitions": {
"ValueTuple[IEnumerable[String],String]": {
"type": "object",
"properties": {
"item1": {
"type": "array",
"items": {
"type": "string"
}
},
"item2": {
"type": "string"
}
}
}
},
I'm note sure if this is swashbuckle's or aspnetcore ApiExplorer issue. @domaindrivendev can you give me some hints on implementing this?
I don't think swagger has any way of describing tuples hence I hardly how swashbuckle could provide a standard implementation of that.
ValueTuples can be treated as simple objects with well known property names matching values defined in generated TupleElementNamesAttribute. The only problem i can see is generating definition name.
+1
any news here? im kinda having a problem here also... It is worth noting that if you use List<KeyValuePair<string,string>>
the output is field:[{key:string,value:string}]
, so why not have List<(string Name, string Email)>
rendered as field:[{Name:string,Email:string}]