Skip to content

Commit f5ab78e

Browse files
committed
Added an E2E test validating OpenAPI document generation for Typed Result returning action
1 parent bd953ac commit f5ab78e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/OpenApi/sample/Controllers/TestController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.ComponentModel.DataAnnotations;
55
using System.Diagnostics.CodeAnalysis;
6+
using Microsoft.AspNetCore.Http.HttpResults;
67
using Microsoft.AspNetCore.Mvc;
78

89
[ApiController]
@@ -17,6 +18,13 @@ public string GetByIdAndName(RouteParamsContainer paramsContainer)
1718
return paramsContainer.Id + "_" + paramsContainer.Name;
1819
}
1920

21+
[HttpGet]
22+
[Route("/gettypedresult")]
23+
public Ok<MvcTodo> GetTypedResult()
24+
{
25+
return TypedResults.Ok(new MvcTodo("Title", "Description", true));
26+
}
27+
2028
[HttpPost]
2129
[Route("/forms")]
2230
public IActionResult PostForm([FromForm] MvcTodo todo)

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@
5454
}
5555
}
5656
},
57+
"/gettypedresult": {
58+
"get": {
59+
"tags": [
60+
"Test"
61+
],
62+
"responses": {
63+
"200": {
64+
"description": "OK",
65+
"content": {
66+
"application/json": {
67+
"schema": {
68+
"$ref": "#/components/schemas/MvcTodo"
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
},
5776
"/forms": {
5877
"post": {
5978
"tags": [
@@ -88,6 +107,29 @@
88107
}
89108
}
90109
},
110+
"components": {
111+
"schemas": {
112+
"MvcTodo": {
113+
"required": [
114+
"title",
115+
"description",
116+
"isCompleted"
117+
],
118+
"type": "object",
119+
"properties": {
120+
"title": {
121+
"type": "string"
122+
},
123+
"description": {
124+
"type": "string"
125+
},
126+
"isCompleted": {
127+
"type": "boolean"
128+
}
129+
}
130+
}
131+
}
132+
},
91133
"tags": [
92134
{
93135
"name": "Test"

0 commit comments

Comments
 (0)