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>
Use c.UseFullTypeNameInSchemaIds() in SwaggerConfig.cs still not help.
@domaindrivendev
Is any update on this? I have the same problem
I am having the same issue and would love an update if there is one.
OK, I'm gonna need some help getting to the bottom of this. Looking at the code that creates the exception - https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Swagger/SchemaRegistry.cs#L275 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?
Sorry about the late response. It has taken me a bit to get back to this issue. Somehow of the course of time my error has also changed :(. I have left of some of the error that points to direct files in our code base however here it is..trying to dig thru what is happening
500 : {"Message":"An error has occurred.","ExceptionMessage":"Invalid type owner for DynamicMethod.","ExceptionType":"System.ArgumentException","StackTrace":" at System.Reflection.Emit.DynamicMethod.Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, Module m, Boolean skipVisibility, Boolean transparentMethod, StackCrawlMark& stackMark)\r\n at System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility)\r\n at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes, Type owner)\r\n at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructorT\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract)\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)\r\n at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)\r\n at Swashbuckle.Swagger.SchemaRegistry.CreateInlineSchema(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
I finally resolved my issue last week. We have Controllers that inherit from a base class and I had to mark several methods in the base class with the attribute [ApiExplorerSettings(IgnoreApi = true)] with so it did not try and document those.
@msclements2003 How did you resolved this issue? I also encountered this problem.
Here is the comment I wrote above: We have Controllers that inherit from a base class and I had to mark several methods in the base class with the attribute [ApiExplorerSettings(IgnoreApi = true)] with so it did not try to document those.
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
This has been fixed when using UseFullTypeNameInSchemaIds option.
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.UseFullTypeNameInSchemaIds();
});
Here is the comment I wrote above: We have Controllers that inherit from a base class and I had to mark several methods in the base class with the attribute [ApiExplorerSettings(IgnoreApi = true)] with so it did not try to document those.
Hi @sclements-wex,
It seems we both have the same setup regarding Controllers.
Do you mind letting me know which methods you had to add the attribute [ApiExplorerSettings(IgnoreApi = true)] to?
Thanks
See comments above.
Most helpful comment
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:
for more information
http://wegotcode.com/microsoft/swagger-fix-for-dotnetcore/