swashbuckle

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

我的未来我决定 提交于 2019-12-18 19:42:33
问题 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=

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

妖精的绣舞 提交于 2019-12-18 19:41:29
问题 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=

How to replace Swagger UI header logo in Swashbuckle

我的梦境 提交于 2019-12-18 13:16:09
问题 I am using the Swashbuckle package for WebAPI and am attempting to customize the look and feel of the swagger ui default page. I would like to customize the default swagger logo/header. I have added the following to SwaggerConfig .EnableSwaggerUi(c => { c.InjectJavaScript(thisAssembly, typeof(SwaggerConfig).Namespace + ".SwaggerExtensions.custom-js.js"); } The contents of custom-js.js are as follows: $("#logo").replaceWith("<span id=\"test\">test</span>"); This works for the most part but the

Route application root to /swagger

一曲冷凌霜 提交于 2019-12-18 08:55:43
问题 What is the correct way to redirect request from www.mysite.com to www.mysite.com/swagger? I setup an index controller Decorated with Route("") and it works but seems like a Kludge. I assume there should be a way to specify it in the MVC routing in Startup.cs, I just can't figure it out. // kludge code, how do I do this in app.UseMvc(route => route.MapRoute... [ApiExplorerSettings(IgnoreApi = true)] [Route("")] public class IndexController : Controller { public ActionResult Index() { return

Replace Swashbuckle UI completely

爷,独闯天下 提交于 2019-12-18 02:48:30
问题 Right now I'm developing an ASP.Net Web API and using Swashbuckle for its documentation. I know that Swashbuckle use Swagger-UI internally, I know that we can modify the layout by injecting our css or javascript file, even change the layout of index.html. I found a good themes for Swagger-UI https://github.com/jensoleg/swagger-ui and trying to implement it but can't make it works. Especially when I want to inject bootstrap.js. Is there anyway I can completely change Swashbuckle Swagger UI

Migrating to Swashbuckle.AspNetCore version 5

☆樱花仙子☆ 提交于 2019-12-18 01:42: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

Swashbuckle Swagger - How to annotate content types?

风格不统一 提交于 2019-12-17 19:27:15
问题 How do I annotate my ASP.NET WebAPI actions so that the swagger metadata includes the content-types that my resources support? Specifically, I want the documentation to show that one of my resources can return the 'original' application/json and application/xml but also now returns a new format, application/vnd.blah+json or +xml . 回答1: What you need to do is this; Swagger spec: you need to add your response-type to the list of response-types for that operation "produces": [ "application/json"

Swagger/Swashbuckle list acceptable values?

喜欢而已 提交于 2019-12-14 04:18:43
问题 I have implemented Swashbuckle/Swagger on my Web API application successfully, but am not happy with the output. One of my web api methods (An enterprise event logging tool) accepts a JSON object of a Complex object value. The issue is that the parameters are listed as string objects when there is a selected list of acceptable values that can be used. I have set default values so that if something incorrect is sent, I set to default. I guess I could add other service calls that return the

Call Swagger generator for plugins

寵の児 提交于 2019-12-13 04:15:36
问题 i want to generate the swagger document for plugins. I point the endpoint for the api to a plugincontroller. In this i have a method to create the documentation for a particular version. While loading the plugin all items are already registered in the swagger tooling. (somehow the new documents don't get picked up by the swagger middleware that is why i need this workaround.) [HttpGet("api/plugins/swaggerdoc/{version}")] public IActionResult GetSwaggerDoc(string version) { SwaggerDocument gen

How to define default values for [FromQuery] parameters for the Swagger UI?

≯℡__Kan透↙ 提交于 2019-12-13 03:36:59
问题 I have an action: [HttpGet] [Route("foo")] public ActionResult Foo([FromQuery] MyClass request) { var image = ToImage(WidgetType.MedianSalesPriceSqft, request); return File(image.ToByteArray(), "image/png"); } below MyClass is defined: public class MyClass { [DefaultValue("90210")] public string Zip { get; set; } [DefaultValue("5361 Doverton Dr")] public string StreetAddress { get; set; } } When I hit /swagger/index.html and want to try out this API, I always have to enter the StreetAddress