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

Resolve paths in CSDL XML documents #291

Draft
wants to merge 70 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
95b8d90
First test
HeikoTheissen Apr 12, 2024
6992c47
Separation of non-final and final segments
HeikoTheissen Apr 12, 2024
4611d82
Edmx version
HeikoTheissen Apr 12, 2024
e59fc2f
indentation
HeikoTheissen Apr 12, 2024
c2f5707
Merge branch 'main' into resolve-paths
HeikoTheissen Apr 12, 2024
eb61cc8
namespaces for non-final and final segments
HeikoTheissen Apr 12, 2024
eb7913c
External targeting
HeikoTheissen Apr 12, 2024
c9d2c42
Immutability example
HeikoTheissen Apr 12, 2024
f1d671f
external targeting 2
HeikoTheissen Apr 15, 2024
994f428
NavigationPropertyBinding
HeikoTheissen Apr 15, 2024
4e28656
outermost
HeikoTheissen Apr 15, 2024
92f9d8e
API_SalesOrder example
HeikoTheissen Apr 15, 2024
4b9dc8a
API_SalesOrder OpenAPI
HeikoTheissen Apr 15, 2024
9e777ff
move file
HeikoTheissen Apr 15, 2024
6b2c5b8
First round of testing
HeikoTheissen Apr 15, 2024
f78b494
Align syntax with ABAP XSLT
HeikoTheissen Apr 15, 2024
f0cb37d
mode="ids"
HeikoTheissen Apr 15, 2024
d64ebeb
$ReturnType
HeikoTheissen Apr 16, 2024
4724f00
mode="path-remainder"
HeikoTheissen Apr 16, 2024
170c42d
<xsl:template match="*" mode="path">
HeikoTheissen Apr 16, 2024
6f8d7c2
ids everywhere
HeikoTheissen Apr 16, 2024
dd52f8e
test="self::*"
HeikoTheissen Apr 16, 2024
414edde
corrected p1:Type
HeikoTheissen Apr 16, 2024
1e3fb40
more robust
HeikoTheissen Apr 16, 2024
28a33a6
absolute paths
HeikoTheissen Apr 16, 2024
8ac3b6c
No support for function overload paths
HeikoTheissen Apr 16, 2024
8dba89b
DTD
HeikoTheissen Apr 17, 2024
87acf77
ID
HeikoTheissen Apr 17, 2024
3dda9d8
More paths
HeikoTheissen Apr 18, 2024
9910976
Abolish xsl:text
HeikoTheissen Apr 18, 2024
894d296
Merge branch 'main' into resolve-paths
HeikoTheissen Apr 18, 2024
fbc42c9
Rudimentary treatment of term casts
HeikoTheissen Apr 18, 2024
545ecba
Abolish qname prefix
HeikoTheissen Apr 18, 2024
0834067
Term cast example
HeikoTheissen Apr 18, 2024
f6b2bf5
Overloads
HeikoTheissen Apr 18, 2024
937422f
Overloads with collections
HeikoTheissen Apr 19, 2024
6419560
Don't work around https://saxonica.plan.io/issues/6393
HeikoTheissen Apr 24, 2024
51871a9
Merge branch 'main' into resolve-paths
HeikoTheissen Apr 24, 2024
3b81ddb
transform.cmd
HeikoTheissen Apr 25, 2024
083ee0f
Smaller example
HeikoTheissen Apr 25, 2024
9421df9
Merge branch 'main' into resolve-paths
HeikoTheissen Apr 25, 2024
61b0c1a
Report path syntax errors
HeikoTheissen Apr 25, 2024
129fa10
Correct id in error message
HeikoTheissen Apr 25, 2024
7709c1b
Qualified name checker
HeikoTheissen Apr 25, 2024
6dc4c14
Allow Collection(Edm.*)
HeikoTheissen May 2, 2024
575021b
2.0 output
HeikoTheissen May 2, 2024
1ab68c2
No redundantly resolved targets
HeikoTheissen May 6, 2024
eb0e430
empty paths
HeikoTheissen May 7, 2024
50f7d54
simplified patterns
HeikoTheissen May 7, 2024
8755f9d
quotes
HeikoTheissen May 7, 2024
ab10f5b
Inline literals to attributes
HeikoTheissen May 28, 2024
5a7bb8e
correction
HeikoTheissen May 28, 2024
eabca61
EnumMember
HeikoTheissen Nov 27, 2024
3237a21
Cleaned up `<xsl:template name="properties">`
HeikoTheissen Nov 28, 2024
15c53f7
Merge branch 'main' into resolve-paths
HeikoTheissen Nov 29, 2024
31b8315
More clean-up
HeikoTheissen Nov 29, 2024
7a28882
Capabilities
HeikoTheissen Dec 2, 2024
22ec250
pathItem templates
HeikoTheissen Dec 4, 2024
aefcc7b
clean-up
HeikoTheissen Dec 11, 2024
e738b40
Solution to #320
HeikoTheissen Dec 11, 2024
07850ab
with-sort
HeikoTheissen Dec 12, 2024
3c0e7b2
BatchSupported
HeikoTheissen Dec 13, 2024
d808b6f
NoNavigationSet
HeikoTheissen Dec 13, 2024
d4f7bf5
typo
HeikoTheissen Dec 13, 2024
01023e4
Sortable
HeikoTheissen Dec 13, 2024
e02a484
NonSortableProperties
HeikoTheissen Dec 13, 2024
8563e1c
path-to-target
HeikoTheissen Dec 16, 2024
7f0c380
target-path
HeikoTheissen Dec 16, 2024
e8742bd
clean-up
HeikoTheissen Dec 17, 2024
7fb4010
Use `$navigation-restrictions` where possible
HeikoTheissen Dec 19, 2024
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
19 changes: 13 additions & 6 deletions tools/V4-CSDL-to-OpenAPI.xsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm"
xmlns:qname="http://docs.oasis-open.org/odata/ns/edm/qname"
xmlns:p0="http://docs.oasis-open.org/odata/ns/edm/non-final-segments"
xmlns:p1="http://docs.oasis-open.org/odata/ns/edm/final-segment">

<!--
This style sheet transforms OData 4.0 CSDL XML documents into OpenAPI 2.0 or OpenAPI 3.0.0 JSON

Expand Down Expand Up @@ -1529,8 +1533,11 @@
<xsl:choose>
<xsl:when test="$suffix='-update'">
<!-- only updatable non-key properties -->
<xsl:for-each select="$structuredType/edm:Property[not(@Name=$immutable or concat($qualifiedName,'/',@Name) = $immutable-ext or concat($aliasQualifiedName,'/',@Name) = $immutable-ext
or @Name=$computed or concat($qualifiedName,'/',@Name) = $computed-ext or concat($aliasQualifiedName,'/',@Name) = $computed-ext
<xsl:for-each select="$structuredType/edm:Property[not(
@id=//edm:Annotation[@qname:Term='Org.OData.Core.V1.Immutable']/@target
and not(@id=//edm:Annotation[@qname:Term='Org.OData.Measures.V1.Unit'
or @qname:Term='Org.OData.Measures.V1.ISOCurrency']//@p1:*)
or @id=//edm:Annotation[@qname:Term='Org.OData.Core.V1.Computed']/@target
or @Name=$read-only or @Name=../edm:Key/edm:PropertyRef/@Name)]">
<xsl:call-template name="property">
<xsl:with-param name="suffix" select="'-update'" />
Expand Down Expand Up @@ -1840,7 +1847,7 @@
<xsl:text>,"x-sap-precision":</xsl:text>
<xsl:value-of select="$target/@Precision" />
</xsl:if>
<xsl:if test="number($target/@Scale)=$target/@Scale">
<xsl:if test="$target/@Scale!='floating' and $target/@Scale!='variable' and number($target/@Scale)=$target/@Scale">
HeikoTheissen marked this conversation as resolved.
Show resolved Hide resolved
<xsl:text>,"x-sap-scale":</xsl:text>
<xsl:value-of select="$target/@Scale" />
</xsl:if>
Expand All @@ -1850,14 +1857,14 @@
<xsl:when test="not($target/@Scale) or $target/@Scale='0'">
<xsl:text>,"multipleOf":1</xsl:text>
</xsl:when>
<xsl:when test="number($target/@Scale)=$target/@Scale">
<xsl:when test="$target/@Scale!='floating' and $target/@Scale!='variable' and number($target/@Scale)=$target/@Scale">
<xsl:text>,"multipleOf":1.0e-</xsl:text>
<xsl:value-of select="$target/@Scale" />
</xsl:when>
</xsl:choose>
<xsl:variable name="scale">
<xsl:choose>
<xsl:when test="number($target/@Scale)=$target/@Scale">
<xsl:when test="$target/@Scale!='floating' and $target/@Scale!='variable' and number($target/@Scale)=$target/@Scale">
<xsl:value-of select="$target/@Scale" />
</xsl:when>
<xsl:otherwise>
Expand Down
Loading