swashbuckle

Has anyone gotten swashbuckle to work with .net core 3 yet?

我的未来我决定 提交于 2019-12-10 15:28:22
问题 I'm trying to generate a swagger doc for my rest API. .net core 3. I've searched other questions on this here and can't seem to find any suggestions that work. The controller is VERY simple, no abstracts, generics, all methods have http attributes, etc. I've tried swashbuckle v4 packages and also the v5 rc2 packages. the v4 packages just cause a runtime exception in .net core on load. the v5 packages always generate a null reference exception in the .json file. The controller is coded and

Swagger - Web API - Optional query parameters

浪子不回头ぞ 提交于 2019-12-10 14:57:00
问题 [HttpGet] [Route("students")] [SwaggerOperation(Tags = new[] { "Student" })] [SwaggerResponse(HttpStatusCode.OK, Type = typeof(ResponseModel<IList<Student>>))] [SwaggerResponseExample(HttpStatusCode.OK, typeof(StudentResponseExample))] [SwaggerResponse(HttpStatusCode.InternalServerError)] public IHttpActionResult SearchStudent() { IDictionary<string, string> searchParams = null; searchParams = ControllerContext.GetQueryStrings(); . . . } The above API has three optional parameters which will

How to define default values for parameters for the Swagger UI?

爷,独闯天下 提交于 2019-12-10 11:18:14
问题 I have Swagger/Swashbuckle integrated into a .NET Core 2.2 API project. Everything works great and what I am asking is purely for convenience. Consider the following API method: public Model SomeEstimate(SomeRequest request) { return Manager.GetSomeEstimate(request); } ... public class SomeRequest { public string StreetAddress { get; set; } public string Zip { get; set; } } When I hit /swagger/index.html and want to try out this API, I always have to enter the StreetAddress and Zip values. Is

How to generate Options(CORS) with Swagger

别说谁变了你拦得住时间么 提交于 2019-12-10 04:22:55
问题 For a project we are working on we are generating an Swagger File automatically. However at this moment we are struggling with the CORS part. We are using the Amazon API gateway import api functionality. To use this in combination with Swagger and CORS, we have to create an additional action (operation) in our source code which allows CORS(options) for each api method (operation)! eg: [HttpOptions] [Route("{id}")] [ProducesResponseType((int)HttpStatusCode.OK)] public IActionResult UserOptions

Remove a route with IOperationFilter in SwashBuckle

☆樱花仙子☆ 提交于 2019-12-10 02:36:57
问题 I am looking for a way to show/hide WebAPI routes in the Swagger documentation using SwashBuckle in a configurable way. Adding [ApiExplorerSettings(IgnoreApi = true)] will indeed hide the routes but I'd need to recompile every time I want that to change. I have looked into creating an IOperationFilter to work with a custom Attribute that I defined. That way I can decorate the routes with a [SwaggerTag("MobileOnly")] and check the web.config or something to see if the route should be shown.

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

帅比萌擦擦* 提交于 2019-12-10 01:00:44
问题 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. 回答1: You can use tags for that. By default Swashbuckle adds a tag

How to add line break to Swashbuckle documentation?

守給你的承諾、 提交于 2019-12-08 15:33:52
问题 I'm generating documentation for an api implemented in Web Api 2 using swagger/swashbuckle. The only xml documentation tags recognized are the <summary> , <remarks> and <param> . This means I cannot use <para> tag to format my text in new lines or paragraphs, everything is generated as a continuous long paragraph in the Implementation Notes entry of the docs. Is there any way to do this? 回答1: Another way to achieve is creating a custom OperationFilter and use the xml documentation tags as

How to configure MultipleApiVersions in Swashbuckle using aspnet ApiVersioning

我的梦境 提交于 2019-12-07 03:46:18
问题 How do I configure swashbuckle to work with Aspnet API verisoning? https://github.com/Microsoft/aspnet-api-versioning In my Startup.cs I have the following code to initialize attribute based routing, api versioning, and swagger. var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof( ApiVersionRouteConstraint ) } }; config.MapHttpAttributeRoutes(constraintResolver); config.AddApiVersioning(); config.EnableSwagger(c => { c.MultipleApiVersions

Swagger default value for parameter

落爺英雄遲暮 提交于 2019-12-07 03:18:17
问题 How do I define default value for property in swagger generated from following API? public class SearchQuery { public string OrderBy { get; set; } [DefaultValue(OrderDirection.Descending)] public OrderDirection OrderDirection { get; set; } = OrderDirection.Descending; } public IActionResult SearchPendingCases(SearchQuery queryInput); Swashbuckle generates OrderDirection as required parameter. I would like to be it optional and indicate to client the default value (not sure if swagger supports

How to define default values for parameters for the Swagger UI?

孤者浪人 提交于 2019-12-06 06:28:50
I have Swagger/Swashbuckle integrated into a .NET Core 2.2 API project. Everything works great and what I am asking is purely for convenience. Consider the following API method: public Model SomeEstimate(SomeRequest request) { return Manager.GetSomeEstimate(request); } ... public class SomeRequest { public string StreetAddress { get; set; } public string Zip { get; set; } } When I hit /swagger/index.html and want to try out this API, I always have to enter the StreetAddress and Zip values. Is there a way to provide default values for StreetAddress and Zip? This answer suggested placing