В моем веб-api у меня есть 2 метода получения, один для получения всех клиентов и один для получения клиента по идентификатору
[HttpGet]
public async Task<IHttpActionResult> GetClients()
{
var telemetry = new TelemetryClient();
try
{
var roles = await CosmosStoreHolder.Instance.CosmosStoreClient.Query().ToListAsync();
return Ok(roles);
}
catch (System.Exception ex)
{
string guid = Guid.NewGuid().ToString();
var dt = new Dictionary<string, string>
{
{ "Error Lulo: ", guid }
};
telemetry.TrackException(ex, dt);
return BadRequest("Error Lulo: " + guid);
}
}
[HttpGet]
public async Task<IHttpActionResult> GetClient(string clientId)
{
var telemetry = new TelemetryClient();
try
{
var clientStore = CosmosStoreHolder.Instance.CosmosStoreClient;
var client = await clientStore.Query().FirstOrDefaultAsync(x => x.Id == clientId);
if (client == null)
{
return NotFound();
}
return Ok(client);
}
catch (System.Exception ex)
{
telemetry.TrackException(ex);
return BadRequest("Unknown error");
}
}
Я только что установил swashbucckle и настроил в соответствии с этим:
https://www.c-sharpcorner.com/article/implementing-swagger-in-web-api/
Однако я получаю сообщение об ошибке ниже
500 : {"Message":"An error has occurred.","ExceptionMessage":"Not supported by Swagger 2.0: Multiple operations with path 'api/Client' and method 'GET'. See the config setting - \"ResolveConflictingActions\" for a potential workaround","ExceptionType":"System.NotSupportedException","StackTrace":" at Swashbuckle.Swagger.SwaggerGeneratorOptions.DefaultConflictingActionsResolver(IEnumerable
1 apiDescriptions) \ r \ n в Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem (группа IEnumerable1 apiDescriptions, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.Swagger.SwaggerGenerator.<>c__DisplayClass7.<GetSwagger>b__4(IGrouping
2) \ r \ n в System.Linq.Enumerable.ToDictionary [TSource, TKey, TElement] (IEnumerable1 source, Func
2 keySelector, в Func1 source, Func
2 keySelector) Swashbuckle.Swagger.SwaggerGenerator.GetSwagger (String rootUrl, String apiVersion) \ r \ n в Swashbuckle.Application.SwaggerDocsHandler.SendAsync (запрос HttpRequestMessage, CancellationToken cancellationTokessage.HRequestMessage request. , CancellationToken cancellationToken) \ r \ n в System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync (запрос HttpRequestMessage, CancellationToken cancellationToken) \ r \ n в System.Net.Http.DelegatingHandclerSendageToken (запрос cancellationMessage), cancellationMessage (запрос Http. \ n на System.Web.Http.HttpServer.d__0.MoveNext () "} https://webapi-app.azurewebsites.net/swagger/do `cs / v1
GetClient
с другим набором параметров? - person Neil   schedule 09.10.2019clientId
на intGetClient(int clientId)
просто проверьте, отличается ли путь ... - person Helder Sepulveda   schedule 09.10.2019