swashbuckle

Swashbuckle rename Data Type in Model

我是研究僧i 提交于 2019-12-06 02:57:37
I'm putting together a web API that needs to match an external sources XML format and was looking to rename the Data Type objects in the swagger output. It's working fine on the members of the class but I was wondering if it was possible to override the class name as well. Example: [DataContract(Name="OVERRIDECLASSNAME")] public class TestItem { [DataMember(Name="OVERRIDETHIS")] public string toOverride {get; set;} } In the generated output I end up seeing Model: TestItem { OVERRIDETHIS (string, optional) } I'd hope to see OVERRIDECLASSNAME { OVERRIDETHIS (string, optional) } Is this possible?

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

回眸只為那壹抹淺笑 提交于 2019-12-06 02:06:16
问题 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); } 回答1: Figured it out... similar to the answer here: Swashbuckle rename Data

Swagger cross out method

两盒软妹~` 提交于 2019-12-05 14:59:18
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? Mik 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 SwaggerConfig class that looks like this: public static class SwaggerConfig { public static void Register

Swashbuckle parameter descriptions

邮差的信 提交于 2019-12-05 12:51:49
问题 I'm using SwaggerResponse attributes to decorate my api controller actions, this all works fine, however when I look at the generated documentation the description field for parameters is empty. Is a there an attribute based approach to describe action parameters (rather than XML comments)? 回答1: With the latest Swashbuckle, or better said at least the Swashbuckle.AspNetCore variant which I'm using, the Description field for parameters can now be displayed correctly as output. It does require

swagger UI is not showing anything in webapi

橙三吉。 提交于 2019-12-05 09:43:57
I followed this up to the xml doc part in order to create Swagger documentation using Swashbuckle. It should allow me to view the endpoints via (in my case): http://localhost:51854/swagger/ui/index Unfortunately, I cannot see any endpoints: Any ideas why and how to fix this? Please note that I created my webapi from an empty webapi project - maybe that's the problem. Something must be missing but I am not sure what ... I have now identified the following code as the root cause. In Global.asax.cs: var container = new XyzWebApiStructureMapContainerConfigurator().Configure(GlobalConfiguration

Swagger UI freezes after API fetch and browser crashes

拜拜、爱过 提交于 2019-12-05 08:24:24
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 before crashing with the "Aw snap" page. There are no errors in the console. Attempting to validate the

Duplicate parameter output in Swagger

萝らか妹 提交于 2019-12-05 08:17:36
Update: I'm starting to wonder if this is due to a bug: https://github.com/domaindrivendev/Swashbuckle/issues/590 But the workaround suggested there does not seem to solve my problem. I am using Swashbuckle to generate API documentation for a C# ASP.NET Web API project. My target is to allow the following as valid URL: /endpoint/items/123/foo?param2=bar With a required parameter (param1) set to "foo" and an optional parameter (param2) set to "bar". I would like both parameters contained inside a single C# parameter object. (with other optional parameters like param3 and so on). Several

Swagger default value for parameter

非 Y 不嫁゛ 提交于 2019-12-05 07:06:22
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 this). I don't like making the property type nullable. Is there any other option? Ideally using built

How to configure MultipleApiVersions in Swashbuckle using aspnet ApiVersioning

眉间皱痕 提交于 2019-12-05 06:09:36
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( (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion), (vc

How to generate Options(CORS) with Swagger

流过昼夜 提交于 2019-12-05 06:02:34
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() { return new OkResult(); } As you can see this makes the code a lot dirtier. this is a temporary fix