Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XSLT: x-sap-odm-oid-reference-entity-name #272

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
17 changes: 17 additions & 0 deletions tools/V4-CSDL-to-OpenAPI.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
<xsl:variable name="odmEntityNameAliased" select="concat($odmAlias,'.entityName')" />
<xsl:variable name="odmOid" select="concat($odmNamespace,'.oid')" />
<xsl:variable name="odmOidAliased" select="concat($odmAlias,'.oid')" />
<xsl:variable name="odmOidReference" select="concat($odmNamespace,'.oidReference')" />
<xsl:variable name="odmOidReferenceAliased" select="concat($odmAlias,'.oidReference')" />

<xsl:variable name="defaultResponse">
<xsl:text>"</xsl:text>
Expand Down Expand Up @@ -2226,6 +2228,9 @@
<xsl:call-template name="Common.SAPObjectNodeTypeReference">
<xsl:with-param name="annos" select="$annos" />
</xsl:call-template>
<xsl:call-template name="ODM.oidReference">
<xsl:with-param name="annos" select="$annos" />
</xsl:call-template>
</xsl:if>
</xsl:template>

Expand Down Expand Up @@ -2349,6 +2354,17 @@
</xsl:if>
</xsl:template>

<xsl:template name="ODM.oidReference">
<xsl:param name="annos" />
<xsl:variable name="sont" select="$annos/edm:Annotation[not(@Qualifier) and (@Term=$odmOidReference or @Term=$odmOidReferenceAliased)]/edm:Record" />
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved
<xsl:if test="$sont">
<xsl:variable name="name" select="$sont/edm:PropertyValue[@Property='entityName']" />
<xsl:text>,"x-sap-odm-oid-reference-entity-name":"</xsl:text>
<xsl:value-of select="$name/@String|$name/edm:String" />
<xsl:text>"</xsl:text>
</xsl:if>
</xsl:template>

<xsl:template name="ref">
<xsl:param name="qualifier" />
<xsl:param name="name" />
Expand Down Expand Up @@ -3317,6 +3333,7 @@
<xsl:with-param name="node" select="$target" />
</xsl:call-template>
</xsl:variable>

<xsl:variable name="target-path-aliased">
<xsl:call-template name="annotation-target">
<xsl:with-param name="node" select="$target" />
Expand Down
3 changes: 2 additions & 1 deletion tools/tests/annotations.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2856,7 +2856,8 @@
{
"$ref": "#/components/schemas/Supported.Annotations.TwoPartKey"
}
]
],
"x-sap-odm-oid-reference-entity-name": "odmTwo"
},
"AllMany": {
"type": "array",
Expand Down
3 changes: 2 additions & 1 deletion tools/tests/annotations.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,8 @@
]
},
"AllOne": {
"$ref": "#/definitions/Supported.Annotations.TwoPartKey"
"$ref": "#/definitions/Supported.Annotations.TwoPartKey",
"x-sap-odm-oid-reference-entity-name": "odmTwo"
},
"AllMany": {
"type": "array",
Expand Down
8 changes: 8 additions & 0 deletions tools/tests/annotations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,14 @@
<Annotation Term="ODM.oid" PropertyPath="Computed" />
</Annotations>

<Annotations Target="self.SinglePartKey/AllOne">
<Annotation Term="ODM.oidReference">
<Record Type="ODM.oidReferenceType">
<PropertyValue Property="entityName" String="odmTwo" />
</Record>
</Annotation>
</Annotations>

<Annotations Target="self.TwoPartKey/One">
<Annotation Term="Common.SAPObjectNodeTypeReference" String="SontOne" />
</Annotations>
Expand Down