Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger documentation in separate class #184

Open
AdisonCavani opened this issue Jul 21, 2022 · 2 comments
Open

Swagger documentation in separate class #184

AdisonCavani opened this issue Jul 21, 2022 · 2 comments

Comments

@AdisonCavani
Copy link

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:

swagger-docs

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.

@ardalis
Copy link
Owner

ardalis commented Jul 21, 2022

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?

@AdisonCavani
Copy link
Author

I don't think it's a Swagger feature. I've looked at a source code and this is what I found:

Summary contructor
EndpointSummary class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants