From e5748a54c0da6d34de33561e2de832a14dad4053 Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Tue, 20 Oct 2026 11:12:21 +0200 Subject: [PATCH 1/4] Auto-expose off for service --- cds/cdl.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cds/cdl.md b/cds/cdl.md index e4ffc07e43..9a91a2d3a0 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -2084,6 +2084,16 @@ service MyOrders { } ``` +Auto-exposure of entities annotated with `@cds.autoexpose` can be switched off for a +particular service by annotating the service with `@cds.autoexpose: false`: +```cds +@cds.autoexpose: false +service Zoo { + // ... + // Bar and Car are not auto-exposed in this service +} +``` + [Learn more about **CodeLists in `@sap/cds/common`**.](./common#code-lists){.learn-more} From 301910492ed1770ff2b5f59aba0a92a09b25e852 Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:41:42 +0200 Subject: [PATCH 2/4] Add explanation of auto-expose for compositions --- cds/cdl.md | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/cds/cdl.md b/cds/cdl.md index 9a91a2d3a0..55256e1bbd 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -2070,8 +2070,8 @@ service Zoo { ```cds extend service Zoo with { // auto-exposed entities: - @readonly entity Foo_bar as projection on Bar; - @readonly entity Foo_car as projection on Car; + entity Bar as projection on my.Bar; + entity Car as projection on my.Car; } ``` @@ -2094,6 +2094,42 @@ service Zoo { } ``` +In addition to entities annotated with `@cds.autoexpose`, composition targets are auto-exposed, too. + +Example: +```cds +// schema.cds +namespace travels; +entity Travels { + key id : Integer; + bookings : Composition of many Bookings on Bookings.Travel = $self; +} +entity Bookings { + key Travel : Association to Travels; + key Pos : Integer; +} +``` + +When `Travels` is exposed in a service ... + +```cds +using { travels } from './schema.cds'; +service TravelService { + entity Travels as projection on travels.Travels +} +``` + +... the composition target `Bookings` is auto-exposed, like + +```cds +extend service TravelService with { // auto-exposed entity: + entity Bookings as projection on travels.Bookings; +} +``` + +This auto-exposure of composition targets is not affected by annotating +service `TravelService` with `@cds.autoexpose: false`. + [Learn more about **CodeLists in `@sap/cds/common`**.](./common#code-lists){.learn-more} From b468d2c56aeecd541f082217a34f7eaaa9c79adb Mon Sep 17 00:00:00 2001 From: Rene Jeglinsky Date: Thu, 22 Oct 2026 14:02:17 +0200 Subject: [PATCH 3/4] restructure --- cds/cdl.md | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/cds/cdl.md b/cds/cdl.md index 55256e1bbd..bc4e0aef18 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -2040,7 +2040,9 @@ service AdminService { ### Auto-Exposed Entities {#auto-expose} -Annotate entities with `@cds.autoexpose` to automatically expose them in services containing entities with associations referring to them. +Annotate entities with `@cds.autoexpose` to automatically expose them in services containing entities with associations referring to them. Composition targets are auto-exposed without the need for an annotation. + +#### Using @cds.autoexpose For example, given the following entity definitions: @@ -2084,15 +2086,7 @@ service MyOrders { } ``` -Auto-exposure of entities annotated with `@cds.autoexpose` can be switched off for a -particular service by annotating the service with `@cds.autoexpose: false`: -```cds -@cds.autoexpose: false -service Zoo { - // ... - // Bar and Car are not auto-exposed in this service -} -``` +#### Using Compositions In addition to entities annotated with `@cds.autoexpose`, composition targets are auto-exposed, too. @@ -2127,12 +2121,25 @@ extend service TravelService with { // auto-exposed entity: } ``` -This auto-exposure of composition targets is not affected by annotating -service `TravelService` with `@cds.autoexpose: false`. - [Learn more about **CodeLists in `@sap/cds/common`**.](./common#code-lists){.learn-more} +#### Switch Off Auto-Exposure + +Auto-exposure of entities annotated with `@cds.autoexpose` can be switched off for a +particular service by annotating the service with `@cds.autoexpose: false`: +```cds +@cds.autoexpose: false +service Zoo { + // ... + // Bar and Car are not auto-exposed in this service +} +``` + +>[!important] Not valid for compositions +> Auto-exposure of composition targets is not affected by annotating the +service with `@cds.autoexpose: false`. + ### Custom Actions and Functions {#actions} From b2a6cd3975de0b8b4ca6eba05c40d2fc9dcff592 Mon Sep 17 00:00:00 2001 From: Rene Jeglinsky Date: Thu, 22 Oct 2026 14:08:39 +0200 Subject: [PATCH 4/4] edit --- cds/cdl.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cds/cdl.md b/cds/cdl.md index bc4e0aef18..4b4951198d 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -2040,7 +2040,7 @@ service AdminService { ### Auto-Exposed Entities {#auto-expose} -Annotate entities with `@cds.autoexpose` to automatically expose them in services containing entities with associations referring to them. Composition targets are auto-exposed without the need for an annotation. +Annotate entities with `@cds.autoexpose` to auto-expose them in services that contain entities with associations referring to them. Composition targets are auto-exposed without an annotation. #### Using @cds.autoexpose @@ -2068,7 +2068,7 @@ service Zoo { } ``` -... would result in the service being automatically extended like this: +... results in the service being automatically extended like this: ```cds extend service Zoo with { // auto-exposed entities: @@ -2077,7 +2077,7 @@ extend service Zoo with { // auto-exposed entities: } ``` -You can still expose such entities explicitly, for example, to make them read-write: +You can still expose such entities directly, for example, to make them read-write: ```cds service MyOrders { @@ -2088,7 +2088,7 @@ service MyOrders { #### Using Compositions -In addition to entities annotated with `@cds.autoexpose`, composition targets are auto-exposed, too. +Besides entities annotated with `@cds.autoexpose`, composition targets are auto-exposed. Example: ```cds @@ -2113,7 +2113,7 @@ service TravelService { } ``` -... the composition target `Bookings` is auto-exposed, like +... the composition target `Bookings` is auto-exposed as follows: ```cds extend service TravelService with { // auto-exposed entity: @@ -2126,8 +2126,7 @@ extend service TravelService with { // auto-exposed entity: #### Switch Off Auto-Exposure -Auto-exposure of entities annotated with `@cds.autoexpose` can be switched off for a -particular service by annotating the service with `@cds.autoexpose: false`: +To switch off auto-exposure of entities annotated with `@cds.autoexpose` in a service, annotate the service with `@cds.autoexpose: false`: ```cds @cds.autoexpose: false service Zoo { @@ -2137,8 +2136,7 @@ service Zoo { ``` >[!important] Not valid for compositions -> Auto-exposure of composition targets is not affected by annotating the -service with `@cds.autoexpose: false`. +> The `@cds.autoexpose: false` annotation does not affect auto-exposure of composition targets. ### Custom Actions and Functions {#actions}