csharpfritz / InstantAPIs

A library that generates Minimal API endpoints for an Entity Framework context.
MIT License
448 stars 57 forks source link

Moved OpenAPI (Swagger) implementation to InstantAPIs project. #31

Closed mkdotcs closed 2 years ago

mkdotcs commented 2 years ago

I moved swagger implementation to InstantAPIs project to reduce the amount of required code in the main project.

Added:

  1. InstantAPIs\InstantAPIsServiceCollectionExtensions.cs: To register and configure Swagger middleware service.
  2. InstantAPIs\InstantAPIsServiceOptions.cs: Holds the InstantAPIs service options. Currently I've added swagger option only, but this can expand to more options in the future.
  3. Swashbuckle.AspNetCore package to InstantAPIs project.

Updated:

  1. InstantAPIs\WebApplicationExtensions.cs: To use Swagger and SwaggerUI.
  2. WorkingAPI\Program.cs: To reflect the new changes

Removed:

  1. Swashbuckle.AspNetCore package from WorkingAPI project.
csharpfritz commented 2 years ago

I like where you've gone with this... and would suggest this starts on #24 There's more to this, such as adding notes and other configuration to swagger for the data types, etc...

Looks like there's a compile issue now, and I would like to see the swagger configuration loaded conditionally if the configuration options do not request it.

Another suggestion: can we inspect the services in the WebApplicationExtension and throw an appropriate error if the AddInstantAPIs method was not executed?