8 Answer(s)
-
0
Hi OriAssurant
If your model classes have circular references (e.g., a property in Class A references Class B, and Class B references Class A), NSwag may struggle to generate the schema. Try using [JsonIgnore] or [SwaggerIgnore] attributes on properties that create circular references.
-
0
Thank you oguzhanagir-
Any other causes you have seen for this issue? After checking for circular references, commenting out many of our custom classes, etc. the issue is still occurring.
Asp.net Zero dropped the use of Newtonsoft in favor of System.Text.Json in v13 right? Seeing Newtonsoft.Json in the error we're getting.
Any other ideas of what to check would be very much appreciated. Thanks
-
0
Hi @OriAssurant,
Can you update the following code on your
service.config.nswag
"codeGenerators": { "openApiToCSharpClient": { "jsonLibrary": "SystemTextJson", // change this line }
-
0
-
0
Hi @OriAssurant,
Could you share your project with [email protected] We can take a look for your custom services.
-
0
Hi oguzhanagir Project shared with "[email protected]" .
Please check and et us know if you are facing any access issue to get the shared project.
Thank you
-
0
Hi oguzhanagir, Hopefully your support received the shared project and taking a look.
any ideas/clues regarding resolve the issue from our project would be very much appreciated.
Thanks
-
0
Hi @OriAssurant
We have found the reason of the problem. It is because of
JToken
andJObject
usages inCustomersController
,ExternalController
andOrdersController
.You can either use DTO classes instead or exclude these controllers from swagger as shown below;
options.DocInclusionPredicate((docName, description) => { var excludedControllers = new[] { "CustomersController", "ExternalController", "OrdersController", }; foreach (var excludedController in excludedControllers) { if (description.ActionDescriptor.DisplayName.Contains(excludedController)) { return false; } } return true; });