swashbuckle

Swagger UI displaying the asp.net webapi parameter name with dot notation

≯℡__Kan透↙ 提交于 2019-12-24 00:59:07
问题 I have configured Swagger for my asp.net webapi which is similar to one shown below [HttpGet] [Route("search")] public async Task<HttpResponseMessage> Get([FromUri]SearchCriteria searchCriteria) When i see the swagger documentation for the webapi , the parameter is displaying as searchCriteria.sortField searchCriteria.sortDirection and so on... being the sortField, sortDirection are properties of SearchCriteria How to get the parameter names without the object.propertyname format? Can anyone

Issue Using Custom Index.Html in Swagger / Swashbuckle for .NET Core

橙三吉。 提交于 2019-12-23 19:48:27
问题 I am having difficulty using a custom index.html and other assets with swashbuckle. Swashbuckle/Swagger do not seem to recognizing or using them at all. I do have app.UseDefaultFiles() and app.UseStaticFiles() set. I am trying to understand what I am doing incorrectly. I have attempted to set up my configuration somewhat similar to what is defined on the Microsoft article without success. (https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual

JWT Authentication and Swagger with .Net core 3.0

狂风中的少年 提交于 2019-12-23 11:59:27
问题 I am developing some Web Api with .Net core 3.0 and want to integrate it with SwashBuckle.Swagger. It is working fine, but when I add JWT authentication, it does not work as I expect. To do that, I added the code below: services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "My Web API", Version = "v1" }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \

Debugging Swashbuckle Error - Failed to load API Definition

北城余情 提交于 2019-12-23 09:22:15
问题 Is there any way to get a stack trace or inner exceptions on Swashbuckle/Swagger errors? At some point, it stopped working. I'm not sure if it was when I upgraded from .Net Core 2.0 to 2.1, but I'm pretty sure it was still working after that. When I navigate to myapidomain/swagger/index.html I get this error: Which is not very helpful. It was working 2 or so weeks ago... I didn't change any Swagger configuration. It's the same as it's always been: public void ConfigureServices

How to use a custom model binder with Swashbuckle, Swagger and NSwag?

僤鯓⒐⒋嵵緔 提交于 2019-12-23 08:46:55
问题 I have an ASP.NET Core Web API that contains the following endpoint. [HttpGet] [Route("models/{ids}")] [Produces(typeof(IEnumerable<Model>))] public IActionResult Get ( [ModelBinder(typeof(CsvModelBinder<string>))] IEnumerable<string> ids ) { // Get models return Ok(models); } This endpoint takes a CSV list of Ids (e.g. /models/a,b,c ) and returns a JSON array of the corresponding Model objects. CsvModelBinder<string> is a custom implementation of IModelBinder I wrote that splits the CSV list

API key in header with swashbuckle

家住魔仙堡 提交于 2019-12-23 07:37:09
问题 I want to do API key based authentication on a WebAPI project with Swashbuckle (swagger for .net). I have configured swashbuckle as below: config .EnableSwagger(c => { c.ApiKey("apiKey") .Description("API Key Authentication") .Name("X-ApiKey") .In("header"); c.SingleApiVersion("v1", "My API"); }) .EnableSwaggerUi(); (see https://github.com/domaindrivendev/Swashbuckle#describing-securityauthorization-schemes) It appears to create the swagger file I expect: "securityDefinitions": { "apiKey": {

ASP.NET Core Swagger uses incorrect json url when web application is hosted in a subdirectory

落爺英雄遲暮 提交于 2019-12-23 01:11:25
问题 I followed these instructions to add swagger to my ASP.NET Core application. It works fine when I host it as a root website but when I host the app as an alias on an existing website, say myserver.com/myapp , swagger will look for swagger.json at an incorrect URL and report: *Can't read swagger JSON from https://myserver.com/swagger/v1/swagger.json . It should instead use https://myserver.com/myapp/swagger/v1/swagger.json . The message I get is: Can't read swagger JSON from https://myserver

ASP.NET Core Swagger uses incorrect json url when web application is hosted in a subdirectory

别说谁变了你拦得住时间么 提交于 2019-12-23 01:11:11
问题 I followed these instructions to add swagger to my ASP.NET Core application. It works fine when I host it as a root website but when I host the app as an alias on an existing website, say myserver.com/myapp , swagger will look for swagger.json at an incorrect URL and report: *Can't read swagger JSON from https://myserver.com/swagger/v1/swagger.json . It should instead use https://myserver.com/myapp/swagger/v1/swagger.json . The message I get is: Can't read swagger JSON from https://myserver

SwaggerUI not displaying Model Schema

喜欢而已 提交于 2019-12-22 18:01:42
问题 I have a C# Web.API project with Swagger and Swashbuckle. I have a model: public class TimeZoneName { public string zoneName { get; } } I have a controller with methods: public string GetLocalTimeByTimeZone(TimeZoneName timezone) { //Stuff Happens here return "12:00"; } During a build I was expecting Swashbuckle to generate a SwaggerUI that shows a JSON representation of the TimeZoneName type in the UI. That didn't occur. How do I set up my methods and models so that the Model Schema is shown

Swashbuckle rename Data Type in Model

佐手、 提交于 2019-12-22 11:12:48
问题 I'm putting together a web API that needs to match an external sources XML format and was looking to rename the Data Type objects in the swagger output. It's working fine on the members of the class but I was wondering if it was possible to override the class name as well. Example: [DataContract(Name="OVERRIDECLASSNAME")] public class TestItem { [DataMember(Name="OVERRIDETHIS")] public string toOverride {get; set;} } In the generated output I end up seeing Model: TestItem { OVERRIDETHIS