From b4aad37338ad68a80de8372d97aaf8c586d23d54 Mon Sep 17 00:00:00 2001 From: Chris Lloyd Date: Fri, 22 Mar 2024 12:17:38 +0000 Subject: [PATCH] WIP --- .../MultiModelTest__test_multi__1.xml | 4 + .../MultiModelTest__test_multi__3.json | 16 + .../MultiModelTest__test_multi__4.json | 372 ++++++++++++++++++ 3 files changed, 392 insertions(+) diff --git a/tests/__snapshots__/Operation/MultiModelTest__test_multi__1.xml b/tests/__snapshots__/Operation/MultiModelTest__test_multi__1.xml index b10e3ffd2..5986b17a1 100644 --- a/tests/__snapshots__/Operation/MultiModelTest__test_multi__1.xml +++ b/tests/__snapshots__/Operation/MultiModelTest__test_multi__1.xml @@ -10,6 +10,7 @@ + @@ -73,6 +74,7 @@ + @@ -143,6 +145,7 @@ + @@ -151,6 +154,7 @@ + diff --git a/tests/__snapshots__/Operation/MultiModelTest__test_multi__3.json b/tests/__snapshots__/Operation/MultiModelTest__test_multi__3.json index d2589a064..173858740 100644 --- a/tests/__snapshots__/Operation/MultiModelTest__test_multi__3.json +++ b/tests/__snapshots__/Operation/MultiModelTest__test_multi__3.json @@ -21,6 +21,9 @@ "$Kind": "EntityContainer", "Users": { "$EntityType": "com.example.odata.User", + "$NavigationPropertyBinding": { + "orders": "Orders" + }, "@Org.OData.Capabilities.V1.CountRestrictions": { "Countable": true }, @@ -65,6 +68,9 @@ }, "Orders": { "$EntityType": "com.example.odata.Order", + "$NavigationPropertyBinding": { + "user": "Users" + }, "@Org.OData.Capabilities.V1.CountRestrictions": { "Countable": true }, @@ -154,6 +160,11 @@ "$Type": "Edm.Int64", "$Nullable": false, "@Org.OData.Core.V1.Computed": true + }, + "orders": { + "$Collection": true, + "$Type": "com.example.odata.Order", + "$Nullable": true } }, "Order": { @@ -165,6 +176,11 @@ "$Type": "Edm.Int64", "$Nullable": false, "@Org.OData.Core.V1.Computed": true + }, + "user": { + "$Collection": false, + "$Type": "com.example.odata.User", + "$Nullable": true } }, "function1": { diff --git a/tests/__snapshots__/Operation/MultiModelTest__test_multi__4.json b/tests/__snapshots__/Operation/MultiModelTest__test_multi__4.json index f0f546203..e6c56df92 100644 --- a/tests/__snapshots__/Operation/MultiModelTest__test_multi__4.json +++ b/tests/__snapshots__/Operation/MultiModelTest__test_multi__4.json @@ -46,6 +46,22 @@ { "$ref": "#/components/parameters/count" }, + { + "name": "expand", + "in": "query", + "description": "Expand related entities, see [OData Expand](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionexpand)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "orders" + ] + } + } + }, { "$ref": "#/components/parameters/filter" }, @@ -178,6 +194,22 @@ ] } } + }, + { + "name": "expand", + "in": "query", + "description": "Expand related entities, see [OData Expand](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionexpand)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "orders" + ] + } + } } ], "responses": { @@ -246,6 +278,160 @@ } } }, + "/Users/{id}/orders": { + "parameters": [ + { + "description": "Key: id", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": -9223372036854775808, + "maximum": 9223372036854775807, + "nullable": false + } + } + ], + "get": { + "summary": "Get entities from related Orders", + "tags": [ + "Orders", + "Users" + ], + "parameters": [ + { + "name": "select", + "in": "query", + "description": "Select properties to be returned, see [OData Select](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionselect)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "*", + "id" + ] + } + } + }, + { + "$ref": "#/components/parameters/count" + }, + { + "name": "expand", + "in": "query", + "description": "Expand related entities, see [OData Expand](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionexpand)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "user" + ] + } + } + }, + { + "$ref": "#/components/parameters/filter" + }, + { + "$ref": "#/components/parameters/search" + }, + { + "$ref": "#/components/parameters/top" + }, + { + "$ref": "#/components/parameters/skip" + }, + { + "name": "orderby", + "in": "query", + "description": "Order items by property values, see [OData Sorting](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionorderby)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "id", + "id desc" + ] + } + } + } + ], + "responses": { + "200": { + "description": "Retrieved entities", + "content": { + "application/json": { + "schema": { + "type": "object", + "title": "Collection of Orders", + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/components/schemas/com.example.odata.Order" + } + }, + "@count": { + "$ref": "#/components/schemas/count" + } + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/error" + } + } + }, + "post": { + "summary": "Add new entity to related Orders", + "tags": [ + "Orders", + "Users" + ], + "requestBody": { + "required": true, + "description": "New entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/com.example.odata.Order-create" + } + } + } + }, + "responses": { + "201": { + "description": "Created entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/com.example.odata.Order" + } + } + } + }, + "204": { + "description": "Success" + }, + "4XX": { + "$ref": "#/components/responses/error" + } + } + } + }, "/Orders": { "get": { "summary": "Get entities from Orders", @@ -273,6 +459,22 @@ { "$ref": "#/components/parameters/count" }, + { + "name": "expand", + "in": "query", + "description": "Expand related entities, see [OData Expand](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionexpand)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "user" + ] + } + } + }, { "$ref": "#/components/parameters/filter" }, @@ -405,6 +607,22 @@ ] } } + }, + { + "name": "expand", + "in": "query", + "description": "Expand related entities, see [OData Expand](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionexpand)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "user" + ] + } + } } ], "responses": { @@ -473,6 +691,160 @@ } } }, + "/Orders/{id}/user": { + "parameters": [ + { + "description": "Key: id", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": -9223372036854775808, + "maximum": 9223372036854775807, + "nullable": false + } + } + ], + "get": { + "summary": "Get entities from related Users", + "tags": [ + "Users", + "Orders" + ], + "parameters": [ + { + "name": "select", + "in": "query", + "description": "Select properties to be returned, see [OData Select](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionselect)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "*", + "id" + ] + } + } + }, + { + "$ref": "#/components/parameters/count" + }, + { + "name": "expand", + "in": "query", + "description": "Expand related entities, see [OData Expand](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionexpand)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "orders" + ] + } + } + }, + { + "$ref": "#/components/parameters/filter" + }, + { + "$ref": "#/components/parameters/search" + }, + { + "$ref": "#/components/parameters/top" + }, + { + "$ref": "#/components/parameters/skip" + }, + { + "name": "orderby", + "in": "query", + "description": "Order items by property values, see [OData Sorting](https://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_SystemQueryOptionorderby)", + "explode": false, + "schema": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "id", + "id desc" + ] + } + } + } + ], + "responses": { + "200": { + "description": "Retrieved entities", + "content": { + "application/json": { + "schema": { + "type": "object", + "title": "Collection of Users", + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/components/schemas/com.example.odata.User" + } + }, + "@count": { + "$ref": "#/components/schemas/count" + } + } + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/error" + } + } + }, + "post": { + "summary": "Add new entity to related Users", + "tags": [ + "Users", + "Orders" + ], + "requestBody": { + "required": true, + "description": "New entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/com.example.odata.User-create" + } + } + } + }, + "responses": { + "201": { + "description": "Created entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/com.example.odata.User" + } + } + } + }, + "204": { + "description": "Success" + }, + "4XX": { + "$ref": "#/components/responses/error" + } + } + } + }, "/function1": { "get": { "tags": [