swashbuckle

Is there a way change the Controller's name in the swagger-ui page?

混江龙づ霸主 提交于 2019-12-04 23:39:01
I'm using Swashbuckle to enable the use of swagger and swagger-ui in my WebApi project. In the following image you can see two of my controllers shown in the swagger-ui page. These are named as they are in the C# code, however I was wondering if there was a way to change what is shown here? This is mainly because as you can see ManagementDashboardWidget is not a user friendly name, so I want to change it to be user friendly. You can use tags for that. By default Swashbuckle adds a tag with the name of the controller to every operation. You can override that with the SwaggerOperationAttribute .

Swagger (Swashbuckle) hide header

空扰寡人 提交于 2019-12-04 22:44:46
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? 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("#header").style.display = "none"; This post shows how to customize the header putting two text boxes on it.

Enable Oauth2 client credentials flow in Swashbuckle

别说谁变了你拦得住时间么 提交于 2019-12-04 10:44:05
问题 Im using IdentityServer3 to secure a Web API with the client credentials grant. For documentation Im using Swashbuckle but can't figure out how to enable Oauth2 in the SwaggerConfig for the client credentials (application) flow. Any help would be appreciated! 回答1: I was able to get this working. Most of the answer can be found here. There were a few parts I had to change to get the client_credential grant to work. The first part is in the EnableSwagger and EnableSwaggerUi calls: config

Rename model in Swashbuckle 6 (Swagger) with ASP.NET Core Web API

梦想与她 提交于 2019-12-04 06:59:45
I'm using Swashbuckle 6 (Swagger) with ASP.NET Core Web API. My models have DTO as a suffix, e.g., public class TestDTO { public int Code { get; set; } public string Message { get; set; } } How do I rename it to just "Test" in the generated documentation? I've tried adding a DataContract attribute with a name, but that didn't help. [HttpGet] public IActionResult Get() { //... create List<TestDTO> return Ok(list); } ultravelocity Figured it out... similar to the answer here: Swashbuckle rename Data Type in Model The only difference was the property is now called CustomSchemaIds instead of

Integrate swashbuckle swagger with odata in ASP.Net Core [closed]

会有一股神秘感。 提交于 2019-12-03 18:03:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 months ago . I have tried to implement both ( swagger and odata ) in asp.net core, but it's not working. I'm unable to integrate the route given for odata. I have the following Configuration and I receive a generic error. This is the error 回答1: We ran into the same issue when adding OData to our .Net Core project. The

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

六月ゝ 毕业季﹏ 提交于 2019-12-03 13:25:46
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 works, I can send files to the controller using Postman. However, I now want to generate swagger

Enable Oauth2 client credentials flow in Swashbuckle

强颜欢笑 提交于 2019-12-03 05:54:28
Im using IdentityServer3 to secure a Web API with the client credentials grant. For documentation Im using Swashbuckle but can't figure out how to enable Oauth2 in the SwaggerConfig for the client credentials (application) flow. Any help would be appreciated! I was able to get this working. Most of the answer can be found here . There were a few parts I had to change to get the client_credential grant to work. The first part is in the EnableSwagger and EnableSwaggerUi calls: config.EnableSwagger(c => { c.SingleApiVersion("v1", "sample api"); c.OAuth2("oauth2") .Description("client credentials

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

岁酱吖の 提交于 2019-12-03 00:50:40
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 : ConfigureServices in Startup.cs c.AddSecurityDefinition("oauth2", new OAuth2Scheme { Type = "oauth2",

Adding Nested Grouping Sections in the UI for Actions within a Controller

本小妞迷上赌 提交于 2019-12-02 17:26:53
问题 Is it possible to have subsections within an action grouping? We currently use Controller-based differentiation to group functions, but are hosting a large amount of controllers and could use further nesting. In other words, I know actions can be grouped/ordered with the following, but can they be grouped multiple times: c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString()); c.OrderActionGroupsBy(new DescendingAlphabeticComparer()); Thanks for all the help! 回答1: In theory yes, we can

Empty authorization header on requests for Swashbuckle.AspNetCore

女生的网名这么多〃 提交于 2019-12-02 13:29:13
Currently having an issue with authorization headers in swashbuckle for .net core The first line of code on every endpoint is: string auth = Request.Headers["Authorization"]; When using postman, everything works smoothly, but when making a request from localhost/swagger, the header is empty when a breakpoint is inserted, the header is a null value. the body of the request is in tact and everything works properly when the authorization is removed from the endpoint In my services.AddSwaggerGen I add the security definition: services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Version =