I have an ASP.NET WebAPI project where I am attempting to replace our old XmlDocumentationProvider page with Swagger UI. I am using the swashbuckle swagger for webAPI 5.3.1
If anyone else runs into this issue and nothing seems to be helping you, here is what I found with our code.
We had a guy contracted to write our API, and he must have automatically imported a bunch of classes based on the DB Schema, but what it did was create a ton of partial classes with references to other partial classes, who in turn had references back to the original class.
So this ended up being a circular reference issue, as mentioned above, but not exactly the same. It took me a while to figure out what what different but as soon as I commented out the references to the other partial classes, everything worked great.
My suggestion would be a combination of the 2 answers above, use your own DTOs and make sure you don't have circular references.
Another important hang-up was in our [Route()]
tags, the guy had put [Route("{model}"]
and in the parameters of the POST/PUT method, he was using the [Route("{model}")]
tag to parse the JSON body for the model, so having it in the Route tag was unnecessary and causing issues. It should have just been [Route("")]
.