'Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: The same schemaId is already used for type "X"
The project of .net core WebApi generate the right swagger when a class is generated in one DLL. this solution works fine, the project is compiled and the swagger is generated, as you can see in the copy of the screen.
Project architecture that works
I wanted to isolate a class in a specific DLL by create a class library and add it in dependencies. the project complies also but the only bug went from the swagger. If I use the same object in the returned object from API (same class in same namespace from a shared project that used in both projects), this is the result in the swagger:
Fetch error response status is 500 /swagger/v1/swagger.json
you can see the new architecture of the project with the same code in the screen copy:
Project architecture that doesn't work
the Exception in console is:
Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate Operation for action - WebApplication2.Controllers.ValuesController2.GetResponse2DTO (WebApplication2). See inner exception ---> Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Failed to generate schema for type - SharedProject1.ResponseDTO. See inner exception ---> System.InvalidOperationException: Can't use schemaId "$ResponseDTO" for type "$SharedProject1.ResponseDTO". The same schemaId is already used for type "$SharedProject1.ResponseDTO"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|