Base solution for your next web application
Open Closed

Swagger duplicate schemaIds #5190


User avatar
0
OriAssurant created

Hi - Swagger is throwing the following error. I already added c.UseFullTypeNameInSchemaIds(); to WebApiModule.cs file. However, that doesn't seem to resolve the issue. Any ideas to help resolve this?

500 : {"message":"An error has occurred.","exceptionMessage":"Conflicting schemaIds: Duplicate schemaIds detected for types and . See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround","exceptionType":"System.InvalidOperationException","stackTrace":" at Swashbuckle.Swagger.SchemaRegistry.CreateRefSchema(Type type)\r\n at Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type)\r\n at Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDesc, 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, IEqualityComparer`1 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 Abp.WebApi.Controllers.ResultWrapperHandler.


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    See <a class="postlink" href="https://github.com/domaindrivendev/Swashbuckle/issues/738">https://github.com/domaindrivendev/Swas ... issues/738</a>

    @domaindrivendev: Looking at the code that creates the exception - <a class="postlink" href="https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Swagger/SchemaRegistry.cs#L275">https://github.com/domaindrivendev/Swas ... ry.cs#L275</a> you can see that type.FullName and conflictingType.FullName must be returning null to result in the specific message you're seeing. This means there is some Type referenced directly or indirectly, from one of your action return types or parameters, that returns FullName null.

    The C# docs indicate that this will happen for certain generic constructs. Are you using generics in any of you're action signatures and if so can you give me the gist so I can repo locally?