0

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"

  • Please include the minimum amount of code needed to reproduce this issue. You explaining it and giving the exception does not help us help you. Sounds like you have something duplicated though. – Zach Sexton May 06 '22 at 06:02
  • the probleme comes from architecture and not from the code. So, I edited the quest and added pictures of good and bad architectures. – Arnaud M. Smadja May 08 '22 at 19:00
  • Does this answer your question? [swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B](https://stackoverflow.com/questions/46071513/swagger-error-conflicting-schemaids-duplicate-schemaids-detected-for-types-a-a) – Saul Sep 06 '22 at 10:43

0 Answers0