Skip to content

Commit

Permalink
Use WithSummary()
Browse files Browse the repository at this point in the history
Use the new WithSummary() extension method.
  • Loading branch information
martincostello committed Mar 17, 2022
1 parent 1983398 commit 66fbf8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/API/ApiModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static IEndpointRouteBuilder MapApiEndpoints(this IEndpointRouteBuilder b
.Produces<TimeResponse, TimeResponseExampleProvider>("The current UTC date and time.")
.RequireCors("DefaultCorsPolicy")
.WithName("Time")
.WithOperationDescription("Gets the current UTC time.");
.WithSummary("Gets the current UTC time.");

builder.MapGet("/tools/guid", (
[SwaggerParameterExample("The format for which to generate a GUID.", "D")] string? format,
Expand All @@ -89,7 +89,7 @@ public static IEndpointRouteBuilder MapApiEndpoints(this IEndpointRouteBuilder b
.Produces<GuidResponse, GuidResponseExampleProvider>("A GUID was generated successfully.")
.ProducesProblem("The specified format is invalid.")
.WithName("Guid")
.WithOperationDescription("Generates a GUID.")
.WithSummary("Generates a GUID.")
.WithProblemDetailsResponseExample();

builder.MapPost("/tools/hash", (HashRequest? request) =>
Expand Down Expand Up @@ -163,7 +163,7 @@ public static IEndpointRouteBuilder MapApiEndpoints(this IEndpointRouteBuilder b
.Produces<HashResponse, HashResponseExampleProvider>("The hash was generated successfully.")
.ProducesProblem("The specified hash algorithm or output format is invalid.")
.WithName("Hash")
.WithOperationDescription("Generates a hash of some plaintext for a specified hash algorithm and returns it in the required format.")
.WithSummary("Generates a hash of some plaintext for a specified hash algorithm and returns it in the required format.")
.WithProblemDetailsResponseExample();

builder.MapGet("/tools/machinekey", (
Expand Down Expand Up @@ -204,7 +204,7 @@ public static IEndpointRouteBuilder MapApiEndpoints(this IEndpointRouteBuilder b
.Produces<MachineKeyResponse, MachineKeyResponseExampleProvider>("The machine key was generated successfully.")
.ProducesProblem("The specified decryption or validation algorithm is invalid.")
.WithName("MachineKey")
.WithOperationDescription("Generates a machine key for a Web.config configuration file for ASP.NET.")
.WithSummary("Generates a machine key for a Web.config configuration file for ASP.NET.")
.WithProblemDetailsResponseExample();

return builder;
Expand Down
17 changes: 0 additions & 17 deletions src/API/Extensions/RouteHandlerBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,6 @@ internal static RouteHandlerBuilder ProducesProblem(
"application/problem+json");
}

/// <summary>
/// Adds the <see cref="SwaggerOperationAttribute"/> to the metadata for all builders produced by builder.
/// </summary>
/// <param name="builder">The <see cref="RouteHandlerBuilder"/>.</param>
/// <param name="summary">The operation summary.</param>
/// <param name="description">The optional operation description.</param>
/// <returns>
/// A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.
/// </returns>
internal static RouteHandlerBuilder WithOperationDescription(
this RouteHandlerBuilder builder,
string summary,
string? description = null)
{
return builder.WithMetadata(new SwaggerOperationAttribute(summary, description));
}

/// <summary>
/// Adds the <see cref="SwaggerResponseExampleAttribute"/> for <see cref="ProblemDetails"/> to the metadata for all builders produced by builder.
/// </summary>
Expand Down

0 comments on commit 66fbf8e

Please sign in to comment.