msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

ComplexType navigation properties are not generated

Open zengin opened this issue 3 years ago • 6 comments

We do not generate navigation properties for complex types. Example:

https://docs.microsoft.com/en-us/graph/api/b2xidentityuserflow-put-apiconnectorconfiguration?view=graph-rest-1.0&tabs=csharp%2Chttp#request

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

await graphClient.Identity.B2xUserFlows["{b2xIdentityUserFlow-id}"].PostFederationSignup.Reference
	.Request()
	.PutAsync("{id}");
<ComplexType Name="userFlowApiConnectorConfiguration">
  <NavigationProperty Name="postAttributeCollection" Type="graph.identityApiConnector" ContainsTarget="true"/>
  <NavigationProperty Name="postFederationSignup" Type="graph.identityApiConnector" ContainsTarget="true"/>
</ComplexType>

AB#9491

zengin avatar May 17 '21 17:05 zengin

In this case I believe the metadata is wrong, since the metadata indicates ContainsTarget=true, the sample should not be a reference request. However the apiConnectors collection exists under the identity singleton, so obviously ContainsTarget should not be here or set to false.

baywet avatar Nov 17 '21 19:11 baywet

I think there might be two separate issues here. I agree that there is a discrepancy between metadata and the ref request in the docs. I will follow up on that.

It also looks like we are not able to generate the apiConnectorConfiguration segment because it is a structural property. So the second, SDK related issue is this one: https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/258. @baywet could you please comment on whether that issue is being fixed by kiota?

Related: we will need to fix the corresponding snippet generation too https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/485.

zengin avatar Nov 17 '21 21:11 zengin

Given the metadata you quoted, I also believe the apiConnectorConfiguration segment should not be in the snippet url

baywet avatar Nov 17 '21 22:11 baywet

structural property problem is actually one level up:

<EntityType Name="b2xIdentityUserFlow" BaseType="graph.identityUserFlow">
  <Property Name="apiConnectorConfiguration" Type="graph.userFlowApiConnectorConfiguration"/>
  <NavigationProperty Name="identityProviders" Type="Collection(graph.identityProvider)"/>
  <NavigationProperty Name="languages" Type="Collection(graph.userFlowLanguageConfiguration)" ContainsTarget="true"/>
  <NavigationProperty Name="userAttributeAssignments" Type="Collection(graph.identityUserFlowAttributeAssignment)" ContainsTarget="true"/>
  <NavigationProperty Name="userFlowIdentityProviders" Type="Collection(graph.identityProviderBase)"/>
</EntityType>

https://docs.microsoft.com/en-us/graph/api/b2xidentityuserflow-put-apiconnectorconfiguration?view=graph-rest-1.0&tabs=http

PUT https://graph.microsoft.com/v1.0/identity/b2xUserFlows/B2X_1_testuserflow/apiConnectorConfiguration/postFederationSignup/$ref

apiConnectorConfiguration is what takes us to the complex type userFlowApiConnectorConfiguration in the metadata quoted above.

But we don't have request builders in Typewriter output for the structural properties (in this case for apiConnectorConfiguration).

zengin avatar Nov 17 '21 22:11 zengin

Thanks for clarifying. We don't have it in kiota today, and that's because it's not part of the openapi description. I suspect it might have been a design choice though to keep the description shorter. Maybe @darrelmiller can help with that?

baywet avatar Nov 17 '21 22:11 baywet

I think we are going to have to create yet another annotation to indicate that an OpenAPI path needs to be generated for a structural property. In OData, in theory, any structural property can be referenced via a path. Obviously the OpenAPI description doesn't include those paths for every property. I don't know if there is a capability annotation that explicitly states a structural property can be accessed directly. If there is, we should use it. If there isn't we need to create one.

darrelmiller avatar Dec 05 '21 04:12 darrelmiller

I think we are going to have to create yet another annotation to indicate that an OpenAPI path needs to be generated for a structural property

This was addressed via https://github.com/microsoft/OpenAPI.NET.OData/issues/176.

Closing this issue here for a relevant annotation to be added to have the path present in the metadata. Tracked via https://github.com/microsoftgraph/msgraph-metadata/issues/new

andrueastman avatar Jun 26 '23 10:06 andrueastman