Образец исключения Swagger Response Formats - PullRequest
0 голосов
/ 17 декабря 2018

Я получаю это сообщение об ошибке при попытке просмотреть мои API в разделе справки swagger.Что-то, что мне нужно добавить, чтобы остановить эту ошибку?

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.

1 Ответ

0 голосов
/ 17 декабря 2018

GuidelineDataLayer.Model.Disease - это ваш собственный код?У вас есть круговая ссылка в вашем объекте, которая препятствует сериализации модели.Повторите код еще раз и убедитесь, что у вас нет двух классов, указывающих друг на друга.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...