user5843610
user5843610

Reputation:

Swagger Response Formats sample exception

I am getting this error message when I try to view my api in swagger help section. Is there something I need to add to stop this error?

Response Formats
application/json
Sample:
An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'application/json'. Exception message: Self referencing loop detected with type 'Model.Disease'. Path '[0].Types[0].List'.

text/json
Sample:
An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'text/json'. Exception message: Self referencing loop detected with type 'Disease'. Path '[0].Types[0].List'.

application/xml
Sample:
An exception has occurred while using the formatter 'XmlMediaTypeFormatter' to generate sample for media type 'application/xml'. Exception message: There was an error generating the XML document.

text/xml
Sample:
An exception has occurred while using the formatter 'XmlMediaTypeFormatter' to generate sample for media type 'text/xml'. Exception message: There was an error generating the XML document.

Upvotes: 0

Views: 1189

Answers (1)

Zakk Diaz
Zakk Diaz

Reputation: 1093

GuidelineDataLayer.Model.Disease is your own code? You have a circular reference in your object that's preventing the model from serializing. Go over your code again and make sure you don't have 2 classes pointing at each other.

Upvotes: 2

Related Questions