diff --git a/src/Http/Wolverine.Http/HttpChain.EndpointBuilder.cs b/src/Http/Wolverine.Http/HttpChain.EndpointBuilder.cs index 884cecf06..6c828b65f 100644 --- a/src/Http/Wolverine.Http/HttpChain.EndpointBuilder.cs +++ b/src/Http/Wolverine.Http/HttpChain.EndpointBuilder.cs @@ -120,6 +120,18 @@ public RouteEndpoint BuildEndpoint(RouteWarmup warmup) builder.Metadata.Add(new RouteNameMetadata(RouteName)); } + builder.Metadata.Add(new EndpointNameMetadata(OperationId)); + + if (EndpointSummary.IsNotEmpty()) + { + builder.Metadata.Add(new WolverineEndpointSummaryMetadata(EndpointSummary)); + } + + if (EndpointDescription.IsNotEmpty()) + { + builder.Metadata.Add(new WolverineEndpointDescriptionMetadata(EndpointDescription)); + } + Endpoint = (RouteEndpoint?)builder.Build(); return Endpoint!; } @@ -169,4 +181,14 @@ internal class ProducesProblemDetailsResponseTypeMetadata : IProducesResponseTyp public Type? Type => typeof(ProblemDetails); public int StatusCode => 400; public IEnumerable ContentTypes => new string[] {"application/problem+json" }; +} + +internal class WolverineEndpointSummaryMetadata(string summary) : IEndpointSummaryMetadata +{ + public string Summary => summary; +} + +internal class WolverineEndpointDescriptionMetadata(string description) : IEndpointDescriptionMetadata +{ + public string Description => description; } \ No newline at end of file diff --git a/src/Http/Wolverine.Http/HttpChain.cs b/src/Http/Wolverine.Http/HttpChain.cs index 687e0a18e..fcf5f3990 100644 --- a/src/Http/Wolverine.Http/HttpChain.cs +++ b/src/Http/Wolverine.Http/HttpChain.cs @@ -69,7 +69,9 @@ public static bool IsValidResponseType(Type type) private readonly List _formValueVariables = []; public string OperationId { get; set; } - + public string? EndpointSummary { get; set; } + public string? EndpointDescription { get; set; } + /// /// This may be overridden by some IResponseAware policies in place of the first /// create variable of the method call @@ -128,6 +130,16 @@ public HttpChain(MethodCall method, HttpGraph parent) { OperationId = att.OperationId; } + + if (att.Summary.IsNotEmpty()) + { + EndpointSummary = att.Summary; + } + + if (att.Description.IsNotEmpty()) + { + EndpointDescription = att.Description; + } } OperationId ??= $"{Method.HandlerType.FullNameInCode()}.{Method.Method.Name}"; @@ -729,9 +741,9 @@ public HttpElementVariable GetOrCreateHeaderVariable(IFromHeaderMetadata metadat return frame.Variable; } - string IEndpointNameMetadata.EndpointName => ToString(); + string IEndpointNameMetadata.EndpointName => OperationId; - string IEndpointSummaryMetadata.Summary => ToString(); + string IEndpointSummaryMetadata.Summary => EndpointSummary ?? ToString(); public List FileParameters { get; } = []; diff --git a/src/Http/Wolverine.Http/ModifyHttpChainAttribute.cs b/src/Http/Wolverine.Http/ModifyHttpChainAttribute.cs index 476319ef6..d6353233b 100644 --- a/src/Http/Wolverine.Http/ModifyHttpChainAttribute.cs +++ b/src/Http/Wolverine.Http/ModifyHttpChainAttribute.cs @@ -75,6 +75,16 @@ protected WolverineHttpMethodAttribute(string httpMethod, string template) /// Swashbuckle /// public string? OperationId { get; set; } + + /// + /// Sets the summary for this endpoint in OpenAPI documentation + /// + public string? Summary { get; set; } + + /// + /// Sets the description for this endpoint in OpenAPI documentation + /// + public string? Description { get; set; } } ///