ApiEndpoints
ApiEndpoints copied to clipboard
Swagger documentation in separate class
Currently, you can document endpoint using SwaggerOperation attribute above HandleAsync method:
[SwaggerOperation(
Summary = "Submit a new article",
Description = "Enables the submission of new articles",
OperationId = "B349A6C4-1198-4B53-B9BE-85232E06F16E",
Tags = new[] {"Article"})
]
Personally, I don't like this approach. Another library (FastEndpoints) has interesting alternative:
public class DeleteCustomerSummary : Summary<DeleteCustomerEndpoint>
{
public DeleteCustomerSummary()
{
Summary = "Deleted a customer the system";
Description = "Deleted a customer the system";
Response(204, "The customer was deleted successfully");
Response(404, "The customer was not found in the system");
}
}
which produces this Swagger documentation:

IMO this is much cleaner, because I don't make my endpoints clogged up with comments. Full project with this solution is here.
Is something like this possible with this library? If not, I'm passing it to you as a feature request.
I like that, too! I've seen FastEndpoints but didn't notice this. I wonder if they did anything to make it work, or if it's just a Swagger feature we can just use in the same manner?
I don't think it's a Swagger feature. I've looked at a source code and this is what I found: