Conflicting schemaIds at the end of session 2
matiasmolleja opened this issue · 2 comments
I've been following the steps and at the end of Session 2, when I run the app and go the "/swagger" url I get an exception about "Conflicting schemaIds".
It's just me?
I fixed it by adding this to the swagger configuration in the startup.cs:
options.CustomSchemaIds(x => x.FullName);
Exception details:
System.InvalidOperationException: Conflicting schemaIds: Identical schemaIds detected for types BackEnd.Data.Speaker and ConferenceDTO.Speaker. See config settings - "CustomSchemaIds" for a workaround at Swashbuckle.AspNetCore.SwaggerGen.SchemaIdManager.IdFor(Type type) at Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistry.CreateReferenceSchema(Type type, Queue
1 referencedTypes)
at Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistry.GetOrRegister(Type type)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateBodyParameter(ApiParameterDescription apiParameterDescription, String name, Boolean isRequired, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateParameter(ApiDescription apiDescription, ApiParameterDescription apiParameterDescription, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.WhereSelectListIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable1 apiDescriptions, ISchemaRegistry schemaRegistry) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector, IEqualityComparer1 comparer) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItems(IEnumerable
1 apiDescriptions, ISchemaRegistry schemaRegistry)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT1.ProcessRequestAsync()
That generally indicates you have an incorrect using
statement somewhere. Go through and triple-check that you're using the ConferenceDTO
and BackEnd.Data
namespaces in the right places.
@DamianEdwards I was going to look for that. But before doing anything I tried again and It worked.
Not sure what was wrong then.
Thank you!