swashbuckle

Add Swagger UI to a custom .NET Web API

混江龙づ霸主 提交于 2019-12-11 08:59:14
问题 I want to integrate Swagger UI into my C# .Net Web API project. This is different from a traditional Web API project where you can install a tool like SwashBuckle, which then picks up the HTTP routes defined in your controller classes and creates the UI. What I have is a custom implementation which generates the OpenAPI/Swagger 3.0 yaml files for different routes. I have a route defined in a generic controller file which accepts a variable - http://localhost:8000/myapp/swagger/{document_name}

Swashbuckle Swagger generate an actual guid

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 06:47:12
问题 I am using Swashbuckle to generate Swagger in my .Net Core WebAPI project. As you can see below, it generates a GUID of type string. I would like to generate a random Guid and replace "string" with "" or an empty guid "00000000-0000-0000-0000-000000000000". This would allow my example to actually work when I post it. { "payload": [ { "GUID": "string", "status": "string" } ] } while I am at it, would it be possible to the same with any string so that JSON is different each time? 回答1: Decorate

Swagger not working on Azure Web app running as OWIN

十年热恋 提交于 2019-12-11 06:29:51
问题 I have a ASP.NET Web API implemented as OWIN middleware. I hosted it on azure and now I have a problem using swagger. It is perfectly working on localhost but when I try it on azure I get this: The way I did my configuration for swagger on the API was to completely remove SwaggerConfig.cs file and add all the configuration into my Startup.cs class as shown here: How to generate documentation using swashbuckle for WebApi 2 with Owin . If it is going to help, I am trying to implement oAuth2

Automatically generate default 200 OK response while specifying other response types

最后都变了- 提交于 2019-12-11 06:22:38
问题 According to #216, Swashbuckle will automatically generate a 200 success response as the default behavior, or otherwise expects all response types to be specified. I'd like to be able to add a 404/400 error response to some endpoints in the XML comments while keeping the 200 success responses for all endpoints, including those with a 404/400 error response. Is it possible to make Swashbuckle continue to automatically generate a 200 success response for all endpoints even when an error

How to debug error 500 in Swashbuckle 5 for ASP.Net

大兔子大兔子 提交于 2019-12-11 04:20:59
问题 I'm getting an error 500 back from Swashbuckle/Swagger, and contrary to the best related answer I could find, I'm not seeing any additional information in the error response. I manually tracked down the problem endpoints by trial-and-error commenting out controllers and actions until I isolated the bad ones, but this is slow and doesn't tell me why certain endpoints have a problem. What can I do to get meaningful debug information for the Swagger/Swashbuckle errors? I'm using Swashbuckle 5.6

Swashbuckle Swagger UI: How to remove required from parameters in xml commenting

佐手、 提交于 2019-12-10 19:49:28
问题 I would like to change the required attribute on a some of the parameters in my controllers. I used XML comments in order to link to Swagger. 回答1: Before proceeding, think carefully about your parameter. Is the parameter truly required, and does your typing reflect that? Is there a sane default value, and what would be the expected behavior in that case? Depending on your answer, you may prefer one of these two solutions: Option 1: Optional Parameters If accessTokenID has a sane default value

Indicate required properties of complex input parameter object in Swagger UI

两盒软妹~` 提交于 2019-12-10 19:39:03
问题 In this method /// <summary> /// Gets activity logs. /// </summary> /// <param name="locationId">Location id.</param> /// <param name="filter">Activity log filter options.</param> /// <response code="200">OK</response> [ResponseType(typeof(ActivityLogResponse))] public async Task<HttpResponseMessage> FetchActivityLogs(int locationId, ActivityLogFilterOptions filter) { } ActivityLogFilterOptions has some required properties and some are optional. Is there any way to indicate this in Swagger UI

Convert string fields to enum fields in Swashbuckle

两盒软妹~` 提交于 2019-12-10 19:36:37
问题 We are using Swashbuckle to document our WebAPI project (using Owin) and are trying to modify the generated Swagger file of Swashbuckle. With the DescribeAllEnumsAsStrings() and an enum property like below, we get an expected result: class MyResponseClass { public Color color; } enum Color { LightBlue, LightRed, DarkBlue, DarkRed } Swagger generated result: "color": { "enum": [ "LightBlue", "LightRed", "DarkBlue", "DarkRed" ], "type": "string" }, The challenge for us is that we have some

How do I get Swagger UI to use port 443 with Swashbuckle?

99封情书 提交于 2019-12-10 15:38:45
问题 In our QA and Prod environments that run our RESTful web services, port 80 is not open. So currently when I try to get to Swagger UI in QA, I get this message and it just hangs: fetching resource list: http://qa-server:80/product-catalog-api/swagger/docs/v1; Please wait. I am using Swashbuckle to configure Swagger. I also changed this line in the config, but it still doesn't work. // If schemes are not explicitly provided in a Swagger 2.0 document, then the scheme used to access // the docs

How disable the swagger validator when using Swashbuckle for a net core web api project. Swashbuckle 6.0.0

自古美人都是妖i 提交于 2019-12-10 15:29:02
问题 How can I disable the Swagger Schema validator in options for Swashbuckle 6.0.0. I know it's turned off by default when I run locally but don't see validatorURL option for SwaggerUI() 回答1: Seems that there is an option on Swagger 6.0.0 to manage Validator. Didn't try myself, but seems to be pretty explicit on what it does. 回答2: from the github repository: This level of configuration will be available in the upcoming, stable 6.0.0 release as can be seen in the example website for custom UI