Closed Lonli-Lokli closed 2 years ago
Hey @Lonli-Lokli
It's hard to tell without a spec but according to this warning there is no operationId set. If you want to set a custom operationId preventing the package from generating one for you simply add the Name
property to the HTTP action filter. For example
[HttpGet(Name="GetDocuments")]
We use this in our StartUp.cs
. It generates methods with the same name as the server side methods
services.AddSwaggerGen(c =>
{
c.CustomOperationIds(api => ((ControllerActionDescriptor)api.ActionDescriptor).MethodInfo.Name);
});
Thanks, I am using now this within class SwaggerDefaultValues : IOperationFilter
operation.OperationId ??= string.Join(string.Empty, (new string[] { apiDescription.HttpMethod ?? string.Empty })
.Concat((apiDescription.RelativePath ?? string.Empty).Split(@"/"))
.Select(word => string.Join(string.Empty, word.Split('{', '}')))
.Select(FirstCharToUpper));
I am getting a lot of such messages with code generation, how can I avoid them with Swashbuckle