GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SimplifyNet/Simplify.Web.Swagger: Swagger generation for Simplify.Web web-framework controllers

BranchesTags
Open more actions menu

Latest commit

 

History

134 Commits
134 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
images
images
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 

Repository files navigation

Simplify.Web.Swagger

Nuget Version Nuget Download Build Package Libraries.io dependency status for latest release CodeFactor Grade Platform

Simplify.Web.Swagger is a package which provides Swagger generation for Simplify.Web web-framework controllers.

Quick Start

  1. Add Simplify.Web.Swagger, Swashbuckle.AspNetCore.SwaggerGen and Swashbuckle.AspNetCore.SwaggerUI packages to your project
<PackageReference Include="Simplify.Web.Swagger" Version="1.0.*" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.2.*" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.2.*" />
  1. Add AddSimplifyWebSwagger in AddSwaggerGen registration and Simplify.Web controllers will be scanned during Swagger generation process.
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer()
 .AddSwaggerGen(x => x.AddSimplifyWebSwagger());
  1. Use Swagger as in regular ASP.NET Core project
var app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();

app.UseSimplifyWeb();

await app.RunAsync();
  1. Add controller Swagger attributes (if needed)
[Get("/api/v1/users/{id}")]
[ApiVersion("1.0")]
[ProducesResponse(StatusCodes.Status200OK, "application/json")]
[ProducesResponse(StatusCodes.Status500InternalServerError)]
public class GetController : Controller2
{
 ...
}
  1. After application started go to http://localhost:5000/swagger/index.html or http://localhost:5000/swagger/v1/swagger.json to see generated Swagger

Configuration

Bearer security scheme

When your controllers use authorization ([Authorize]), Simplify.Web.Swagger automatically adds security requirements to the corresponding operations using all security schemes registered via AddSecurityDefinition — no extra configuration needed:

x.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { ... });
x.AddSimplifyWebSwagger(); // Bearer requirement is added automatically

To restrict to a specific scheme name (e.g. when you have multiple definitions but want only one applied), set SecuritySchemeName explicitly:

x.AddSimplifyWebSwagger(new SimplifyWebSwaggerArgs
{
	SecuritySchemeName = "Bearer"
});

JSON property casing

By default, Swagger schema property names follow the System.Text.Json default casing (PascalCase). To use camelCase (matching JsonSerializerDefaults.Web), register a custom ISerializerDataContractResolver:

builder.Services
	.AddSingleton<ISerializerDataContractResolver>(_ =>
		new JsonSerializerDataContractResolver(
			new JsonSerializerOptions(JsonSerializerDefaults.Web)
		))
	.AddEndpointsApiExplorer()
	.AddSwaggerGen(x => x.AddSimplifyWebSwagger());

Example application

Below is the example of Swagger generated by Simplify.Web.Swagger:

Simplify

Contributing

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:

  • Documentation (both code and features)
  • Bug reports
  • Bug fixes
  • Feature requests
  • Feature implementations
  • Test coverage
  • Code quality
  • Sample applications

Related Projects

Additional extensions to Simplify.Web live in their own repositories on GitHub. For example:

  • Simplify.Web.Json - JSON serialization/deserialization
  • Simplify.Web.Postman - Postman collection and environment generation
  • Simplify.Web.Multipart - multipart form model binder
  • Simplify.Web.MessageBox - non-interactive server side message box
  • Simplify.Web.Templates - .NET projects templates

License

Licensed under the GNU Lesser General Public License

About

Swagger generation for Simplify.Web web-framework controllers

Topics

c-sharpc-sharp-librarydotnet-coredotnetcoresimplifysimplify-webswagger

Resources

Readme
LGPL-3.0 license
Activity
Custom properties

Stars

1 star

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.