From f2e9b4b5be7c5c2c01a6d796a19e0dbe1e909063 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Thu, 23 Apr 2020 11:13:14 +0200 Subject: [PATCH 1/2] Don't crash if $Partner points to non-existing navigation property (#79) --- lib/csdl2openapi.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/csdl2openapi.js b/lib/csdl2openapi.js index 8b8ecbc2..28ec3c49 100644 --- a/lib/csdl2openapi.js +++ b/lib/csdl2openapi.js @@ -246,7 +246,7 @@ module.exports.csdl2openapi = function ( const targetNP = nameParts(property.$Type || 'Edm.String'); if (property.$Kind == 'NavigationProperty' || targetNP.qualifier != 'Edm') { const target = modelElement(property.$Type); - const bidirectional = property.$Partner && target && target[property.$Partner].$Partner == propertyName; + const bidirectional = property.$Partner && target && target[property.$Partner] && target[property.$Partner].$Partner == propertyName; // Note: if the partner has the same name then it will also be depicted if (!bidirectional || propertyName <= property.$Partner) { diagram += ',[' + typeName + ']' diff --git a/package.json b/package.json index b384aedf..895d23d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "odata-openapi", - "version": "0.5.0", + "version": "0.5.1", "description": "Convert OData CSDL XML or CSDL JSON to OpenAPI", "homepage": "https://github.com/oasis-tcs/odata-openapi/blob/master/lib/README.md", "bugs": "https://github.com/oasis-tcs/odata-openapi/issues", From b382992537349e7bfd10d43f67ebcd169d74b36a Mon Sep 17 00:00:00 2001 From: snebjorn Date: Tue, 28 Apr 2020 10:27:27 +0200 Subject: [PATCH 2/2] feat: adds count property to collection result (#73) * feat: adds count property to collection result fixes #61 * refactor: moved count property into reusable structure * added collNavProp@count to schema Co-authored-by: Ralf Handl --- examples/TripPin.openapi3.json | 71 ++++++++++ examples/annotations.openapi3.json | 62 +++++++++ examples/authorization.openapi3.json | 14 ++ examples/containment.openapi3.json | 71 ++++++++++ examples/csdl-16.1.openapi3.json | 41 ++++++ examples/descriptions.openapi3.json | 17 +++ examples/example.openapi3.json | 53 ++++++++ examples/miscellaneous.openapi3.json | 59 ++++++++ examples/odata-rw-v3.openapi3.json | 56 ++++++++ lib/csdl2openapi.js | 23 +++- test/csdl2openapi.test.js | 21 +++ tools/V4-CSDL-to-OpenAPI.xsl | 26 +++- .../Northwind-key-as-segment.openapi3.json | 128 ++++++++++++++++++ .../Northwind-key-as-segment.swagger.json | 128 ++++++++++++++++++ tools/tests/TripPin.openapi3.json | 59 ++++++++ tools/tests/TripPin.swagger.json | 59 ++++++++ tools/tests/annotations.openapi3.json | 53 ++++++++ tools/tests/annotations.swagger.json | 53 ++++++++ tools/tests/authorization.openapi3.json | 14 ++ tools/tests/authorization.swagger.json | 14 ++ tools/tests/containment.openapi3.json | 56 ++++++++ tools/tests/containment.swagger.json | 56 ++++++++ tools/tests/csdl-16.1.openapi3.json | 35 +++++ tools/tests/csdl-16.1.swagger.json | 35 +++++ tools/tests/descriptions.openapi3.json | 17 +++ tools/tests/descriptions.swagger.json | 17 +++ tools/tests/odata-rw-v2.openapi3.json | 22 +++ tools/tests/odata-rw-v2.swagger.json | 22 +++ tools/tests/odata-rw-v3.openapi3.json | 44 ++++++ tools/tests/odata-rw-v3.swagger.json | 44 ++++++ 30 files changed, 1367 insertions(+), 3 deletions(-) diff --git a/examples/TripPin.openapi3.json b/examples/TripPin.openapi3.json index 7370a06f..e2233a43 100644 --- a/examples/TripPin.openapi3.json +++ b/examples/TripPin.openapi3.json @@ -101,6 +101,9 @@ "type": "object", "title": "Collection of Photo", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -364,6 +367,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -597,6 +603,9 @@ "type": "object", "title": "Collection of Trip", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -784,6 +793,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -953,6 +965,9 @@ "type": "object", "title": "Collection of Trip", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1164,6 +1179,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1275,6 +1293,9 @@ "type": "object", "title": "Collection of Photo", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1395,6 +1416,9 @@ "type": "object", "title": "Collection of PlanItem", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1686,6 +1710,9 @@ "type": "object", "title": "Collection of Airline", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1914,6 +1941,9 @@ "type": "object", "title": "Collection of Airport", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2151,6 +2181,9 @@ "type": "object", "title": "Collection of Trip", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2317,6 +2350,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2476,6 +2512,9 @@ "type": "object", "title": "Collection of Trip", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2669,6 +2708,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2771,6 +2813,9 @@ "type": "object", "title": "Collection of Photo", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2882,6 +2927,9 @@ "type": "object", "title": "Collection of PlanItem", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3492,12 +3540,18 @@ "format": "int64", "example": "42" }, + "Friends@odata.count": { + "$ref": "#/components/schemas/count" + }, "Friends": { "type": "array", "items": { "$ref": "#/components/schemas/Microsoft.OData.SampleService.Models.TripPin.Person" } }, + "Trips@odata.count": { + "$ref": "#/components/schemas/count" + }, "Trips": { "type": "array", "items": { @@ -4191,12 +4245,18 @@ "type": "string" } }, + "Photos@odata.count": { + "$ref": "#/components/schemas/count" + }, "Photos": { "type": "array", "items": { "$ref": "#/components/schemas/Microsoft.OData.SampleService.Models.TripPin.Photo" } }, + "PlanItems@odata.count": { + "$ref": "#/components/schemas/count" + }, "PlanItems": { "type": "array", "items": { @@ -4311,6 +4371,17 @@ } } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": { diff --git a/examples/annotations.openapi3.json b/examples/annotations.openapi3.json index c76d27ea..8c058a96 100644 --- a/examples/annotations.openapi3.json +++ b/examples/annotations.openapi3.json @@ -189,6 +189,9 @@ "type": "object", "title": "Collection of SinglePartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -503,6 +506,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -617,6 +623,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -797,6 +806,9 @@ "type": "object", "title": "Collection of SinglePartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1111,6 +1123,9 @@ "type": "object", "title": "Collection of SinglePartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1301,6 +1316,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1334,6 +1352,9 @@ "type": "object", "title": "Collection of SinglePartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1570,6 +1591,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1662,6 +1686,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1821,6 +1848,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1880,6 +1910,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2005,6 +2038,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2093,6 +2129,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2261,6 +2300,9 @@ "type": "object", "title": "Collection of TwoPartKey", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2653,6 +2695,9 @@ ], "nullable": true }, + "AllMany@count": { + "$ref": "#/components/schemas/count" + }, "AllMany": { "type": "array", "items": { @@ -2667,6 +2712,9 @@ ], "nullable": true }, + "ReadOnlyMany@count": { + "$ref": "#/components/schemas/count" + }, "ReadOnlyMany": { "type": "array", "items": { @@ -2681,6 +2729,9 @@ ], "nullable": true }, + "NothingMany@count": { + "$ref": "#/components/schemas/count" + }, "NothingMany": { "type": "array", "items": { @@ -2999,6 +3050,17 @@ "title": "TwoPartKey (for update)", "type": "object" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/examples/authorization.openapi3.json b/examples/authorization.openapi3.json index 34518b85..597e65b4 100644 --- a/examples/authorization.openapi3.json +++ b/examples/authorization.openapi3.json @@ -89,6 +89,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -309,6 +312,17 @@ } } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/examples/containment.openapi3.json b/examples/containment.openapi3.json index ef7f695c..68c21ef3 100644 --- a/examples/containment.openapi3.json +++ b/examples/containment.openapi3.json @@ -116,6 +116,9 @@ "type": "object", "title": "Collection of Whole", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -730,6 +733,9 @@ "type": "object", "title": "Collection of SubPart", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -992,6 +998,9 @@ "type": "object", "title": "Collection of Part", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1504,6 +1513,9 @@ "type": "object", "title": "Collection of SubPart", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1769,6 +1781,9 @@ "type": "object", "title": "Collection of SubPart", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2297,6 +2312,9 @@ "type": "object", "title": "Collection of SubPart", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2539,6 +2557,9 @@ "type": "object", "title": "Collection of Part", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2985,6 +3006,9 @@ "type": "object", "title": "Collection of SubPart", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3179,6 +3203,9 @@ "type": "object", "title": "Collection of SubPart", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3358,6 +3385,9 @@ "type": "object", "title": "Collection of Folder", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3617,6 +3647,9 @@ "type": "object", "title": "Collection of Folder", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3894,6 +3927,9 @@ "type": "object", "title": "Collection of Folder", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4189,6 +4225,9 @@ "type": "object", "title": "Collection of Folder", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4502,6 +4541,9 @@ "type": "object", "title": "Collection of Folder", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4833,6 +4875,9 @@ "type": "object", "title": "Collection of Folder", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4904,6 +4949,9 @@ ], "nullable": true }, + "Many@count": { + "$ref": "#/components/schemas/count" + }, "Many": { "type": "array", "items": { @@ -4968,18 +5016,27 @@ ], "nullable": true }, + "Many@count": { + "$ref": "#/components/schemas/count" + }, "Many": { "type": "array", "items": { "$ref": "#/components/schemas/Containment.SubPart" } }, + "ManyReadListOnly@count": { + "$ref": "#/components/schemas/count" + }, "ManyReadListOnly": { "type": "array", "items": { "$ref": "#/components/schemas/Containment.SubPart" } }, + "ManyReadByKeyOnly@count": { + "$ref": "#/components/schemas/count" + }, "ManyReadByKeyOnly": { "type": "array", "items": { @@ -5078,6 +5135,9 @@ "type": "string", "nullable": true }, + "Folders@count": { + "$ref": "#/components/schemas/count" + }, "Folders": { "type": "array", "items": { @@ -5118,6 +5178,17 @@ } } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/examples/csdl-16.1.openapi3.json b/examples/csdl-16.1.openapi3.json index 9158ddc8..1315351e 100644 --- a/examples/csdl-16.1.openapi3.json +++ b/examples/csdl-16.1.openapi3.json @@ -136,6 +136,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -534,6 +537,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -812,6 +818,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -967,6 +976,9 @@ "type": "object", "title": "Collection of Supplier", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1300,6 +1312,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1586,6 +1601,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1709,6 +1727,9 @@ "type": "object", "title": "Collection of Country", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1878,6 +1899,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2115,6 +2139,9 @@ "Name": { "type": "string" }, + "Products@count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -2172,6 +2199,9 @@ "type": "integer", "format": "int32" }, + "Products@count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -2361,6 +2391,17 @@ } } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/examples/descriptions.openapi3.json b/examples/descriptions.openapi3.json index 92f3cd75..d9e45cb4 100644 --- a/examples/descriptions.openapi3.json +++ b/examples/descriptions.openapi3.json @@ -99,6 +99,9 @@ "type": "object", "title": "Collection of entity", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -421,6 +424,9 @@ "type": "object", "title": "Collection of entity", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1303,6 +1309,17 @@ "type": "object", "description": "Entity Type - LongDescription" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/examples/example.openapi3.json b/examples/example.openapi3.json index 0c0c9a5f..d52d6589 100644 --- a/examples/example.openapi3.json +++ b/examples/example.openapi3.json @@ -141,6 +141,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -470,6 +473,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -757,6 +763,9 @@ "type": "object", "title": "Collection of ProductDetail", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1145,6 +1154,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1424,6 +1436,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1581,6 +1596,9 @@ "type": "object", "title": "Collection of Supplier", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1863,6 +1881,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2003,6 +2024,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2348,6 +2372,9 @@ "type": "object", "title": "Collection of PersonDetail", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2676,6 +2703,9 @@ "type": "object", "title": "Collection of Advertisement", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3041,6 +3071,9 @@ "format": "double", "example": 3.14 }, + "Categories@odata.count": { + "$ref": "#/components/schemas/count" + }, "Categories": { "type": "array", "items": { @@ -3237,6 +3270,9 @@ "format": "double", "example": 3.14 }, + "Categories@odata.count": { + "$ref": "#/components/schemas/count" + }, "Categories": { "type": "array", "items": { @@ -3457,6 +3493,9 @@ "type": "string", "nullable": true }, + "Products@odata.count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -3530,6 +3569,9 @@ "type": "integer", "format": "int32" }, + "Products@odata.count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -4227,6 +4269,17 @@ "type": "number" } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/examples/miscellaneous.openapi3.json b/examples/miscellaneous.openapi3.json index 15c2cf9e..298b13ab 100644 --- a/examples/miscellaneous.openapi3.json +++ b/examples/miscellaneous.openapi3.json @@ -110,6 +110,9 @@ "type": "object", "title": "Collection of Customer", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -320,6 +323,9 @@ "type": "object", "title": "Collection of Customer", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -530,6 +536,9 @@ "type": "object", "title": "Collection of Order", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -718,6 +727,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -827,6 +839,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1236,6 +1251,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1496,6 +1514,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1677,6 +1698,9 @@ "type": "object", "title": "Collection of Supplier", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1937,6 +1961,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2041,6 +2068,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2300,6 +2330,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2465,6 +2498,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2724,6 +2760,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3225,6 +3264,9 @@ "ID": { "type": "string" }, + "Products@odata.count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -3369,6 +3411,9 @@ "multipleOf": 1, "nullable": true }, + "Employees@odata.count": { + "$ref": "#/components/schemas/count" + }, "Employees": { "type": "array", "items": { @@ -5961,6 +6006,9 @@ "$ref": "#/components/schemas/X.PersonType" } }, + "VIPs@odata.count": { + "$ref": "#/components/schemas/count" + }, "VIPs": { "type": "array", "items": { @@ -6046,6 +6094,17 @@ } } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": { diff --git a/examples/odata-rw-v3.openapi3.json b/examples/odata-rw-v3.openapi3.json index 6b4ef032..02961bcc 100644 --- a/examples/odata-rw-v3.openapi3.json +++ b/examples/odata-rw-v3.openapi3.json @@ -138,6 +138,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -464,6 +467,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -748,6 +754,9 @@ "type": "object", "title": "Collection of ProductDetail", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1133,6 +1142,9 @@ "type": "object", "title": "Collection of Category", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1409,6 +1421,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1563,6 +1578,9 @@ "type": "object", "title": "Collection of Supplier", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1842,6 +1860,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1979,6 +2000,9 @@ "type": "object", "title": "Collection of Person", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2321,6 +2345,9 @@ "type": "object", "title": "Collection of PersonDetail", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2646,6 +2673,9 @@ "type": "object", "title": "Collection of Advertisement", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2914,6 +2944,9 @@ "type": "object", "title": "Collection of Product", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3046,6 +3079,9 @@ "format": "double", "example": 3.14 }, + "Categories@count": { + "$ref": "#/components/schemas/count" + }, "Categories": { "type": "array", "items": { @@ -3242,6 +3278,9 @@ "format": "double", "example": 3.14 }, + "Categories@count": { + "$ref": "#/components/schemas/count" + }, "Categories": { "type": "array", "items": { @@ -3462,6 +3501,9 @@ "type": "string", "nullable": true }, + "Products@count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -3535,6 +3577,9 @@ "type": "integer", "format": "int32" }, + "Products@count": { + "$ref": "#/components/schemas/count" + }, "Products": { "type": "array", "items": { @@ -4206,6 +4251,17 @@ } } }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": { diff --git a/lib/csdl2openapi.js b/lib/csdl2openapi.js index 28ec3c49..80c649c0 100644 --- a/lib/csdl2openapi.js +++ b/lib/csdl2openapi.js @@ -1329,6 +1329,7 @@ module.exports.csdl2openapi = function ( type: 'object', title: 'Collection of ' + nameParts(type.$Type || 'Edm.String').name, properties: { + [csdl.$Version > '4.0' ? '@count' : '@odata.count']: ref('count'), value: s } } @@ -1400,7 +1401,10 @@ module.exports.csdl2openapi = function ( inlineTypes(s); - if (csdl.$EntityContainer) s.error = error(); + if (csdl.$EntityContainer) { + s.count = count(); + s.error = error(); + } return s; } @@ -1496,6 +1500,9 @@ module.exports.csdl2openapi = function ( const property = properties[name]; allProperties[name] = schema(property); if (property.$Kind == 'NavigationProperty') { + if (property.$Collection) { + allProperties[`${name}@${csdl.$Version === '4.0' ? 'odata.' : ''}count`] = ref('count'); + } creProperties[name] = schema(property, '-create'); if (deepUpdate) updProperties[name] = schema(property, '-create'); @@ -1671,6 +1678,20 @@ module.exports.csdl2openapi = function ( return err; } + /** + * Construct OData count response + * @return {object} Count response schema + */ + function count() { + return { + anyOf: [ + { type: 'number' }, + { type: 'string' } + ], + description: 'The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option.', + }; + } + /** * Construct Schema Object for model object referencing a type * @param {object} modelElement referencing a type diff --git a/test/csdl2openapi.test.js b/test/csdl2openapi.test.js index a81703e5..e9316585 100644 --- a/test/csdl2openapi.test.js +++ b/test/csdl2openapi.test.js @@ -468,6 +468,9 @@ describe('Edge cases', function () { type: 'object', title: 'Collection of String', properties: { + '@odata.count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { @@ -522,6 +525,9 @@ describe('Edge cases', function () { } }; const expectedGetResponseProperties = { + '@odata.count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { @@ -578,6 +584,9 @@ describe('Edge cases', function () { type: 'object', title: 'Collection of type_does_not_exist', properties: { + '@odata.count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { @@ -782,6 +791,9 @@ describe('Edge cases', function () { type: 'object', title: 'Collection of derived', properties: { + '@odata.count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { @@ -950,6 +962,9 @@ describe('Edge cases', function () { type: 'object', title: 'Collection of source', properties: { + '@odata.count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { @@ -1104,6 +1119,9 @@ describe('Edge cases', function () { type: 'object', title: 'Collection of Category', properties: { + '@odata.count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { @@ -1298,6 +1316,9 @@ describe('Edge cases', function () { type: 'object', title: 'Collection of thing', properties: { + '@count': { + $ref: '#/components/schemas/count' + }, value: { type: 'array', items: { diff --git a/tools/V4-CSDL-to-OpenAPI.xsl b/tools/V4-CSDL-to-OpenAPI.xsl index fa842f44..c250bdff 100644 --- a/tools/V4-CSDL-to-OpenAPI.xsl +++ b/tools/V4-CSDL-to-OpenAPI.xsl @@ -897,6 +897,16 @@ + "count": + + + {"type":"string","description":"The number of entities in the collection. Available when using the [$inlinecount](https://help.sap.com/doc/5890d27be418427993fafa6722cdc03b/Cloud/en-US/OdataV2.pdf#page=67) query option."} + + + {"anyOf":[{"type":"number"},{"type": "string"}],"description":"The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."} + + + , "geoPoint":{"type":"object","properties":{"type":{"type":"string","enum":["Point"],"default":"Point"},"coordinates":{"$ref":" @@ -1584,7 +1594,13 @@ ", - "type":"object","properties":{"results":{ + "type":"object","properties":{ + + "__count":{"$ref":" + + count"}, + + "results":{ "type":"array","items":{ @@ -4244,7 +4260,13 @@ - value + @ + + odata. + + count":{"$ref":" + + count"},"value ":{ diff --git a/tools/tests/Northwind-key-as-segment.openapi3.json b/tools/tests/Northwind-key-as-segment.openapi3.json index 872e078e..a2f6e7ff 100644 --- a/tools/tests/Northwind-key-as-segment.openapi3.json +++ b/tools/tests/Northwind-key-as-segment.openapi3.json @@ -187,6 +187,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -477,6 +480,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -617,6 +623,9 @@ "title": "Collection of CustomerDemographic", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -907,6 +916,9 @@ "title": "Collection of Customer", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1075,6 +1087,9 @@ "title": "Collection of Customer", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1386,6 +1401,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1539,6 +1557,9 @@ "title": "Collection of CustomerDemographic", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1730,6 +1751,9 @@ "title": "Collection of Employee", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2061,6 +2085,9 @@ "title": "Collection of Employee", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2342,6 +2369,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2499,6 +2529,9 @@ "title": "Collection of Territory", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2649,6 +2682,9 @@ "title": "Collection of Order_Detail", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3140,6 +3176,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3600,6 +3639,9 @@ "title": "Collection of Order_Detail", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3839,6 +3881,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4195,6 +4240,9 @@ "title": "Collection of Order_Detail", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4417,6 +4465,9 @@ "title": "Collection of Region", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4683,6 +4734,9 @@ "title": "Collection of Territory", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4826,6 +4880,9 @@ "title": "Collection of Shipper", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -5128,6 +5185,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -5298,6 +5358,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -5596,6 +5659,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -5740,6 +5806,9 @@ "title": "Collection of Territory", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -6127,6 +6196,9 @@ "title": "Collection of Employee", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -6277,6 +6349,9 @@ "title": "Collection of Alphabetical_list_of_product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -6530,6 +6605,9 @@ "title": "Collection of Category_Sales_for_1997", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -6745,6 +6823,9 @@ "title": "Collection of Current_Product_List", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -6976,6 +7057,9 @@ "title": "Collection of Customer_and_Suppliers_by_City", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -7275,6 +7359,9 @@ "title": "Collection of Invoice", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -7626,6 +7713,9 @@ "title": "Collection of Order_Details_Extended", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -7913,6 +8003,9 @@ "title": "Collection of Order_Subtotal", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -8182,6 +8275,9 @@ "title": "Collection of Orders_Qry", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -8428,6 +8524,9 @@ "title": "Collection of Product_Sales_for_1997", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -8654,6 +8753,9 @@ "title": "Collection of Products_Above_Average_Price", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -8878,6 +8980,9 @@ "title": "Collection of Products_by_Category", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -9121,6 +9226,9 @@ "title": "Collection of Sales_by_Category", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -9364,6 +9472,9 @@ "title": "Collection of Sales_Totals_by_Amount", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -9594,6 +9705,9 @@ "title": "Collection of Summary_of_Sales_by_Quarter", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -9813,6 +9927,9 @@ "title": "Collection of Summary_of_Sales_by_Year", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -13707,6 +13824,17 @@ }, "title": "Summary_of_Sales_by_Year (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/Northwind-key-as-segment.swagger.json b/tools/tests/Northwind-key-as-segment.swagger.json index ead3367a..93a3e8a7 100644 --- a/tools/tests/Northwind-key-as-segment.swagger.json +++ b/tools/tests/Northwind-key-as-segment.swagger.json @@ -180,6 +180,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -435,6 +438,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -555,6 +561,9 @@ "title": "Collection of CustomerDemographic", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -808,6 +817,9 @@ "title": "Collection of Customer", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -956,6 +968,9 @@ "title": "Collection of Customer", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1230,6 +1245,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1360,6 +1378,9 @@ "title": "Collection of CustomerDemographic", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1531,6 +1552,9 @@ "title": "Collection of Employee", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1827,6 +1851,9 @@ "title": "Collection of Employee", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2074,6 +2101,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2209,6 +2239,9 @@ "title": "Collection of Territory", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2339,6 +2372,9 @@ "title": "Collection of Order_Detail", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2767,6 +2803,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3168,6 +3207,9 @@ "title": "Collection of Order_Detail", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3375,6 +3417,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3684,6 +3729,9 @@ "title": "Collection of Order_Detail", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3874,6 +3922,9 @@ "title": "Collection of Region", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4105,6 +4156,9 @@ "title": "Collection of Territory", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4228,6 +4282,9 @@ "title": "Collection of Shipper", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4495,6 +4552,9 @@ "title": "Collection of Order", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4645,6 +4705,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4908,6 +4971,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -5032,6 +5098,9 @@ "title": "Collection of Territory", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -5369,6 +5438,9 @@ "title": "Collection of Employee", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -5502,6 +5574,9 @@ "title": "Collection of Alphabetical_list_of_product", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -5720,6 +5795,9 @@ "title": "Collection of Category_Sales_for_1997", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -5907,6 +5985,9 @@ "title": "Collection of Current_Product_List", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -6108,6 +6189,9 @@ "title": "Collection of Customer_and_Suppliers_by_City", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -6376,6 +6460,9 @@ "title": "Collection of Invoice", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -6660,6 +6747,9 @@ "title": "Collection of Order_Details_Extended", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -6889,6 +6979,9 @@ "title": "Collection of Order_Subtotal", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -7131,6 +7224,9 @@ "title": "Collection of Orders_Qry", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -7347,6 +7443,9 @@ "title": "Collection of Product_Sales_for_1997", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -7542,6 +7641,9 @@ "title": "Collection of Products_Above_Average_Price", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -7738,6 +7840,9 @@ "title": "Collection of Products_by_Category", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -7948,6 +8053,9 @@ "title": "Collection of Sales_by_Category", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -8158,6 +8266,9 @@ "title": "Collection of Sales_Totals_by_Amount", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -8358,6 +8469,9 @@ "title": "Collection of Summary_of_Sales_by_Quarter", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -8550,6 +8664,9 @@ "title": "Collection of Summary_of_Sales_by_Year", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -12944,6 +13061,17 @@ }, "title": "Summary_of_Sales_by_Year (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/TripPin.openapi3.json b/tools/tests/TripPin.openapi3.json index 0dbb81fd..b8a8467d 100644 --- a/tools/tests/TripPin.openapi3.json +++ b/tools/tests/TripPin.openapi3.json @@ -101,6 +101,9 @@ "title": "Collection of Photo", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -358,6 +361,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -591,6 +597,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -772,6 +781,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -941,6 +953,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1152,6 +1167,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1263,6 +1281,9 @@ "title": "Collection of Photo", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1383,6 +1404,9 @@ "title": "Collection of PlanItem", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1674,6 +1698,9 @@ "title": "Collection of Airline", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1894,6 +1921,9 @@ "title": "Collection of Airport", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2133,6 +2163,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2293,6 +2326,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2452,6 +2488,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2645,6 +2684,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2747,6 +2789,9 @@ "title": "Collection of Photo", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2858,6 +2903,9 @@ "title": "Collection of PlanItem", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4305,6 +4353,17 @@ }, "title": "Trip (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": { diff --git a/tools/tests/TripPin.swagger.json b/tools/tests/TripPin.swagger.json index 211c663d..cd8e2960 100644 --- a/tools/tests/TripPin.swagger.json +++ b/tools/tests/TripPin.swagger.json @@ -97,6 +97,9 @@ "title": "Collection of Photo", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -316,6 +319,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -517,6 +523,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -677,6 +686,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -824,6 +836,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1007,6 +1022,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1102,6 +1120,9 @@ "title": "Collection of Photo", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1206,6 +1227,9 @@ "title": "Collection of PlanItem", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1457,6 +1481,9 @@ "title": "Collection of Airline", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1650,6 +1677,9 @@ "title": "Collection of Airport", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1858,6 +1888,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2003,6 +2036,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2142,6 +2178,9 @@ "title": "Collection of Trip", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2311,6 +2350,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2399,6 +2441,9 @@ "title": "Collection of Photo", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2496,6 +2541,9 @@ "title": "Collection of PlanItem", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3926,6 +3974,17 @@ }, "title": "Trip (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": { diff --git a/tools/tests/annotations.openapi3.json b/tools/tests/annotations.openapi3.json index 7c5e6dfd..46847242 100644 --- a/tools/tests/annotations.openapi3.json +++ b/tools/tests/annotations.openapi3.json @@ -189,6 +189,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -503,6 +506,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -621,6 +627,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -801,6 +810,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1115,6 +1127,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1305,6 +1320,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1341,6 +1359,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1576,6 +1597,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1672,6 +1696,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1837,6 +1864,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1900,6 +1930,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2027,6 +2060,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2115,6 +2151,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2286,6 +2325,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3031,6 +3073,17 @@ "type": "object", "title": "TwoPartKey (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/annotations.swagger.json b/tools/tests/annotations.swagger.json index ed377752..63b38e89 100644 --- a/tools/tests/annotations.swagger.json +++ b/tools/tests/annotations.swagger.json @@ -182,6 +182,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -455,6 +458,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -556,6 +562,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -717,6 +726,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -998,6 +1010,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1162,6 +1177,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1194,6 +1212,9 @@ "title": "Collection of SinglePartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1399,6 +1420,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1482,6 +1506,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1624,6 +1651,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1679,6 +1709,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1789,6 +1822,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1865,6 +1901,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2015,6 +2054,9 @@ "title": "Collection of TwoPartKey", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2724,6 +2766,17 @@ "type": "object", "title": "TwoPartKey (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/authorization.openapi3.json b/tools/tests/authorization.openapi3.json index 51a9b20f..5ed0a848 100644 --- a/tools/tests/authorization.openapi3.json +++ b/tools/tests/authorization.openapi3.json @@ -89,6 +89,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -309,6 +312,17 @@ }, "title": "Person (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/authorization.swagger.json b/tools/tests/authorization.swagger.json index 94454678..d27e7eea 100644 --- a/tools/tests/authorization.swagger.json +++ b/tools/tests/authorization.swagger.json @@ -85,6 +85,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@odata.count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -297,6 +300,17 @@ }, "title": "Person (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/containment.openapi3.json b/tools/tests/containment.openapi3.json index 2147409e..7b64be60 100644 --- a/tools/tests/containment.openapi3.json +++ b/tools/tests/containment.openapi3.json @@ -116,6 +116,9 @@ "title": "Collection of Whole", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -732,6 +735,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -994,6 +1000,9 @@ "title": "Collection of Part", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1506,6 +1515,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1771,6 +1783,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2305,6 +2320,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2547,6 +2565,9 @@ "title": "Collection of Part", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2995,6 +3016,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3190,6 +3214,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3370,6 +3397,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3629,6 +3659,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -3906,6 +3939,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4201,6 +4237,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4514,6 +4553,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4845,6 +4887,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -5130,6 +5175,17 @@ }, "title": "Folder (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/containment.swagger.json b/tools/tests/containment.swagger.json index e480abac..bf955a4d 100644 --- a/tools/tests/containment.swagger.json +++ b/tools/tests/containment.swagger.json @@ -109,6 +109,9 @@ "title": "Collection of Whole", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -659,6 +662,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -885,6 +891,9 @@ "title": "Collection of Part", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1333,6 +1342,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1561,6 +1573,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2039,6 +2054,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2249,6 +2267,9 @@ "title": "Collection of Part", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2650,6 +2671,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2820,6 +2844,9 @@ "title": "Collection of SubPart", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2973,6 +3000,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3197,6 +3227,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3435,6 +3468,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3687,6 +3723,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3953,6 +3992,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4233,6 +4275,9 @@ "title": "Collection of Folder", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -4508,6 +4553,17 @@ }, "title": "Folder (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/csdl-16.1.openapi3.json b/tools/tests/csdl-16.1.openapi3.json index 9e2cbbd9..4999fd80 100644 --- a/tools/tests/csdl-16.1.openapi3.json +++ b/tools/tests/csdl-16.1.openapi3.json @@ -136,6 +136,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -533,6 +536,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -811,6 +817,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -957,6 +966,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1235,6 +1247,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1478,6 +1493,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1601,6 +1619,9 @@ "title": "Collection of Country", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1770,6 +1791,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2253,6 +2277,17 @@ }, "title": "Address (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/csdl-16.1.swagger.json b/tools/tests/csdl-16.1.swagger.json index 9cd603c9..4ad5abe9 100644 --- a/tools/tests/csdl-16.1.swagger.json +++ b/tools/tests/csdl-16.1.swagger.json @@ -129,6 +129,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -469,6 +472,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -712,6 +718,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -838,6 +847,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1081,6 +1093,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1293,6 +1308,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1399,6 +1417,9 @@ "title": "Collection of Country", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1545,6 +1566,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2093,6 +2117,17 @@ }, "title": "Address (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/descriptions.openapi3.json b/tools/tests/descriptions.openapi3.json index 5fb8ae2f..7d297a9f 100644 --- a/tools/tests/descriptions.openapi3.json +++ b/tools/tests/descriptions.openapi3.json @@ -100,6 +100,9 @@ "title": "Collection of entity", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -422,6 +425,9 @@ "title": "Collection of entity", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1269,6 +1275,17 @@ }, "components": { "schemas": { + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/descriptions.swagger.json b/tools/tests/descriptions.swagger.json index a1621c6f..fea10f16 100644 --- a/tools/tests/descriptions.swagger.json +++ b/tools/tests/descriptions.swagger.json @@ -96,6 +96,9 @@ "title": "Collection of entity", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -380,6 +383,9 @@ "title": "Collection of entity", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1173,6 +1179,17 @@ } }, "definitions": { + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/odata-rw-v2.openapi3.json b/tools/tests/odata-rw-v2.openapi3.json index 9009aff5..9873b615 100644 --- a/tools/tests/odata-rw-v2.openapi3.json +++ b/tools/tests/odata-rw-v2.openapi3.json @@ -130,6 +130,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/components/schemas/count" + }, "results": { "type": "array", "items": { @@ -565,6 +568,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "__count": { + "$ref": "#/components/schemas/count" + }, "results": { "type": "array", "items": { @@ -865,6 +871,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/components/schemas/count" + }, "results": { "type": "array", "items": { @@ -1020,6 +1029,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "__count": { + "$ref": "#/components/schemas/count" + }, "results": { "type": "array", "items": { @@ -1322,6 +1334,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/components/schemas/count" + }, "results": { "type": "array", "items": { @@ -1410,6 +1425,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/components/schemas/count" + }, "results": { "type": "array", "items": { @@ -1836,6 +1854,10 @@ }, "title": "Address (for update)" }, + "count": { + "type": "string", + "description": "The number of entities in the collection. Available when using the [$inlinecount](https://help.sap.com/doc/5890d27be418427993fafa6722cdc03b/Cloud/en-US/OdataV2.pdf#page=67) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/odata-rw-v2.swagger.json b/tools/tests/odata-rw-v2.swagger.json index ffbbc29c..89cb479d 100644 --- a/tools/tests/odata-rw-v2.swagger.json +++ b/tools/tests/odata-rw-v2.swagger.json @@ -123,6 +123,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/definitions/count" + }, "results": { "type": "array", "items": { @@ -501,6 +504,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "__count": { + "$ref": "#/definitions/count" + }, "results": { "type": "array", "items": { @@ -766,6 +772,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/definitions/count" + }, "results": { "type": "array", "items": { @@ -901,6 +910,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "__count": { + "$ref": "#/definitions/count" + }, "results": { "type": "array", "items": { @@ -1168,6 +1180,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/definitions/count" + }, "results": { "type": "array", "items": { @@ -1245,6 +1260,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "__count": { + "$ref": "#/definitions/count" + }, "results": { "type": "array", "items": { @@ -1736,6 +1754,10 @@ }, "title": "Address (for update)" }, + "count": { + "type": "string", + "description": "The number of entities in the collection. Available when using the [$inlinecount](https://help.sap.com/doc/5890d27be418427993fafa6722cdc03b/Cloud/en-US/OdataV2.pdf#page=67) query option." + }, "error": { "type": "object", "required": [ diff --git a/tools/tests/odata-rw-v3.openapi3.json b/tools/tests/odata-rw-v3.openapi3.json index dbbfce90..8e8e7183 100644 --- a/tools/tests/odata-rw-v3.openapi3.json +++ b/tools/tests/odata-rw-v3.openapi3.json @@ -138,6 +138,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -464,6 +467,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -748,6 +754,9 @@ "title": "Collection of ProductDetail", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1133,6 +1142,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1409,6 +1421,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1555,6 +1570,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1834,6 +1852,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -1971,6 +1992,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2305,6 +2329,9 @@ "title": "Collection of PersonDetail", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2630,6 +2657,9 @@ "title": "Collection of Advertisement", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -2873,6 +2903,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/components/schemas/count" + }, "value": { "type": "array", "items": { @@ -4177,6 +4210,17 @@ }, "title": "Advertisement (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": { diff --git a/tools/tests/odata-rw-v3.swagger.json b/tools/tests/odata-rw-v3.swagger.json index f1ab81db..3df0ed02 100644 --- a/tools/tests/odata-rw-v3.swagger.json +++ b/tools/tests/odata-rw-v3.swagger.json @@ -131,6 +131,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -410,6 +413,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -650,6 +656,9 @@ "title": "Collection of ProductDetail", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -978,6 +987,9 @@ "title": "Collection of Category", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1219,6 +1231,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1345,6 +1360,9 @@ "title": "Collection of Supplier", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1589,6 +1607,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1706,6 +1727,9 @@ "title": "Collection of Person", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -1995,6 +2019,9 @@ "title": "Collection of PersonDetail", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2275,6 +2302,9 @@ "title": "Collection of Advertisement", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -2481,6 +2511,9 @@ "title": "Collection of Product", "type": "object", "properties": { + "@count": { + "$ref": "#/definitions/count" + }, "value": { "type": "array", "items": { @@ -3676,6 +3709,17 @@ }, "title": "Advertisement (for update)" }, + "count": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "string" + } + ], + "description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option." + }, "geoPoint": { "type": "object", "properties": {