Skip to content

Commit

Permalink
FieldControl=Mandatory does not mean required during create
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Nov 29, 2024
1 parent cbfb3a4 commit 8ef8f65
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
16 changes: 3 additions & 13 deletions tools/V4-CSDL-to-OpenAPI.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@

<xsl:variable name="commonNamespace" select="'com.sap.vocabularies.Common.v1'" />
<xsl:variable name="commonAlias" select="/edmx:Edmx/edmx:Reference/edmx:Include[@Namespace=$commonNamespace]/@Alias" />
<xsl:variable name="commonFieldControl" select="concat($commonNamespace,'.FieldControl')" />
<xsl:variable name="commonFieldControlAliased" select="concat($commonAlias,'.FieldControl')" />
<xsl:variable name="commonFieldControlMandatory" select="concat($commonNamespace,'.FieldControlType/Mandatory')" />
<xsl:variable name="commonFieldControlMandatoryAliased" select="concat($commonAlias,'.FieldControlType/Mandatory')" />
<xsl:variable name="commonLabel" select="concat($commonNamespace,'.Label')" />
<xsl:variable name="commonLabelAliased" select="concat($commonAlias,'.Label')" />
<xsl:variable name="commonQuickInfo" select="concat($commonNamespace,'.QuickInfo')" />
Expand Down Expand Up @@ -1508,11 +1504,6 @@
/edm:EnumMember[.=$corePermissionRead or .=$corePermissionReadAliased]]/@Name" />
<!-- TODO: also nested annotations -->
<!-- TODO: also edm:EnumMember -->
<xsl:variable name="mandatory" select="(key('externalPropertyAnnotations',$qualifiedName)|key('externalPropertyAnnotations',$aliasQualifiedName))
[edm:Annotation[(@Term=$commonFieldControl or @Term=$commonFieldControlAliased)
and (@EnumMember=$commonFieldControlMandatory or @EnumMember=$commonFieldControlMandatoryAliased)]]/@Target" />
<!-- TODO: also nested annotations -->
<!-- TODO: also edm:EnumMember -->
<xsl:variable name="navprop-read-only" select="(key('externalPropertyAnnotations',$qualifiedName)|key('externalPropertyAnnotations',$aliasQualifiedName))
[edm:Annotation[(@Term=$corePermissions or @Term=$corePermissionsAliased)
and (@EnumMember=$corePermissionRead or @EnumMember=$corePermissionReadAliased)]]/@Target" />
Expand Down Expand Up @@ -1561,12 +1552,11 @@
</xsl:variable>
<xsl:variable name="required">
<xsl:if test="$suffix='-create'">
<!-- non-computed key properties are required, as are properties marked with Common.FieldControl=Mandatory -->
<!-- non-computed key properties are required -->
<xsl:for-each select="$structuredType/edm:Property[
(@Name=../edm:Key/edm:PropertyRef/@Name and not(@Name=$read-only
@Name=../edm:Key/edm:PropertyRef/@Name and not(@Name=$read-only
or @Name=$computed or concat($qualifiedName,'/',@Name) = $computed-ext or concat($aliasQualifiedName,'/',@Name) = $computed-ext
or @Name=$computeddefaultvalue or concat($qualifiedName,'/',@Name) = $computeddefaultvalue-ext or concat($aliasQualifiedName,'/',@Name) = $computeddefaultvalue-ext))
or concat($qualifiedName,'/',@Name)=$mandatory or concat($aliasQualifiedName,'/',@Name)=$mandatory]">
or @Name=$computeddefaultvalue or concat($qualifiedName,'/',@Name) = $computeddefaultvalue-ext or concat($aliasQualifiedName,'/',@Name) = $computeddefaultvalue-ext)]">
<xsl:if test="position()>1">
<xsl:text>,</xsl:text>
</xsl:if>
Expand Down
4 changes: 1 addition & 3 deletions tools/tests/annotations.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3134,9 +3134,7 @@
}
},
"required": [
"ID",
"PatternExt",
"AllowedValuesExt"
"ID"
],
"title": "SinglePartKey (for create)"
},
Expand Down
4 changes: 1 addition & 3 deletions tools/tests/annotations.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2783,9 +2783,7 @@
}
},
"required": [
"ID",
"PatternExt",
"AllowedValuesExt"
"ID"
],
"title": "SinglePartKey (for create)"
},
Expand Down

0 comments on commit 8ef8f65

Please sign in to comment.