Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Http/Wolverine.Http/HttpChain.EndpointBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
}
Expand Down Expand Up @@ -169,4 +181,14 @@ internal class ProducesProblemDetailsResponseTypeMetadata : IProducesResponseTyp
public Type? Type => typeof(ProblemDetails);
public int StatusCode => 400;
public IEnumerable<string> 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;
}
18 changes: 15 additions & 3 deletions src/Http/Wolverine.Http/HttpChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public static bool IsValidResponseType(Type type)
private readonly List<HttpElementVariable> _formValueVariables = [];

public string OperationId { get; set; }

public string? EndpointSummary { get; set; }
public string? EndpointDescription { get; set; }

/// <summary>
/// This may be overridden by some IResponseAware policies in place of the first
/// create variable of the method call
Expand Down Expand Up @@ -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}";
Expand Down Expand Up @@ -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<ParameterInfo> FileParameters { get; } = [];

Expand Down
10 changes: 10 additions & 0 deletions src/Http/Wolverine.Http/ModifyHttpChainAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ protected WolverineHttpMethodAttribute(string httpMethod, string template)
/// Swashbuckle
/// </summary>
public string? OperationId { get; set; }

/// <summary>
/// Sets the summary for this endpoint in OpenAPI documentation
/// </summary>
public string? Summary { get; set; }

/// <summary>
/// Sets the description for this endpoint in OpenAPI documentation
/// </summary>
public string? Description { get; set; }
}

/// <summary>
Expand Down
Loading