swashbuckle

How to force Swagger/Swashbuckle to append an API key?

╄→гoц情女王★ 提交于 2019-12-12 16:08:02
问题 I have a .NET Core 2.x project which integrates Swagger and Swashbuckle v4.x. And it all works really well. However, now I need to append a query string to every GET that is fired by Swagger in the form of www.foo.com/myendpoint? authorization=APIKEY . To that end, I have the following in Startup.ConfigureServices: services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); c.AddSecurityDefinition("api key", new ApiKeyScheme() { Description =

Show Name from [Route] in swagger documentation using swashbuckle

对着背影说爱祢 提交于 2019-12-12 15:41:59
问题 In the asp .net controller when defining an action, we can provide a name to the route as part of the [Route] attribute. In the below example, I've given the name as 'DeleteOrder'. How do I get to showing the name in the generated swagger documentation? Thanks. [HttpDelete] [Route("order/{orderId}", Name ="DeleteOrder")] [ProducesResponseType(typeof(void), 204)] [ProducesResponseType(typeof(void), 400)] public async Task<IActionResult> Delete(string orderId) 回答1: By default, Swagger UI will

Add endpoints manually with Swashbuckle.Swagger

心已入冬 提交于 2019-12-12 12:25:49
问题 I'm using a CMS. So when I go to i.e. '/painter' its routed to the 'JobController'. /plumber is also routed to 'JobController'. Besides that it's MVC and not WebAPI, so swagger doesn't discover it, which is understandable and fine. But I've a usecase, where if I access /pianter?json=1 it returnes json instead of HTML. So as an API UI we would like to expose this 'fake' endpoint, just so the designers can see the output model. So can I add an entirely fake endpoint - just to have a single

Does Swashbuckle.AspNetCore support documentation when route has parameter?

你离开我真会死。 提交于 2019-12-12 03:48:52
问题 I follow the instructions by https://github.com/domaindrivendev/Swashbuckle.AspNetCore create a new asp.net core web api project add nugget package Swashbuckle.AspNetCore Add code for swagger services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Version = "v1", Title = "API (version 1.0)", Description = "A RESTFUL API" }); options.IncludeXmlComments(xmlDocPath); }); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API"); }); Add code

Describe an array of complex objects using Swagger 2.0

青春壹個敷衍的年華 提交于 2019-12-12 02:25:54
问题 I have a Web Api 2 project that has an HttpGet method that takes a list of complex objects as the parameter. Like this: [HttpGet] public string GetCoolStuff(List<ContainerContract> containers) I am using swashbuckle to setup my swagger docs. But it sets this parameter up like this: { "name" : "containerContracts", "in" : "query", "required" : true, "type" : "array", "items" : {}, "collectionFormat" : "multi" } At the very least the items object seems like it needs something in it. Later down

How to generate multiple pages from Swashbuckle.AspNet?

穿精又带淫゛_ 提交于 2019-12-11 23:24:18
问题 I've been following this guide to create developer friendly documentation for my ASP.Net REST WebApi using Swashbuckle. However, the current version Swashbuckle.AspNetCore v2.2.0 generates a huge single page app, which is confusing for my users. If I remember correctly, Swashbuckle was generating separate pages for each controller/method (early 2017?). My configuration looks like this: app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1"); c.EnableFilter(); c

swashbuckle mediatype application/octetstream

我怕爱的太早我们不能终老 提交于 2019-12-11 17:05:57
问题 I have an endpoint that produces mediatype as application/octet-stream. However, when I generated the swagger json, it specifies "produces" as "application/json" I did not do any special configs in swagger. All I did was import swagger nuget and just kept the default configuration as is. Please find below the endpoint: [HttpPost] [Route("document/method1")] public HttpResponseMessage method1([FromBody]SomeModel SomeModelValue) { // code that generates the file if (File.Exists(outputFilePath))

Swashuckle SwaggerDocument object retrieval

不羁的心 提交于 2019-12-11 15:08:15
问题 I've integrated ASP .NET Core HealthChecks in my solution and I'm already using Swashbuckle swagger. I thought it would be a nice idea to add the HealthCheck endpoints to the swagger. I found this solution in the StackOverflow (Integrating HealthCheck endpoint into swagger (open API) UI on dotnet core), but I can't understand how I chould be using this method. I've tried to find SwaggerDocument in the startup file, but I didn't manage to do that. It would be nice, if somebody, who knows how

BadHttpRequestException caused by slow clients are showing up in my application insights

做~自己de王妃 提交于 2019-12-11 11:29:19
问题 One caller of my API sometimes has some performance issues where they max out at 100% CPU on their end and my API is rejecting some of their calls due to request timeouts (HTTP 408). This is fine for me as I consider it protection to reject the calls. However, it also triggers alerts in Application Insights because the timeout is being tracked as an exception. The requests are POSTs. What can I do to prevent this? I looked into filtering configuration for Application Insights, but I was

Is it possible to hide an Enum member in Swashbuckle.AspNetCore?

扶醉桌前 提交于 2019-12-11 11:28:10
问题 I have an enum such as public enum SampleFormats { unknown = 0, audio = 1, video = 2, } Is it possible to decorate the unknown member in a way that it is excluded by the generated swagger json? I could possibly write a schema/document filter, but was wondering if there was something out of the box. 回答1: You can try this: public enum SampleFormats { unknown = 0, audio = 1, video = 2, } public class ResultModel { public SampleFormats Format { get; set; } [JsonIgnore] public bool FormatSpecified