ardalis / ApiEndpoints

A project for supporting API Endpoints in ASP.NET Core web applications.
MIT License
3.09k stars 226 forks source link

Common endpoint controllers in swagger #14

Closed CrisBogucki closed 4 years ago

CrisBogucki commented 4 years ago

add grouping of endpoints in controllers in swagger.

ardalis commented 4 years ago

Seems like a good idea. Do you know how to do so?

ardalis commented 4 years ago

Maybe tags: https://swagger.io/docs/specification/grouping-operations-with-tags/ This has some good info on configuring swagger in asp.net core, but nothing on tags: https://code-maze.com/swagger-ui-asp-net-core-web-api/

This seems to have it: https://stackoverflow.com/a/53506078/13729

Any interest in doing a PR or you just want me to have a go at it?

CrisBogucki commented 4 years ago

I'm trying to do it ... with Route Generally, it is a great idea to write services in such a way, e.g. for logging in, registration. I plan to use it in my projects. Great idea. Look at what I've done here -> https://github.com/CrisBogucki/.NET-DRS-Modular-Monolith

CrisBogucki commented 4 years ago

if you want I can add my code

ardalis commented 4 years ago

I got this working in my CleanArchitecture repo using SwaggerOperation attribute: https://github.com/ardalis/CleanArchitecture/blob/master/src/CleanArchitecture.Web/Endpoints/ToDoItems/Create.cs#L20-L25

I had to enable annotations: https://github.com/ardalis/CleanArchitecture/blob/master/src/CleanArchitecture.Web/Startup.cs#L48

And install this package: https://github.com/ardalis/CleanArchitecture/blob/master/src/CleanArchitecture.Web/CleanArchitecture.Web.csproj#L20

If someone wants to add these to the sample in this repo that would be appreciated. @jeastham1993

jeastham1993 commented 4 years ago

Yep, I can do that whilst I've got the code locally!

jeastham1993 commented 4 years ago

@ardalis done and pull request created :)

ardalis commented 4 years ago

Fixed by #18