swashbuckle

ASP.NET Core 2.1 Swagger(swashbuckle) Url template optional parameter [duplicate]

本秂侑毒 提交于 2020-01-15 12:24:29
问题 This question already has answers here : Optional WebAPI routing parameters with Swagger documentation (1 answer) Make parameters in swashbuckle optional(not required) (3 answers) Swagger: support for optional routes (1 answer) Closed 21 days ago . [HttpGet("commercial/{fromCcy}/{toCcy?}")] public ActionResult Commercial(string fromCcy, string toCcy) I have action "commercial" with optional parameter "toCcy" and swagger spec generates with required field. Is there any way to solve this

swagger UI is not showing anything in webapi

十年热恋 提交于 2020-01-13 10:04:38
问题 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

swagger .net core API ambiguous HTTP Action debugging

可紊 提交于 2020-01-12 13:46:33
问题 Implementing Swashbuckle/Swagger with .net Core 2 API I am now receiving the 500 error when accessing swagger.json: NotSupportedException: Ambiguous HTTP method for action - EBisAPI.Controllers._class.HandleError (EBisAPI). Actions require an explicit HttpMethod binding for Swagger I have gone through all the controllers and see explicit routing on all the public methods of each controller. Is there a way to determine which method is throwing the ambiguous routing error? 回答1: This can occur

Grouping of API methods in documentation - is there some custom attribute

試著忘記壹切 提交于 2020-01-10 08:49:26
问题 I have controller like public class UserController : ApiController { [Route("api/user")] IHttpActionResult GetUser() { ... } } public class ResumeController : ApiController { [Route("api/user/resumes")] IHttpActionResult GetResumes() { ... } } Which on swagger generates output like Is there a way (besides overriding default implementation by rolling out your own ISwaggerProvider or merging two controllers into one) to enforce the group name ? Something like public class UserController :

Swagger/Swashbuckle document POST with JSON

↘锁芯ラ 提交于 2020-01-07 03:08:10
问题 I have a challenge with Swashbuckle or Swagger. I'm not sure if the problem is with Swagger or Swashbuckle. I have web api call, implemented both with the parameter as URI params, and with reading the content from the body of the request. One is implemented like this: [Route("application/uri")] [HttpPost] public async Task<string> Post([ModelBinder] Application application) { return await RegisterApplication(application); } The other is implemented like this: [Route("loanapplication/json")]

Html Example Response with Swagger and Swashbuckle

醉酒当歌 提交于 2020-01-06 11:48:30
问题 I have a .NET Web API 2 app, with a controller method that returns HTML. I want to provide sample HTML in the swagger docs, but I can't get anything to show. This is what I have: [HttpGet] [SwaggerResponse(HttpStatusCode.OK, Type = typeof(string))] [SwaggerResponse(HttpStatusCode.NotFound)] [SwaggerResponseContentType("text/html", Exclusive = true)] [SwaggerResponseExamples(typeof(string), typeof(ExampleProvider))] public async Task<HttpResponseMessage> Get(Guid id) { var example = GetExample

`SwaggerRequestExample` is being ignored

。_饼干妹妹 提交于 2020-01-03 15:20:22
问题 As I was adding swagger to my API, I wanted to get default values and response examples. I added the NuGet packages and tried to follow this tutorial. The SwaggerResponseExample attribute works properly but the SwaggerRequestExample seems to be simply ignored. With my action defined as follow [SwaggerRequestExample(typeof(int), typeof(PersonExamples.Request))] [SwaggerResponseExample(200, typeof(PersonExamples.Response))] /* more attribute & stuff */ public IActionResult Get(int id) { /*

Swagger: support for optional routes

假如想象 提交于 2020-01-03 13:07:48
问题 I have a route with an optional parameter: [Route("{categoryId?}")] public HttpResponseMessage Get(int? categoryId=null) However, when I don't provide a value for categoryId the call includes {categoryId?} in the request itself... http://myhost/api/%7BcategoryId%7D 回答1: Swagger has no support for optional path parameters. If you wish to document it this way, you'd have to create two separate paths - one without the path parameter and one with. 来源: https://stackoverflow.com/questions/30182657

Duplicate parameter output in Swagger

↘锁芯ラ 提交于 2020-01-02 03:38:04
问题 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

Asp.Net core Swashbuckle set operationId

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 19:34:59
问题 How can I set swagger operationId attribute in Asp.Net Core 2.1 project? According to this post I should use SwaggerOperationAttribute but I cannot find it in Swashbuckle.AspNetCore library. Also there is an IOperationFilter public interface IOperationFilter { void Apply(Operation operation, OperationFilterContext context); } and I can't find any implementations for swagger generation purposes. 回答1: There are 2 other options without having to write any extra code or add extra dependency like