Swagger
- How to set up Swashbuckle vs Microsoft.AspNetCore.Mvc.Versioning
- SwaggerUI authorization
- Adding Basic Authorization for Swagger-UI 2017-03-18
- Customize Authentication Header in SwaggerUI using Swashbuckle June 2015
- HitBTC API 2.1.0
- Adding Basic Authorization for Swagger-UI jul 15
- Adding a Authorization field to the Swagger UI jan 16
- Web API with OAUTH using Swagger / Swashbuckle
- Swagger and ASP.NET Web API - Part II: Enabling OAuth 2.0
- Swagger UI - Adding multiple custom header parameters
- Generating Swagger example requests & responses with Swashbuckle
- ASP.NET Web API Help Pages using Swagger
- Add JWT Bearer Authorization to Swagger and ASP.NET Core Oct17
AddFileParamTypes
operation filter for file upload- Modify Swagger with Request Context
- Annotations enrich operation, response and parameter metadata
- Extend Generator with Operation, Schema & Document Filters
- Custom operation filters: AssignOperationVendor, RemoveVersionParameters, FormDataOperationFilter
- Custom UI website project
Recipes
- packages
<PackageReference Include="Swashbuckle" Version="5.5.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
- configure swagger middleware
ConfigureServices
permalink, bearer authorization ConfigureSwaggerGen.Bearer.csConfigure
link- operation filter SwaggerApiOperationIdFilter.cs
- header parameter
- test swagger definitions
public class SwaggerTests
{
private const string TargetUrl = "/swagger/v1.0/swagger.json";
[Fact, IsWarmUp]
public async Task VerifySwaggerEndpoint()
{
string swaggerResult;
using (var client = new System.Net.WebClient())
{
swaggerResult = await client.DownloadStringTaskAsync($"{Settings.Instance.SiteURL}{TargetUrl}");
}
swaggerResult.Should().NotBeNull();
var obj = JsonConvert.DeserializeObject<JObject>(swaggerResult);
var paths = obj["paths"];
Assert.True(paths.Children().Count() > 1);
}
}
- better name generation UI
- Instead of
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(void))]
use[SwaggerResponse(StatusCodes.Status401Unauthorized, null, "Unauthorized")]
. - Instead of
[Action("name")]
useSwaggerOperation("Ping", Schemes = new[] { "http" })]
.
- Instead of