Open Closed

The same schema is already used for type #9824


0
tbentley created

I'm using version Abp.AspNetCore v5.10.1 using angular I haave been using this application for a while and have recently added some Stripe APIs and have suddenly run into an error when I try to log into swagger and select the "Swagger UI" button I get the error Failed to load API definition Errors Fetch error undefined /swagger/v1/swagger.json

in the log.txt file is the following error. I am not sure what is causing it or how to get rid of it.

INFO 2020-11-15 17:18:33,784 [7 ] NetCore.StaticFiles.StaticFileMiddleware - Sending file. Request path: '/favicon-32x32.png'. Physical path: 'N/A' INFO 2020-11-15 17:18:33,785 [7 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished in 6.4973ms 200 image/png ERROR 2020-11-15 17:18:34,222 [4 ] nostics.DeveloperExceptionPageMiddleware - An unhandled exception has occurred while executing the request. System.InvalidOperationException: Can't use schemaId "$Customer" for type "$Stripe.Customer". The same schemaId is already used for type "$UnuHub.Orders.Customer" at Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.ReserveIdFor(Type type, String schemaId) at Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.GetOrAdd(Type type, String schemaId, Func1 factoryMethod) at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateReferencedSchema(DataContract dataContract, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForType(Type type, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GeneratePropertySchema(DataProperty serializerMember, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateObjectSchema(DataContract dataContract, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateInlineSchema(DataContract dataContract, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.<>c__DisplayClass7_0.<GenerateReferencedSchema>b__0() at Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.GetOrAdd(Type type, String schemaId, Func1 factoryMethod)

Any help is much appreciated. Thanks... Terry


4 Answer(s)
  • 0
    tbentley created

    I posted a little too quickly as I found the solution at https://stackoverflow.com/questions/46071513/swagger-error-conflicting-schemaids-duplicate-schemaids-detected-for-types-a-a

    I changed options.CustomSchemaIds(SchemaIdSelector); to options.CustomSchemaIds(x => x.FullName);

    in the SwaggerExtension CustomDefaultSchemaIdSelector

    and I no longer get the error

  • 0
    tbentley created

    This fix allowed me to start the server app but after doing a nswag refresh, I am now getting dozens of errors when I do an npm start.

  • 0
    ismcagdas created
    Support Team

    Hi @tbentley

    AspNet Zero doesn't support using options.CustomSchemaIds(x => x.FullName). I think best way is to rename the classes you can.

  • 1
    tbentley created

    Thanks. I added a bit of a hack to the CustomDefaultSchemaIdSelector to differentiate between these two Customer classes for now. It seems to be working.