swashbuckle

Swagger cross out method

旧街凉风 提交于 2019-12-22 08:24:33
问题 I am using Swaschbuckle for my .NET Swagger Web API Service. I have looked at the sample from http://petstore.swagger.io/#/pet and there ist the Action findByTags which is crossed out. I want to cross out an action in my api service, but when i am using the obsolete attribute the action isn't visible. Any idea how to handle this issue? 回答1: I had the same problem with my WebApi project, but after updating Swashbuckle.Core nuget package to version 5.6.0 it started to work. I have a

Swagger UI freezes after API fetch and browser crashes

僤鯓⒐⒋嵵緔 提交于 2019-12-22 06:31:32
问题 I have an ASP.NET WebAPI project where I am attempting to replace our old XmlDocumentationProvider page with Swagger UI. I am using the swashbuckle swagger for webAPI 5.3.1 nuget package. I am able to navigate to localhost/MyApp/swagger, and I can see in fiddler that it makes a call to localhost/MyApp/swagger/docs/v1 to retrieve the JSON string representing my API. The call succeeds, the JSON is about 240KB, and the JSON is valid. At this point, the chrome tab freezes for about 30 seconds

http basic auth with swashbuckle api documentation

让人想犯罪 __ 提交于 2019-12-22 05:29:08
问题 could anyone know how could i integrate basic auth with swashbuckle api's documentation? I saw that there's a basicAuth function in the swaggerconfig file: c.BasicAuth("basic").Description("Basic HTTP Authentication"); What i've done: uncommented the previous line but nothing changed! does anyone have any idea what did i miss? Thanks! 回答1: A minor improvement on @MarwaAhmad 's most excellent answer, is to check for null parameters (e.g. a simple GET or call with all params in the URL) . Also

Swagger (Swashbuckle) hide header

落花浮王杯 提交于 2019-12-22 01:28:18
问题 I use Swashbuckle to add Swagger documentation to my ASP.NET Web API project. How can I hide default header (with swagger logo) from documentation page without injecting CSS? 回答1: Unfortunately I think you can do it olny by javascript right now. In your SwaggerConfig.cs you can inject a .js file like this: .EnableSwaggerUi(c => { c.InjectJavaScript(thisAssembly, "yournamespace.yourscript.js"); }); So in this script you can do whatever you want, like hide the header: document.querySelector("

How can I tell Swashbuckle that the body content is required?

徘徊边缘 提交于 2019-12-21 04:29:13
问题 I have a WebAPI controller that accepts binary packages and stores them somewhere. As these packages can become quite large, I don't want to load them into memory by adding a byte array parameter but rather pass along a stream. I found a way to do that in this answer: [HttpPost] [Route("Store/{projectId}")] public async Task Store(string projectId) { using (var stream = await this.Request.Content.ReadAsStreamAsync()) { await this.packageManager.StorePackageAsync(projectId, stream); } } This

Using Swashbuckle for Asp.net core how can I add a model to the generated model list?

天涯浪子 提交于 2019-12-21 01:15:00
问题 I'm using Swashbuckle with ASP.net core. It is producing a nice website with a list of models at the bottom. How can I add a model to this list that isn't already appearing? I return an abstract class in one of my requests and I want to list all the variations that inherit that abstract class. Thanks in advance 回答1: You could create an document filter and register it globally. public class CustomModelDocumentFilter<T> : IDocumentFilter where T : class { public void Apply(SwaggerDocument

How to send Authorization header with a request in Swagger UI?

别来无恙 提交于 2019-12-20 17:32:37
问题 I have a ASP.NET Web Api 2 application. I added Swashbuckle to it (Swagger for .NET). It displays my endpoints no problem, but in order to send a request I need to attach an Authorization header to that request. If I understand correctly in order to do that I need to modify the index.html file (https://github.com/swagger-api/swagger-ui#how-to-use-it) so I git cloned Swashbuckle project in order to modify index.html and add some headers. Is that the only way to send Authorization header with

Swashbuckle.AspNetCore v1.0.0 with OAuth2, flow : application -> IdentityServer4

喜夏-厌秋 提交于 2019-12-20 10:57:47
问题 I can't seem to make my .net core web API work with swashbuckle, OAuth2 with an application flow. When I click the Authorize button, Fiddler shows that the call is OK and my local IdentityServer(4) replies with an access_token. That's all great and all but I don't think Swagger picks this up, there's nothing happening and I can't trigger my controller methods without getting a 401. I see no cookies, nothing. I'm sure I'm missing something super trivial. Can someone help me out? Relevant code

Swashbuckle + XmlComments work locally, but fail swagger generation on server

无人久伴 提交于 2019-12-20 04:24:21
问题 I have a webapi project, and I am utilizing the swashbuckle framework to flush out api documentation. I have followed the directions to build the documentation xml file with my controller and DTO's, and it all works great locally. However, when generating the swagger document, a 500 error is thrown. I have confirmed if i remove my xml registration line, the swagger doc is generated and returned successfully. here is my registration line: GlobalConfiguration.Configuration.EnableSwagger(c => {

cannot convert from 'Microsoft.OpenApi.Models.OpenApiInfo' to 'Swashbuckle.AspNetCore.Swagger.Info'

淺唱寂寞╮ 提交于 2019-12-19 17:45:52
问题 I'm getting this error when tryign to run swashbuckle. Any ideas? I have this in my ConfigureServices Class services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "testing", Version = "v1" }); }); And this in my Configure Class app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); 回答1: I ran into this same issue today. After looking at the Microsoft documentation, it appears that SwaggerDoc is looking for a string and an