swashbuckle

How to secure generated API documentation using swagger swashbuckle

眉间皱痕 提交于 2019-12-01 00:27:08
问题 I have implemented API documentation using swagger swashbukle. Now I want to publish generated documentation as a help file in my website. How to secure this link and publish? 回答1: I don't think there's a way to secure the swagger swashbuckle endpoint up until now. You can have tips and more into this from their github issue here 回答2: This solution will only work if you have implemented authentication in your solution. Create new folder swagger in solution Add new Web.config file. write

ASP.NET Core - Swashbuckle not creating swagger.json file

淺唱寂寞╮ 提交于 2019-11-30 21:24:10
问题 I am having trouble getting the Swashbuckle.AspNetCore (1.0.0) package to generate any output. I read the swagger.json file should be written to '~/swagger/docs/v1'. However, I am not getting any output. I started with a brand new ASP.NET Core API project. I should mention this is ASP.NET Core 2. The API works, and I am able to retrieve values from the values controller just fine. My startup class has the configuration exactly as described in this article (Swashbuckle.AspNetCore on GitHub).

k__BackingField remove in C# (seen via Swashbuckle / Swagger)

瘦欲@ 提交于 2019-11-30 18:13:36
I am using Swashbuckle 5 in my ASP.NET webapi project with all default settings. It serializes my method's output in order to show me schema of the reply. I am getting documentation that looks like this: Response Class (Status 200) Model Model Schema [ { "<Key>k__BackingField": "string", "<Value>k__BackingField": "string", "<Id>k__BackingField": 0 } ] This is generated by following C# code /// <summary> /// Fetches all system configuration items /// </summary> /// <returns>List of <see cref="SystemConfigurationDto" /> items</returns> public IList<SystemConfigurationDto>

Leverage MultipleApiVersions in Swagger with attribute versioning

拟墨画扇 提交于 2019-11-30 16:55:21
问题 Is it possible to leverage MultipleApiVersions in Swagger UI / Swashbuckle when using attribute routing? Specifically, I implemented versioning by: using System.Web.Http; namespace RESTServices.Controllers.v1 { [Route("api/v1/Test")] public class TestV1Controller : ApiController { ... } Version 2 would be in a v2 namespace. In a controller named TestV2Controller. The route would have v2 in it. Is it possible to pass a lambda in that will allow this? I found a sample lambda online which

Swashbuckle 5 can't find my ApiControllers

我们两清 提交于 2019-11-30 16:24:51
问题 I'm at a point where I really need API documentation for my WebAPI 2 project, and I used the Swashbuckle 5 NuGet package. Out of the box, I can hit {myrooturl}/swagger and a UI pops up, but there are no controllers, methods, or anything in there. Just my title: [ base url: /EM.Services , api version: v1 ] I took a look at the Swashbuckle docs, and since I'm using OWIN which is hosted by IIS, I modified the SwaggerConfig with: c.RootUrl(req => req.RequestUri.GetLeftPart(UriPartial.Authority) +

Authorization for JWT bearer in Swashbuckle .NET Core 2

吃可爱长大的小学妹 提交于 2019-11-30 15:14:10
问题 I use tokens generated by an authentication service for my app. No problems there. Now I have introduced Swashbuckle to document my API an I can authenticate as follows by sending the JWT with every request using this code; services.AddSwaggerGen(c => { var a = new ApiKeyScheme(); //c.AddSecurityDefinition("Bearer", new ApiKeyScheme() //{ In = "header", Description = "Please insert JWT with Bearer into field", Name = "Authorization", Type = "apiKey" }); c.OperationFilter

How to set base path property in swagger for .Net Core Web API

纵饮孤独 提交于 2019-11-30 15:11:22
问题 i've built a Web API in ASP.Net Core (version 1.1.2) and i use the Swashbuckle.AspNetCore for generating the swagger definition. below is a part of the automatically generated swagger definition. i would like to change the paths so it does not include /api/ApiName but it would be included in the basePath which is now / { "swagger": "2.0", "info": { "version": "v1", "title": "ApiName.V1" }, "host": "ApiUrl", "basePath": "/api/ApiName", "paths": { "/": { "get": { "tags": [ "ApiName" ], ........

Migrating to Swashbuckle.AspNetCore version 5

断了今生、忘了曾经 提交于 2019-11-30 14:08:34
I'm trying to migrate from version 4.0.1 to 5.0.0-rc2 of Swashbuckle in a .NET Core 3 Preview 5 Web API project. I've got the project compiling and the Swagger UI working, but I can't get Bearer authentication to work, which I think is due to me not setting up the new format security correctly. This is my old code that worked in version 4: c.AddSecurityDefinition("Bearer", new ApiKeyScheme { Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"", Name = "Authorization"

Swagger not working correctly with multiple versions of ASP.NET WebApi app

烂漫一生 提交于 2019-11-30 13:31:26
Please help me with this, it looked easy at first, now I'm late in the project: I'm trying to setup API versioning for a ASP.NET WebApi project, along with Swagger. The API versioning works fine, calling different versions returns the correct results (see below). On the contrary, Swagger fails to serve both versions. While debugging, I noticed that when c.MultipleApiVersions(...) gets called in SwaggerConfig.cs, the controller reported by apiDesc.ActionDescriptor.ControllerDescriptor is always PingController and never Ping11Controller . Can somebody point out what needs to be done to solve

500 Error when setting up Swagger in asp .net CORE / MVC 6 app

给你一囗甜甜゛ 提交于 2019-11-30 10:42:04
I'm trying to setup a basic swagger API doc in a new asp .net CORE / MVC 6 project and receiving a 500 error from the swagger UI: 500 : http://localhost:4405/swagger/v1/swagger.json My startup class has the following code in it: using Swashbuckle.SwaggerGen; using Swashbuckle.SwaggerGen.XmlComments; using Swashbuckle.Application; .... public void ConfigureServices(IServiceCollection services) { ... services.AddSwaggerGen(); services.ConfigureSwaggerDocument(options => { options.SingleApiVersion(new Info { Version = "v1", Title = "Blog Test Api", Description = "A test API for this blogpost" });