Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/compile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 15 additions & 0 deletions test/lib/compile/openapi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; };};`
Expand Down
Loading