|
| 1 | +# Simplify.Web.Swagger |
| 2 | + |
| 3 | +[](https://www.nuget.org/packages/Simplify.Web.Swagger/) |
| 4 | +[](https://www.nuget.org/packages/Simplify.Web.Swagger/) |
| 5 | +[](https://github.com/SimplifyNet/Simplify.Web.Swagger/actions/workflows/build.yml)[](https://libraries.io/nuget/Simplify.Web.Swagger) |
| 6 | +[](https://www.codefactor.io/repository/github/simplifynet/Simplify.Web.Swagger) |
| 7 | + |
| 8 | +[](http://makeapullrequest.com) |
| 9 | + |
| 10 | +`Simplify.Web.Swagger` is a package which provides Swagger generation for [Simplify.Web](https://github.com/SimplifyNet/Simplify.Web) web-framework controllers. |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +1. Add `Swashbuckle.AspNetCore.SwaggerGen` and `Swashbuckle.AspNetCore.SwaggerUI` packages to your project |
| 15 | + |
| 16 | +1. Add `AddSimplifyWebSwagger` in `AddSwaggerGen` registration and `Simplify.Web` controllers will be scanned when generation Swagger. |
| 17 | + |
| 18 | +```csharp |
| 19 | +var builder = WebApplication.CreateBuilder(args); |
| 20 | + |
| 21 | +builder.Services.AddEndpointsApiExplorer() |
| 22 | + .AddSwaggerGen(x => x.AddSimplifyWebSwagger()); |
| 23 | +``` |
| 24 | + |
| 25 | +3. Use swagger as in regular ASP.NET Core project |
| 26 | + |
| 27 | +```csharp |
| 28 | +var app = builder.Build(); |
| 29 | + |
| 30 | +app.UseSwagger(); |
| 31 | +app.UseSwaggerUI(); |
| 32 | + |
| 33 | +app.UseSimplifyWebWithoutRegistrations(); |
| 34 | + |
| 35 | +app.Run(); |
| 36 | +``` |
| 37 | + |
| 38 | +4. Add controller Swagger attributes (if needed) |
| 39 | + |
| 40 | +```csharp |
| 41 | +[Get("/api/v1/users/{id:int}")] |
| 42 | +[ApiVersion("1.0")] |
| 43 | +[ProducesResponse(StatusCodes.Status200OK, "application/json")] |
| 44 | +[ProducesResponse(StatusCodes.Status500InternalServerError)] |
| 45 | +public class GetController : Simplify.Web.Controller |
| 46 | +{ |
| 47 | + ... |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +5. After application started go to <http://localhost:5000/swagger/index.html> or <http://localhost:5000/swagger/swagger.json> to see generated Swagger |
| 52 | + |
| 53 | +## Contributing |
| 54 | + |
| 55 | +There are many ways in which you can participate in the project. Like most open-source software projects, contributing code is just one of many outlets where you can help improve. Some of the things that you could help out with are: |
| 56 | + |
| 57 | +- Documentation (both code and features) |
| 58 | +- Bug reports |
| 59 | +- Bug fixes |
| 60 | +- Feature requests |
| 61 | +- Feature implementations |
| 62 | +- Test coverage |
| 63 | +- Code quality |
| 64 | +- Sample applications |
| 65 | + |
| 66 | +## Related Projects |
| 67 | + |
| 68 | +Additional extensions to Simplify.Web live in their own repositories on GitHub. For example: |
| 69 | + |
| 70 | +- [Simplify.Web.Json](https://github.com/SimplifyNet/Simplify.Web.Json) - JSON serialization/deserialization |
| 71 | +- [Simplify.Web.Multipart](https://github.com/SimplifyNet/Simplify.Web.Multipart) - multipart form model binder |
| 72 | +- [Simplify.Web.MessageBox](https://github.com/SimplifyNet/Simplify.Web.MessageBox) - non-interactive server side message box |
| 73 | +- [Simplify.Web.Templates](https://github.com/SimplifyNet/Simplify.Web.Templates) - Visual studio project templates |
| 74 | + |
| 75 | +## License |
| 76 | + |
| 77 | +Licensed under the GNU LESSER GENERAL PUBLIC LICENSE |
0 commit comments