Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions transforms/csdl/preprocess_csdl.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,16 @@
</xsl:template>

<!-- Capability Annotations Templates -->
<xsl:template name="IndexableByKeyTemplate">
<xsl:param name="indexableByKey" />
<xsl:element name="Annotation">
<xsl:attribute name="Term">Org.OData.Capabilities.V1.IndexableByKey</xsl:attribute>
<xsl:attribute name="Bool">
<xsl:value-of select="$indexableByKey"/>
</xsl:attribute>
</xsl:element>
</xsl:template>

<xsl:template name="CountRestrictionsTemplate">
<xsl:param name="countable" />
<xsl:element name="Annotation">
Expand Down Expand Up @@ -1823,28 +1833,46 @@
</xsl:element>
</xsl:when>
</xsl:choose>

<!-- Set IndexableByKey to false for GraphService/invitations -->
<xsl:choose>
<xsl:when test="not(edm:Annotations[@Target='microsoft.graph.GraphService/invitations'])">
<xsl:element name="Annotations">
<xsl:attribute name="Target">microsoft.graph.GraphService/invitations</xsl:attribute>
<xsl:call-template name="IndexableByKeyTemplate">
<xsl:with-param name="indexableByKey">false</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:when>
</xsl:choose>

</xsl:copy>
</xsl:template>

<!-- If the grand-parent "Annotations" tag already exists modify it -->
<!-- Set IndexableByKey to false for GraphService/invitations -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.GraphService/invitations']">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:if test="not(edm:Annotation[@Term='Org.OData.Capabilities.V1.IndexableByKey'])">
<xsl:call-template name="IndexableByKeyTemplate">
<xsl:with-param name="indexableByKey">false</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:copy>
</xsl:template>

<!-- If the grand-parent "Annotations" tag already exists modify it -->
<!-- Add deletability for directory/deletedItems -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.directory/deletedItems'] ">
<xsl:choose>
<xsl:when test="not(edm:Annotation[@Term='Org.OData.Capabilities.V1.DeleteRestrictions'])">
<xsl:copy>
<xsl:copy-of select="@*|node()"/>
<xsl:call-template name="DeleteRestrictionsTemplate">
<xsl:with-param name="deletable">true</xsl:with-param>
</xsl:call-template>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:if test="not(edm:Annotation[@Term='Org.OData.Capabilities.V1.DeleteRestrictions'])">
<xsl:call-template name="DeleteRestrictionsTemplate">
<xsl:with-param name="deletable">true</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:copy>
</xsl:template>

<!-- If the parent "Annotation" tag already exists, modify it -->
Expand Down
8 changes: 8 additions & 0 deletions transforms/csdl/preprocess_csdl_test_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@
<EntityType Name="identityContainer">
<NavigationProperty Name="authenticationEventsFlows" Type="Collection(graph.authenticationEventsFlow)" ContainsTarget="true" />
</EntityType>
<Annotations Target="microsoft.graph.GraphService/invitations">
<Annotation Term="Org.OData.Capabilities.V1.InsertRestrictions">
<Record>
<PropertyValue Property="Description" String="Create invitation" />
<PropertyValue Property="LongDescription" String="Use this API to create a new invitation. Invitation adds an external user to the organization. When creating a new invitation, you have several options available:" />
</Record>
</Annotation>
</Annotations>
<Annotations Target="microsoft.graph.directory/deletedItems">
<Annotation Term="Org.OData.Capabilities.V1.DeleteRestrictions">
<Record>
Expand Down
5 changes: 4 additions & 1 deletion transforms/csdl/preprocess_csdl_test_output.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='preprocess_csdl.xsl'?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
Expand Down Expand Up @@ -599,6 +599,9 @@
</Annotation>
</NavigationProperty>
</EntityType>
<Annotations Target="microsoft.graph.GraphService/invitations">
<Annotation Term="Org.OData.Capabilities.V1.IndexableByKey" Bool="false" />
</Annotations>
<Annotations Target="microsoft.graph.directory/deletedItems">
<Annotation Term="Org.OData.Capabilities.V1.DeleteRestrictions">
<Record>
Expand Down