aspnet-api-versioning icon indicating copy to clipboard operation
aspnet-api-versioning copied to clipboard

OData service with hierarchy recursion

Open AndrewZenith opened this issue 4 years ago • 5 comments
trafficstars

I'm trying to generate my Swagger Pages for my OData Service (using 8.0.1). My EdmModel has hierarchy recursion, and I can see the PseudoModelBindingVisitor.Visit is going nuts as a result. I debugged, and at the below line it's already gone into recursive madness.

How do I stop this. I don't mind if I just get the base object (for now) in the swagger page - I just want it to generate! I don't want to change the EdmModel though, it's working fine and will let me down into the navigation properties.

Visit(context, bindingSource ?? ambientSource, containerName2);

containerName2, already gone down the rabbit hole:

ClientIDXpo.ClientAdditionalDetailsNewXpo.ServiceIDXpo.FclaspServicesXpo.CountryIDDestXpo.CsdAddSecIDXpo.UpdateUserIDXpo.UserPasswordXpo.UpdateUserIDXpo.ClientIDFclaspXpoDs.ClientDefRegistAndApprovalXpoDan1.RegappcatIDXpo.RegappIDXpo.UpdateUserIDXpo.SubsidiarySystemUsersXpo.UpdateUserIDXpo.StklocIDXpo.CountryIDXpo.CurrencyIDXpo.CountryIDXpo.DoctxtIDExpSpotQuoteCat2Xpo.AnalysisIDXpo.DepartmentIDEmail1Xpo.FilterIDDefEqcGXpo.UpdateUserIDXpo.CliCont3IDXpo.ClientIDXpo.SalesReportsLastContact.ServiceIDXpo.AnalysisIDXpo.DepartmentIDEmail2Xpo.ServiceIDXpo.BerthsIDXpo.ClientIDclearXpo.CRMBatchControlListHoldingXpo.ClientIDXpo.ZipCodesXpo.CountryIDXpo.DoctxtIDExpSpotQuoteCat3Xpo.CreateUserIDXpo.AnalysisIDCrmXpo.DepartmentIDEmail3Xpo.AnalysisIDClientVisibleXpo.DepartmentIDEmail4Xpo.AnalysisIDDeptTypeXpo.DocmaskIDXpo.DataType.Assembly.EntryPoint.ReturnParameter.Member

AndrewZenith avatar Jul 22 '21 17:07 AndrewZenith

OData 8.0 is not officially supported so hopefully that isn't the culprit.

Do you have the file and line number reference link? If you have the world's simplest repro, that would help.

commonsensesoftware avatar Jul 22 '21 21:07 commonsensesoftware

PseudoModelBindingVisitor.Visit Just keeps going into PseudoModelBindingVisitor.Visit.

Doesn't matter that the datatypes have already been found, it just keeps going down the chain. I'll see if I can put something together with EF, but at the simplest class thing has a property thing that is a thing. Container name becomes thing.thing.thing.thing.thing........ ad infinitum. I tried using the swagger IFilterSchema, but it never gets called in my scenario, as I think it's post schema generation. I need something to stop it!

AndrewZenith avatar Jul 22 '21 21:07 AndrewZenith

https://github.com/microsoft/aspnet-api-versioning/blob/e16b579d240574053ebd8e7ee38c8686beaee174/src/Microsoft.AspNetCore.OData.Versioning.ApiExplorer/AspNetCore.Mvc/ApiExplorer/PseudoModelBindingVisitor.cs#L71

AndrewZenith avatar Jul 22 '21 21:07 AndrewZenith

Something is seemingly awry. I haven't seen this before so there is clearly some edge case not covered. The PseudoModelBindingVisitor was forked from here. Perhaps there's some difference or change that has been overlooked.

If only the OData team supported the API Explorer... 🙄

commonsensesoftware avatar Jul 22 '21 21:07 commonsensesoftware

Circling back around on this issue. I expect that you never got it to work; at least, not the way you wanted. OData 8.0 hasn't been supported (until now) and it was a complete rewrite. This type of issue, therefore, wasn't too surprising to me.

The 6.0 release is finally close and will support OData 8. You can find the latest code and example for OData + OpenAPI here. I know it's a bit to ask, but if you're able to test it out and let me know if it addresses your issue, I'm sure it will beneficial to you as well as others. Due the entire rewrite of the OData implementation, the offending line of code mentioned here doesn't event exist anymore.

Here's to hoping this is resolved for you - soon, if it isn't already.

commonsensesoftware avatar Mar 20 '22 22:03 commonsensesoftware

6.0 has been officially release. This thread seems to gone dark. Since the offending code no longer even exists, I'm inclined to close this out. If someone this is not resolved, I'm happy to reopen the issue or discuss further. Thanks.

commonsensesoftware avatar Aug 24 '22 02:08 commonsensesoftware