Skip to content

Conversation

@HeikoTheissen
Copy link
Contributor

@HeikoTheissen HeikoTheissen commented Jun 12, 2025

In the service tools/tests/ServiceQuotation.xml, the property ServiceQuotationType is required during a POST /ServiceQuotation:

<Annotation Term="SAP__capabilities.InsertRestrictions">
<Record>
<PropertyValue Property="RequiredProperties">
<Collection>
<PropertyPath>ServiceQuotationType</PropertyPath>
</Collection>
</PropertyValue>
</Record>
</Annotation>

But the XSLT tool for OpenAPI generation does not currently consider this Capabilities.InsertRestrictions/RequiredProperties annotation when it generates the *-create schema, since the annotation targets the entity set but the schema is generated per entity type.

This PR contains a simplified version of the treatment of this annotation, which looks at all entity sets for the given entity type. It leads to the following Swagger UI. It does not yet consider paths of the form EntitySet/NavigationProperty that might also have the entity type.

The full treatment is implemented in the much bigger PR #291:

<xsl:variable name="required">
<xsl:variable name="navigation-restrictions" select="//edm:Annotation[not(@Qualifier) and
@p2:Term='Org.OData.Capabilities.V1.NavigationRestrictions']
/edm:Record/edm:PropertyValue[@Property='RestrictedProperties']/edm:Collection
/edm:Record[edm:PropertyValue[@Property='NavigationProperty' and key('id',@p1:NavigationPropertyPath)/@p1:Type=$structuredType/@id]]" />
<xsl:if test="$suffix='-create'">
<!-- non-computed key properties are required, as are Capabilities.InsertRestrictions/RequiredProperties -->
<xsl:for-each select="$structuredType/edm:Property[
@Name=../edm:Key/edm:PropertyRef/@Name and not(@id=//edm:Annotation[not(@Qualifier) and
@p2:Term='Org.OData.Core.V1.Computed' and not(@Bool='false') or
@p2:Term='Org.OData.Core.V1.ComputedDefaultValue' and not(@Bool='false') or
@p2:Term='Org.OData.Core.V1.Permissions' and @p2:EnumMember='Org.OData.Core.V1.Permission/Read' or
@p2:Term='com.sap.vocabularies.Common.v1.FieldControl' and @p2:EnumMember='com.sap.vocabularies.Common.v1.FieldControlType/ReadOnly']/@target) or
@Name=$navigation-restrictions/edm:PropertyValue[@Property='InsertRestrictions']
/edm:Record/edm:PropertyValue[@Property='RequiredProperties']/edm:Collection/edm:PropertyPath or
not($navigation-restrictions/edm:PropertyValue[@Property='InsertRestrictions']) and
@Name=//edm:Annotation[not(@Qualifier) and @p2:Term='Org.OData.Capabilities.V1.InsertRestrictions' and
key('id',@target)/@p1:Type=$structuredType/@id]
/edm:Record/edm:PropertyValue[@Property='RequiredProperties']/edm:Collection/edm:PropertyPath]">

@HeikoTheissen
Copy link
Contributor Author

Solved with #342

@HeikoTheissen HeikoTheissen deleted the csdl2openapi/insert-required branch December 16, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants