Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An item with the same key has already been added #1335

Closed
andrewzamer opened this issue Oct 1, 2019 · 3 comments
Closed

An item with the same key has already been added #1335

andrewzamer opened this issue Oct 1, 2019 · 3 comments

Comments

@andrewzamer
Copy link

I'm not sure what changed, but there seems to be a key duplicating causing this error. Is there a way to determine what the key is that's duplicating and where it's coming from?

500 : {"message":"An error has occurred.","exceptionMessage":"An item with the same key has already been added.","exceptionType":"System.ArgumentException","stackTrace":" at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)\r\n at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)\r\n at Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem(IEnumerable1 apiDescriptions, SchemaRegistry schemaRegistry)\r\n at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)\r\n at Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String apiVersion)\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Cors.CorsMessageHandler.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at U4.PublicApiFramework.Core.MessageHandlers.NotMatchedUriMessageHandler.d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.HttpServer.d__0.MoveNext()"} http://localhost/agrtest-BusinessWorld-web-api/documentation/swagger/v1

STEPS TO REPRODUCE:

Opening up the site http://localhost/agrtest-BusinessWorld-web-api/swagger/ui/index

EXPECTED RESULT:

Swagger document should be displayed

ACTUAL RESULT:

The above error message is being displayed

@andrewzamer
Copy link
Author

We were able to get the issue resolved by modifying the file set slightly

@ravideepbansal
Copy link

Hi Andrew, I am facing same issue. what did you change or how did you fix it?

@andrewzamer
Copy link
Author

Hi @ravideepbansal ,
It almost looks like any API-related change done to the file set makes it work again for us. I simply deleted an unneeded file from our \Web Api\bin folder and restarted the WebAPI app pool and it worked for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants