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

ODATA-1571: Allow empty EntityContainer #82

Merged
merged 4 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand Down
9 changes: 9 additions & 0 deletions examples/empty-container.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$Version": "4.01",
"org.example": {
"Empty": {
"$Kind": "EntityContainer"
}
},
"$EntityContainer": "org.example.Empty"
}
8 changes: 8 additions & 0 deletions examples/empty-container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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="org.example">
<EntityContainer Name="Empty" />
</Schema>
</edmx:DataServices>
</edmx:Edmx>
28 changes: 7 additions & 21 deletions schemas/edm.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -520,27 +520,13 @@
container constructs
-->
<xs:complexType name="TEntityContainer">
<xs:sequence>
<xs:element ref="edm:Annotation" minOccurs="0" maxOccurs="unbounded" />
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:sequence>
<xs:element name="EntitySet" type="edm:TEntitySet" />
<xs:element ref="edm:Annotation" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:sequence>
<xs:element name="ActionImport" type="edm:TActionImport" />
<xs:element ref="edm:Annotation" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:sequence>
<xs:element name="FunctionImport" type="edm:TFunctionImport" />
<xs:element ref="edm:Annotation" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:sequence>
<xs:element name="Singleton" type="edm:TSingleton" />
<xs:element ref="edm:Annotation" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:choice>
</xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="EntitySet" type="edm:TEntitySet" />
<xs:element name="ActionImport" type="edm:TActionImport" />
<xs:element name="FunctionImport" type="edm:TFunctionImport" />
<xs:element name="Singleton" type="edm:TSingleton" />
<xs:element ref="edm:Annotation" />
</xs:choice>
<xs:attribute name="Name" type="edm:TSimpleIdentifier" use="required" />
<xs:attribute name="Extends" type="edm:TQualifiedName" use="optional" />
</xs:complexType>
Expand Down
7 changes: 7 additions & 0 deletions test/xml2json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const result8 = require("./ReferentialConstraint-v2.json");
const example9 = fs.readFileSync("test/documentation-v2.xml");
const result9 = require("./documentation-v2.json");

const example10 = fs.readFileSync("examples/empty-container.xml");
const result10 = require("../examples/empty-container.json");

describe("Examples", function () {
it("csdl-16.1", function () {
assert.deepStrictEqual(csdl.xml2json(example1), result1, "CSDL JSON");
Expand Down Expand Up @@ -77,6 +80,10 @@ describe("Examples", function () {
assert.deepStrictEqual(csdl.xml2json(example9), result9, "CSDL JSON");
});

it("empty-container", function () {
assert.deepStrictEqual(csdl.xml2json(example10), result10, "CSDL JSON");
});

it("empty <String> element", function () {
const xml = `<Edmx Version="4.01" xmlns="http://docs.oasis-open.org/odata/ns/edmx"><DataServices><Schema Namespace="n" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="String.NoBody"><String/></Annotation>
Expand Down