From 8b037a6a9f0ee42cf048ec37a73020c69074c9f9 Mon Sep 17 00:00:00 2001 From: Lukas Schwabe Date: Thu, 20 Aug 2026 16:42:43 +0200 Subject: [PATCH 1/2] fix: use OData V4 path for OpenAPI server URL if no protocol is set to match @sap/cds default behavior Signed-off-by: Lukas Schwabe --- lib/compile/index.js | 2 +- test/lib/compile/openapi.test.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/compile/index.js b/lib/compile/index.js index 1bfb40f..6dabd6d 100644 --- a/lib/compile/index.js +++ b/lib/compile/index.js @@ -156,7 +156,7 @@ function _getProtocols(csdl, csn, odataVersion) { protocols.push("odata"); } else if (!service["@protocol"]) { - protocols.push("rest"); //taking rest as default in case no relevant protocol is there + protocols.push("odata"); // matches cds's default protocol when none is annotated } else if (service["@protocol"] === "none") { // if @protocol is 'none' then throw an error throw new Error( diff --git a/test/lib/compile/openapi.test.js b/test/lib/compile/openapi.test.js index 79e5374..24961dd 100644 --- a/test/lib/compile/openapi.test.js +++ b/test/lib/compile/openapi.test.js @@ -262,6 +262,21 @@ service CatalogService { assert(openapi.servers[0].url.includes('odata')); }); + test('default service without @protocol renders server URL with odata/v4', () => { + const csn = cds.compile.to.csn(` + @path: 'catalog' + service CatalogService { + entity Books { + key ID : Integer; + title : String; + } + }` + ); + const openapi = toOpenApi(csn); + assert(openapi.servers[0].url.includes('odata/v4')); + assert(!openapi.servers[0].url.includes('rest')); + }); + test('options: Multiple servers', () => { const csn = cds.compile.to.csn(` service A {entity E { key ID : UUID; };};` From db8cc224284dd8e79c3ba55255997f39be6628f1 Mon Sep 17 00:00:00 2001 From: Lukas Schwabe Date: Fri, 21 Aug 2026 09:20:12 +0200 Subject: [PATCH 2/2] chore: adjust changelog.md to fit the fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4285a52..267c2a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). ### Deprecated ### Removed ### Fixed +- set `odata` as the service protocol if no protocol is set to match the default behavior of `@sap/cds` ### Security ## [1.6.0] - 2026-08-04