question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error "Duplicate schemaIds detected" without schema name.

See original GitHub issue

Try to access http://localhost:52840/swagger/docs/v1 I got this message

Conflicting schemaIds: Duplicate schemaIds detected for types and . See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround

Use c.UseFullTypeNameInSchemaIds() in SwaggerConfig.cs still not help.

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Conflicting schemaIds: Duplicate schemaIds detected for types and . See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace>
at Swashbuckle.Swagger.SchemaRegistry.CreateRefSchema(Type type) at Swashbuckle.Swagger.SchemaRegistry.CreateInlineSchema(Type type) at Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type) at Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDesc, SchemaRegistry schemaRegistry) at Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, SchemaRegistry schemaRegistry) at Swashbuckle.Swagger.SwaggerGenerator.<>c__DisplayClass7.<GetSwagger>b__4(IGrouping`2 group) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) at Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String apiVersion) at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()
</StackTrace>
</Error>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

30reactions
Ghebrehiywetcommented, Nov 15, 2017

Every class in the swagger JSON must have a unique schemaId.

Swashbuckler tries to just use the class name as a simple schemaId, however if you have two classes in different namespaces with the same name (as you do) this will not work.

As the error suggests, you can use the config setting “UseFullTypeNameInSchemaIds” for a potential workaround.

if your concern is How to use “UseFullTypeNameInSchemaIds” in .NetCore middleware? you can achieve the same behavior via options.CustomSchemaIds(x => x.FullName).

Here is an example:


   services.ConfigureSwaggerGen(options =>
   {
       //your custom configuration goes here

...

  // UseFullTypeNameInSchemaIds replacement for .NET Core
       options.CustomSchemaIds(x => x.FullName);
   });

for more information

http://wegotcode.com/microsoft/swagger-fix-for-dotnetcore/

5reactions
malah-codecommented, Jan 23, 2018

This has been fixed when using UseFullTypeNameInSchemaIds option.

GlobalConfiguration.Configuration
                .EnableSwagger(c =>
                    {
c.UseFullTypeNameInSchemaIds();
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

swagger error: Conflicting schemaIds: Duplicate ...
Every class in the swagger JSON must have a unique schemaId. Swashbuckler tries to just use the class name as a simple schemaId, ......
Read more >
Swashbuckle Duplicate SchemaId Detected
Swashbuckle Duplicate SchemaId Detected ... Use the default implementation of the Class Name (without Namespace) when possible.
Read more >
Duplicate schemaIds detected for types A and B-asp.net-web ...
I am using Asp.net Core 2.1. This error resulted when I tried to show Swagger UI. Every class in the swagger JSON must...
Read more >
C# – swagger error: Conflicting schemaIds: Duplicate ...
Using Web API and using swashbuckle to generate swagger documentation, I defined two different classes with the same name in two different namespaces....
Read more >
Swagger duplicate schemaIds #5190
Hi - Swagger is throwing the following error. I already added c.UseFullTypeNameInSchemaIds(); to WebApiModule.cs file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found