问题
I have a web api controller like below. In swagger output I am having the below image And when I want to consume it in my another console app, it is showing the below error
Note I have followed the tutorial Customize Swashbuckle-generated API definitions but still getting the same error. Any idea?
回答1:
I must need to add the Route Attribute on top of the Action methods. Like below: So, the API changed into below Swagger UI endpoints And when I consumed this Swagger in my console app, the below OperationId I got And I can now call like below (just an example)
回答2:
I found this while looking for the same question. For me it was a dumb mistake: the controller's methods had the same name. Apparently, Swashbuckle uses the method's name as the Operation Id.
来源:https://stackoverflow.com/questions/39843269/asp-net-web-api-swagger-swashbuckle-duplicate-operationid