Is there an existing issue for this?
Current Behavior
When defining a CDS function with multiple parameters, all marked as @mandatory, the OpenAPI compiler fails with:
[ERROR] Unexpected mandatory after optional parameter (in function:"<ServiceName>.<functionName>"/param:"<secondParam>")
The compiler appears to not recognize @mandatory annotations on function parameters at all — every parameter is treated internally as optional, which then triggers the OData V4 rule that mandatory parameters must come before optional ones as soon as a second mandatory parameter is encountered.
The same annotation pattern works correctly on action definitions.
Expected Behavior
The function definition compiles successfully and the generated OpenAPI document marks both parameters as required: true, identical to how the action variant is handled.
Steps To Reproduce
Minimal CDS service definition:
service ReproService {
// FAILS with `odata-parameter-order`
// Both params are tagged @mandatory, so a developer reasonably expects this to be valid.
// The first param is an enum type (no `not null`) -> compiler treats it as optional.
// The second param references a key field (`name` is `String not null`) -> compiler treats it as mandatory.
// -> "Unexpected mandatory after optional parameter".
function getMapping(
@mandatory
@Core.Description: 'First parameter'
paramA: TypeA,
@mandatory
@Core.Description: 'Second parameter'
paramB: TypeB:name
) returns String;
// WORKS — identical signature, only `function` -> `action`
action getMappingAsAction(
@mandatory
@Core.Description: 'First parameter'
paramA: String,
@mandatory
@Core.Description: 'Second parameter'
paramB: String
) returns String;
}
define type TypeA: String enum {
A; B; C;
}
entity TypeB{
key id : UUID;
name : String not null;
}
Environment
- `@sap/cds`: 9.3.x
- `@cap-js/openapi`: latest
- Node.js: 24.x
- OS: Windows 11
Repository Containing a Minimal Reproducible Example
No response
Anything else?
No response
Is there an existing issue for this?
Current Behavior
When defining a CDS
functionwith multiple parameters, all marked as@mandatory, the OpenAPI compiler fails with:The compiler appears to not recognize
@mandatoryannotations onfunctionparameters at all — every parameter is treated internally as optional, which then triggers the OData V4 rule that mandatory parameters must come before optional ones as soon as a second mandatory parameter is encountered.The same annotation pattern works correctly on
actiondefinitions.Expected Behavior
The
functiondefinition compiles successfully and the generated OpenAPI document marks both parameters asrequired: true, identical to how theactionvariant is handled.Steps To Reproduce
Minimal CDS service definition:
Environment
Repository Containing a Minimal Reproducible Example
No response
Anything else?
No response