Skip to content

Commit 10fa9cc

Browse files
authored
Adds referenceable annotation (#153)
* Add referenceable annotations * Update output file * Add transform for group/members separately * Update output file * Update indentation * Refactor transform file * Update output file
1 parent 85b22c7 commit 10fa9cc

2 files changed

Lines changed: 107 additions & 4 deletions

File tree

transforms/csdl/preprocess_csdl.xsl

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,18 @@
606606
</xsl:element>
607607
</xsl:element>
608608
</xsl:template>
609+
<xsl:template name="ReferenceableRestrictionsTemplate">
610+
<xsl:param name = "referenceable" />
611+
<xsl:element name="Annotation">
612+
<xsl:attribute name="Term">Org.OData.Capabilities.V1.NavigationRestrictions</xsl:attribute>
613+
<xsl:element name="Record" namespace="{namespace-uri()}">
614+
<xsl:element name="PropertyValue">
615+
<xsl:attribute name="Property">Referenceable</xsl:attribute>
616+
<xsl:attribute name="Bool"><xsl:value-of select="$referenceable"/></xsl:attribute>
617+
</xsl:element>
618+
</xsl:element>
619+
</xsl:element>
620+
</xsl:template>
609621

610622
<!-- Add Navigation Restrictions Annotations -->
611623
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']">
@@ -656,7 +668,7 @@
656668
</xsl:element>
657669
</xsl:element>
658670
</xsl:element>
659-
671+
660672
<!-- Remove indexability for joinedGroups navigation property -->
661673
<!-- Add the parent "Annotations" tag if it doesn't exists -->
662674
<xsl:choose>
@@ -718,6 +730,21 @@
718730
</xsl:call-template>
719731
</xsl:element>
720732
</xsl:if>
733+
734+
<!-- Add Referenceable annotations for group/members & publishedResource/agentGroups
735+
separately so as not to overwrite the prior transforms added to these navigation properties -->
736+
<xsl:element name="Annotations">
737+
<xsl:attribute name="Target">microsoft.graph.group/members</xsl:attribute>
738+
<xsl:call-template name="ReferenceableRestrictionsTemplate">
739+
<xsl:with-param name="referenceable">true</xsl:with-param>
740+
</xsl:call-template>
741+
</xsl:element>
742+
<xsl:element name="Annotations">
743+
<xsl:attribute name="Target">microsoft.graph.publishedResource/agentGroups</xsl:attribute>
744+
<xsl:call-template name="ReferenceableRestrictionsTemplate">
745+
<xsl:with-param name="referenceable">true</xsl:with-param>
746+
</xsl:call-template>
747+
</xsl:element>
721748
</xsl:copy>
722749
</xsl:template>
723750

@@ -732,7 +759,7 @@
732759
<xsl:copy-of select="@*|node()"/>
733760
<xsl:call-template name="NavigationRestrictionsTemplate">
734761
<xsl:with-param name="navigable">false</xsl:with-param>
735-
</xsl:call-template>
762+
</xsl:call-template>
736763
</xsl:copy>
737764
</xsl:template>
738765

@@ -753,4 +780,54 @@
753780
</xsl:copy>
754781
</xsl:template>
755782

783+
<!-- Add Referenceable Annotations (for /$ref paths) -->
784+
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='administrativeUnit']/edm:NavigationProperty[@Name='members']|
785+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connectorGroup']/edm:NavigationProperty[@Name='members']|
786+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='directoryRole']/edm:NavigationProperty[@Name='members']|
787+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationClass']/edm:NavigationProperty[@Name='members']|
788+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='accessPackage']/edm:NavigationProperty[@Name='incompatibleAccessPackages']|
789+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='accessPackage']/edm:NavigationProperty[@Name='incompatibleGroups']|
790+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='application']/edm:NavigationProperty[@Name='owners']|
791+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='application']/edm:NavigationProperty[@Name='tokenIssuancePolicies']|
792+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='application']/edm:NavigationProperty[@Name='tokenLifetimePolicies']|
793+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='application']/edm:NavigationProperty[@Name='appManagementPolicies']|
794+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='b2cIdentityUserFlow']/edm:NavigationProperty[@Name='identityProviders']|
795+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='b2xIdentityUserFlow']/edm:NavigationProperty[@Name='userFlowIdentityProviders']|
796+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connectedOrganization']/edm:NavigationProperty[@Name='externalSponsors']|
797+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connector']/edm:NavigationProperty[@Name='memberOf']|
798+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='application']/edm:NavigationProperty[@Name='connectorGroup']|
799+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connectorGroup']/edm:NavigationProperty[@Name='members']|
800+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='device']/edm:NavigationProperty[@Name='registeredOwners']|
801+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connector']/edm:NavigationProperty[@Name='registeredUsers']|
802+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='sourceCollection']/edm:NavigationProperty[@Name='custodianSources']|
803+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='sourceCollection']/edm:NavigationProperty[@Name='noncustodialSources']|
804+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationAssignment']/edm:NavigationProperty[@Name='categories']|
805+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationAssignment']/edm:NavigationProperty[@Name='rubric']|
806+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationClass']/edm:NavigationProperty[@Name='members']|
807+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationClass']/edm:NavigationProperty[@Name='teachers']|
808+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationSchool']/edm:NavigationProperty[@Name='classes']|
809+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationSchool']/edm:NavigationProperty[@Name='users']|
810+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='featureRolloutPolicy']/edm:NavigationProperty[@Name='appliesTo']|
811+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='group']/edm:NavigationProperty[@Name='acceptedSenders']|
812+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='group']/edm:NavigationProperty[@Name='owners']|
813+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='group']/edm:NavigationProperty[@Name='rejectedSenders']|
814+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='mobilityManagementPolicy']/edm:NavigationProperty[@Name='includedGroups']|
815+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='onPremisesAgent']/edm:NavigationProperty[@Name='agentGroups']|
816+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='printerShare']/edm:NavigationProperty[@Name='allowedGroups']|
817+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='printerShare']/edm:NavigationProperty[@Name='allowedUsers']|
818+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='servicePrincipal']/edm:NavigationProperty[@Name='claimsMappingPolicies']|
819+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='servicePrincipal']/edm:NavigationProperty[@Name='homeRealmDiscoveryPolicies']|
820+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='servicePrincipal']/edm:NavigationProperty[@Name='owners']|
821+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='user']/edm:NavigationProperty[@Name='manager']|
822+
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connector']/edm:NavigationProperty[@Name='memberOf']|
823+
edm:Schema[@Namespace='microsoft.graph']/edm:ComplexType[@Name='userFlowApiConnectorConfiguration']/edm:NavigationProperty[@Name='postAttributeCollection']|
824+
edm:Schema[@Namespace='microsoft.graph']/edm:ComplexType[@Name='userFlowApiConnectorConfiguration']/edm:NavigationProperty[@Name='postFederationSignup']">
825+
<xsl:copy>
826+
<xsl:apply-templates select="@* | node()"/>
827+
<xsl:call-template name="ReferenceableRestrictionsTemplate">
828+
<xsl:with-param name="referenceable">true</xsl:with-param>
829+
</xsl:call-template>
830+
</xsl:copy>
831+
</xsl:template>
832+
756833
</xsl:stylesheet>

transforms/csdl/preprocess_csdl_test_output.xml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,20 @@
4242
</Collection>
4343
</Annotation>
4444
</NavigationProperty>
45-
<NavigationProperty Name="acceptedSenders" Type="Collection(graph.directoryObject)" />
46-
<NavigationProperty Name="rejectedSenders" Type="Collection(graph.directoryObject)" />
45+
<NavigationProperty Name="acceptedSenders" Type="Collection(graph.directoryObject)">
46+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
47+
<Record>
48+
<PropertyValue Property="Referenceable" Bool="true" />
49+
</Record>
50+
</Annotation>
51+
</NavigationProperty>
52+
<NavigationProperty Name="rejectedSenders" Type="Collection(graph.directoryObject)">
53+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
54+
<Record>
55+
<PropertyValue Property="Referenceable" Bool="true" />
56+
</Record>
57+
</Annotation>
58+
</NavigationProperty>
4759
</EntityType>
4860
<EntityType Name="servicePrincipal" BaseType="graph.directoryObject" OpenType="true">
4961
<Property Name="appId" Type="Edm.String" />
@@ -439,6 +451,20 @@
439451
</Record>
440452
</Annotation>
441453
</Annotations>
454+
<Annotations Target="microsoft.graph.group/members">
455+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
456+
<Record>
457+
<PropertyValue Property="Referenceable" Bool="true" />
458+
</Record>
459+
</Annotation>
460+
</Annotations>
461+
<Annotations Target="microsoft.graph.publishedResource/agentGroups">
462+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
463+
<Record>
464+
<PropertyValue Property="Referenceable" Bool="true" />
465+
</Record>
466+
</Annotation>
467+
</Annotations>
442468
</Schema>
443469
<Schema Namespace="microsoft.graph.callRecords" xmlns="http://docs.oasis-open.org/odata/ns/edm">
444470
<EnumType Name="callType">

0 commit comments

Comments
 (0)