Skip to content

Commit 761ff17

Browse files
committed
Add more tests
1 parent 21fdc73 commit 761ff17

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/OperationTests.MinimalApis.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ public static string Get2(string name)
6969
}
7070
7171
/// <param name="name" example="Testy McTester">The name of the person.</param>
72+
/// <returns>Returns the greeting.</returns>
73+
/// <returns>Returns a different greeting.</returns>
7274
public static string Get3(string name)
7375
{
7476
return $"Hello, {name}!";
7577
}
7678
77-
/// <returns>This gets ignored. We favor response over returns.</returns>
78-
/// <response code="404">Indicates that the value was not found.</response>
79+
/// <returns>Indicates that the value was not found.</returns>
7980
public static NotFound<string> Get4()
8081
{
8182
return TypedResults.NotFound("Not found!");
@@ -249,6 +250,7 @@ await SnapshotTestHelper.VerifyOpenApi(compilation, document =>
249250
Assert.Equal("The name of the person.", path3.Parameters[0].Description);
250251
var example = Assert.IsAssignableFrom<JsonNode>(path3.Parameters[0].Example);
251252
Assert.Equal("\"Testy McTester\"", example.ToJsonString());
253+
Assert.Equal("Returns the greeting.", path3.Responses["200"].Description);
252254

253255
var path4 = document.Paths["/4"].Operations[HttpMethod.Get];
254256
var response = path4.Responses["404"];

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ private static Dictionary<string, XmlComment> GenerateCacheEntries()
7575

7676
cache.Add(@"M:RouteHandlerExtensionMethods.Get~System.String", new XmlComment(@"A summary of the action.", @"A description of the action.", null, @"Returns the greeting.", null, false, null, null, null));
7777
cache.Add(@"M:RouteHandlerExtensionMethods.Get2(System.String)~System.String", new XmlComment(null, null, null, null, null, false, null, [new XmlParameterComment(@"name", @"The name of the person.", null, false)], [new XmlResponseComment(@"200", @"Returns the greeting.", @"")]));
78-
cache.Add(@"M:RouteHandlerExtensionMethods.Get3(System.String)~System.String", new XmlComment(null, null, null, null, null, false, null, [new XmlParameterComment(@"name", @"The name of the person.", @"Testy McTester", false)], null));
79-
cache.Add(@"M:RouteHandlerExtensionMethods.Get4~Microsoft.AspNetCore.Http.HttpResults.NotFound{System.String}", new XmlComment(null, null, null, @"This gets ignored. We favor response over returns.", null, false, null, null, [new XmlResponseComment(@"404", @"Indicates that the value was not found.", @"")]));
78+
cache.Add(@"M:RouteHandlerExtensionMethods.Get3(System.String)~System.String", new XmlComment(null, null, null, @"Returns the greeting.", null, false, null, [new XmlParameterComment(@"name", @"The name of the person.", @"Testy McTester", false)], null));
79+
cache.Add(@"M:RouteHandlerExtensionMethods.Get4~Microsoft.AspNetCore.Http.HttpResults.NotFound{System.String}", new XmlComment(null, null, null, @"Indicates that the value was not found.", null, false, null, null, null));
8080
cache.Add(@"M:RouteHandlerExtensionMethods.Get5~Microsoft.AspNetCore.Http.HttpResults.Results{Microsoft.AspNetCore.Http.HttpResults.NotFound{System.String},Microsoft.AspNetCore.Http.HttpResults.Ok{System.String},Microsoft.AspNetCore.Http.HttpResults.Created}", new XmlComment(null, null, null, @"This gets ignored.", null, false, null, null, [new XmlResponseComment(@"200", @"Indicates that the value is even.", @""), new XmlResponseComment(@"201", @"Indicates that the value is less than 50.", @""), new XmlResponseComment(@"404", @"Indicates that the value was not found.", @"")]));
8181
cache.Add(@"M:RouteHandlerExtensionMethods.Post6(User)~Microsoft.AspNetCore.Http.IResult", new XmlComment(@"Creates a new user.", null, @"Sample request:
8282
POST /6

0 commit comments

Comments
 (0)