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

Wrong JSON representation of empty complex <Annotation> #75

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions examples/absent-record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$Version": "4.01",
"foo": {
"bar": {
"$Kind": "Term",
"$Type": "foo.record",
"$Nullable": true
},
"record": {
"$Kind": "ComplexType",
"@foo.bar#WithRecord": {},
"@foo.bar#WithoutRecord": true
Comment on lines +11 to +12
Copy link
Contributor Author

@HeikoTheissen HeikoTheissen Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default annotation value in JSON depends on whether a <Record> was present in XML.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. We use Boolean tagging annotations (typically with Type="Core.Tag" DefaultValue="true") a lot, and the code is optimized for this.

This can only be improved if the term definition is read from the referenced vocabulary, which is currently not the case.

}
}
}
14 changes: 14 additions & 0 deletions examples/absent-record.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns="http://docs.oasis-open.org/odata/ns/edm" Version="4.01">
<edmx:DataServices>
<Schema Namespace="foo">
<Term Name="bar" Type="foo.record"/>
<ComplexType Name="record">
<Annotation Term="foo.bar" Qualifier="WithRecord">
<Record/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omitting this empty <Record> should make no difference.

</Annotation>
<Annotation Term="foo.bar" Qualifier="WithoutRecord"/>
</ComplexType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>