swashbuckle

Show only selected controllers in swagger-swashbuckle UI

岁酱吖の 提交于 2020-07-18 08:51:12
问题 I am currently using swagger in my project and i have more than 100 controllers there. I guess due to the large number of controller, swagger UI documentation page takes more than 5 min to load its controller. Is it possible to select specific controllers at the UI page and load options for them only? Or else there are other methods to load UI page faster? Help me! 回答1: you can use ApiExplorerSettings on either controller to ignore a controller completely or on a method. [ApiExplorerSettings

Using Swashbuckle 5.x specify nullable = true on a Generic T Parameter reference property

有些话、适合烂在心里 提交于 2020-06-28 06:09:07
问题 I recently upgraded my API to a .net core 3.1 server using Swashbuckle 5 with the newtonsoft json nuget, which produces an openapi 3 schema. I then use NSwag to generate a C# API. Previously I had a .net core 2.2 server with swashbuckle 4, producing a swagger 2.0 api schema. I have a generic response class for all responses, containing some metadata about the response like status code and a message, plus a Payload property of Generic type T containing the meat of the response. When the

Swashbuckle - swagger documentation of returned response?

空扰寡人 提交于 2020-06-13 20:04:00
问题 Swashbuckle would not generate swagger.json with an output of "UserCreateResponse", how do you fix this? [HttpPost] public async Task<IActionResult> Update([FromBody]UserCreate Request) { UserCreateResponse response = new UserCreateResponse(); //do something here // returns UserCreateResponse with http status code 200 return Ok(response); } You can't do this, because its not going to return the http status code, 200,400,401 etc [HttpPost] public async Task<UserCreateResponse> Update([FromBody

Swashbuckle - swagger documentation of returned response?

时光毁灭记忆、已成空白 提交于 2020-06-13 20:03:13
问题 Swashbuckle would not generate swagger.json with an output of "UserCreateResponse", how do you fix this? [HttpPost] public async Task<IActionResult> Update([FromBody]UserCreate Request) { UserCreateResponse response = new UserCreateResponse(); //do something here // returns UserCreateResponse with http status code 200 return Ok(response); } You can't do this, because its not going to return the http status code, 200,400,401 etc [HttpPost] public async Task<UserCreateResponse> Update([FromBody

How to set up Swashbuckle vs Microsoft.AspNetCore.Mvc.Versioning

丶灬走出姿态 提交于 2020-06-09 09:28:26
问题 We have asp.net core webapi. We added Microsoft.AspNetCore.Mvc.Versioning and Swashbuckle to have swagger UI. We specified controllers as this: [ApiVersion("1.0")] [Route("api/v{version:apiVersion}/[controller]")] public class ContactController : Controller { When we run swagger ui we get version as parameter in routes: How to set-up default "v1" for route ? If version 2 come to the stage how support swagger ui for both versions ? 回答1: At the moment Swashbuckle and Microsoft.AspNetCore.Mvc

How to set up Swashbuckle vs Microsoft.AspNetCore.Mvc.Versioning

﹥>﹥吖頭↗ 提交于 2020-06-09 09:28:22
问题 We have asp.net core webapi. We added Microsoft.AspNetCore.Mvc.Versioning and Swashbuckle to have swagger UI. We specified controllers as this: [ApiVersion("1.0")] [Route("api/v{version:apiVersion}/[controller]")] public class ContactController : Controller { When we run swagger ui we get version as parameter in routes: How to set-up default "v1" for route ? If version 2 come to the stage how support swagger ui for both versions ? 回答1: At the moment Swashbuckle and Microsoft.AspNetCore.Mvc

How to set up Swashbuckle vs Microsoft.AspNetCore.Mvc.Versioning

二次信任 提交于 2020-06-09 09:27:14
问题 We have asp.net core webapi. We added Microsoft.AspNetCore.Mvc.Versioning and Swashbuckle to have swagger UI. We specified controllers as this: [ApiVersion("1.0")] [Route("api/v{version:apiVersion}/[controller]")] public class ContactController : Controller { When we run swagger ui we get version as parameter in routes: How to set-up default "v1" for route ? If version 2 come to the stage how support swagger ui for both versions ? 回答1: At the moment Swashbuckle and Microsoft.AspNetCore.Mvc

Secure swagger docs page with username and password Asp Net Core 2.1

谁都会走 提交于 2020-05-26 04:17:19
问题 I am using Asp.Net Core 2.1 Web Api with Swashbuckle.aspnetcore.swagger I want to secure api documentation page with username and password before granting access. Sample documention page To make sure its not accessible by the public 回答1: Copied from mguinness's answer on Github: In .NET Core you use middleware, instead of a DelegatingHandler: public class SwaggerAuthorizedMiddleware { private readonly RequestDelegate _next; public SwaggerAuthorizedMiddleware(RequestDelegate next) { _next =

swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B

馋奶兔 提交于 2020-05-09 20:02:10
问题 Using Web API and using swashbuckle to generate swagger documentation, I defined two different classes with the same name in two different namespaces. when I open swagger page in my browser it says Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround full message: 500 : {"Message":"An error has occurred.","ExceptionMessage":"Conflicting schemaIds: Duplicate schemaIds detected for types A and B.

Autorest Failed resolving swagger.json against file when swagger.json is served by localhost

冷暖自知 提交于 2020-05-07 08:16:24
问题 I am able to use Autorest_core 3 to generate the client when swagger.json is hosted on a website but not when it is hosted on localhost. However if I cut and paste the swagger.json from local host into a file then I can generate the client. In startup.ConfigureServices I have services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); c.CustomOperationIds( d => (d.ActionDescriptor as ControllerActionDescriptor)?.ActionName); And in Startup.Configure