Support for ValueTuple type in response body type
See original GitHub issueDescribe
Tuple and ValueTuple seem to have the same response. However, when ValueTuple type is used for Description, “Example” (or Schema) is not described normally.
For example, I wrote the code like this, (check body Type). Then I check the response && swagger.
code
[Function(nameof(PetStoreHttpTrigger.SystemTupleHandler))]
[OpenApiOperation(operationId: "SystemTupleHandler", tags: new[] { "tuple" })]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Tuple<int,double,string>))]
public async Task<Tuple<int,double,string>> SystemTupleHandler(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "system-tuple")] HttpRequestData req,
FunctionContext executionContext)
{
var tuple = Tuple.Create(1,1.5,"3");
return await Task.FromResult(tuple).ConfigureAwait(false);
}
[Function(nameof(PetStoreHttpTrigger.SystemValueTupleHandler))]
[OpenApiOperation(operationId: "SystemValueTupleHandler", tags: new[] { "tuple" })]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(ValueTuple<int, double, string>))]
public async Task<ValueTuple<int, double, string>> SystemValueTupleHandler(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "system-valuetuple")] HttpRequestData req,
FunctionContext executionContext)
{
var tuple = ValueTuple.Create(1, 1.5, "3");
return await Task.FromResult(tuple).ConfigureAwait(false);
}
[Function(nameof(PetStoreHttpTrigger.SystemValueTupleSyntaxHandler))]
[OpenApiOperation(operationId: "SystemValueTupleSyntaxHandler", tags: new[] { "tuple" })]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof((int,double,string)))]
public async Task<(int,double,string)> SystemValueTupleSyntaxHandler(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "system-valuetuplesyntax")] HttpRequestData req,
FunctionContext executionContext)
{
var tuple = (1, 1.5, "3");
return await Task.FromResult(tuple).ConfigureAwait(false);
}
Response / swagger
Env Information
- Windows 10 Education (21H1)
- Azure Function Local Test
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Is params Keyword supports with ValueTuple as a ...
A value tuple is a struct with variable length generic parameters and has been given a special syntax for initialization and usage (most...
Read more >ValueTuple Struct (System)
The ValueTuple structure represents a tuple that has no elements. It is useful primarily for its static methods that let you create and...
Read more >Use ValueTuple element names in minimal route handlers
The problem is that the schema for the lives with the methods and not with the type. This means that we need to...
Read more >Request and response objects
Django uses request and response objects to pass state through the system. When a page is requested, ... CONTENT_TYPE – The MIME type...
Read more >C# 7 ValueTuple types and their limitations - Joseph Woodward
C# 7's Tuple type is now a value type, meaning there's no heap allocation and one less de-allocation to worry about when compacting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found the reason. in the document “Members like Item1 and Item2 are fields, not properties.” content can be found
So it is not automatically serialized. I’ll be able to make new visitor for ValueTuple.
@Lee-WonJun I’ll assign this to you to take a look.