Skip to content
Merged
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
- Restore bound actions/functions on containment navigation paths (regression since v1.2.0)
### Security

## [1.4.0] - 2026-03-18
Expand Down
3 changes: 1 addition & 2 deletions lib/compile/csdl2openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
* @param {{ url?: string, servers?: object, odataVersion?: string, scheme?: string, host?: string, basePath?: string, diagram?: boolean, maxLevels?: number, shortActionPaths?: boolean }} options Optional parameters
* @return {object} OpenAPI description
*/
module.exports.csdl2openapi = function (

Check warning on line 93 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Function has a complexity of 22. Maximum allowed is 15

Check warning on line 93 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Function has a complexity of 22. Maximum allowed is 15

Check warning on line 93 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Function has a complexity of 22. Maximum allowed is 15
csdl,
{
url: serviceRoot,
Expand All @@ -104,12 +104,12 @@
shortActionPaths = false
} = {}
) {
diagram = /** @type {unknown} */(diagram) !== "false" && !!diagram;

Check warning on line 107 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Assignment to function parameter 'diagram'

Check warning on line 107 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Assignment to function parameter 'diagram'

Check warning on line 107 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'diagram'
// as preProcess below mutates the csdl, copy it before, to avoid side-effects on the caller side
csdl = JSON.parse(JSON.stringify(csdl))

Check warning on line 109 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Assignment to function parameter 'csdl'

Check warning on line 109 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Assignment to function parameter 'csdl'

Check warning on line 109 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'csdl'
csdl.$Version = odataVersion ? odataVersion : '4.01'
const meta = new CSDLMeta(csdl)
serviceRoot = serviceRoot ?? (`${scheme}://${host}${basePath}`);

Check warning on line 112 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Assignment to function parameter 'serviceRoot'

Check warning on line 112 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Assignment to function parameter 'serviceRoot'

Check warning on line 112 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'serviceRoot'
const queryOptionPrefix = csdl.$Version <= '4.01' ? '$' : '';
const typesToInline = {}; // filled in schema() and used in inlineTypes()

Expand All @@ -122,7 +122,7 @@
Object.keys(entityContainer).forEach(element => {
if (entityContainer[element].$Type) {
const fullTypeName = entityContainer[element].$Type;
const type = fullTypeName.startsWith(serviceName + '.')

Check warning on line 125 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Unexpected string concatenation

Check warning on line 125 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Unexpected string concatenation

Check warning on line 125 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected string concatenation
? fullTypeName.substring(serviceName.length + 1)
: nameParts(fullTypeName).name;
if ((csdl[serviceName]?.[type]?.['@cds.autoexpose'] || csdl[serviceName]?.[type]?.['@cds.autoexposed'])
Expand Down Expand Up @@ -408,7 +408,7 @@
.replaceAll('_', ' ')
.replace(/([a-z])([A-Z])/g, '$1 $2'); // "camelCase" to "camel Case"
if (typeof tag === 'string') {
tag = normalise(tag);

Check warning on line 411 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Assignment to function parameter 'tag'

Check warning on line 411 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Assignment to function parameter 'tag'

Check warning on line 411 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'tag'
} else {
tag.name = normalise(tag.name);
}
Expand Down Expand Up @@ -460,7 +460,7 @@
* @param {number} level Number of navigation segments so far
* @param {string} navigationPath Path for finding navigation restrictions
*/
function pathItems(paths, prefix, prefixParameters, element, root, sourceName, targetName, target, level, navigationPath) {

Check warning on line 463 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Function 'pathItems' has too many parameters (10). Maximum allowed is 4

Check warning on line 463 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Function 'pathItems' has too many parameters (10). Maximum allowed is 4

Check warning on line 463 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Function 'pathItems' has too many parameters (10). Maximum allowed is 4
const name = prefix.substring(prefix.lastIndexOf('/') + 1);
const type = meta.modelElement(element.$Type);
const pathItem = {};
Expand Down Expand Up @@ -542,7 +542,7 @@
* @param {object} restrictions Navigation property restrictions of navigation segment
* @param {array} nonExpandable Non-expandable navigation properties
*/
function pathItemsWithKey(paths, prefix, prefixParameters, element, root, sourceName, targetName, target, level, navigationPath, restrictions, nonExpandable) {

Check warning on line 545 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Function 'pathItemsWithKey' has too many parameters (12). Maximum allowed is 4

Check warning on line 545 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Function 'pathItemsWithKey' has too many parameters (12). Maximum allowed is 4

Check warning on line 545 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Function 'pathItemsWithKey' has too many parameters (12). Maximum allowed is 4
const targetIndexable = target == null || target[meta.voc.Capabilities.IndexableByKey] != false;
if (restrictions.IndexableByKey == true || restrictions.IndexableByKey != false && targetIndexable) {
const name = prefix.substring(prefix.lastIndexOf('/') + 1);
Expand Down Expand Up @@ -580,7 +580,7 @@
* @param {number} level Number of navigation segments so far
* @param {object} restrictions Navigation property restrictions of navigation segment
*/
function operationCreate(pathItem, element, name, sourceName, targetName, target, level, restrictions) {

Check warning on line 583 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Function 'operationCreate' has too many parameters (8). Maximum allowed is 4

Check warning on line 583 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Function 'operationCreate' has too many parameters (8). Maximum allowed is 4

Check warning on line 583 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Function 'operationCreate' has too many parameters (8). Maximum allowed is 4
const insertRestrictions = restrictions.InsertRestrictions || target?.[meta.voc.Capabilities.InsertRestrictions] || {};
const countRestrictions = target?.[meta.voc.Capabilities.CountRestrictions]?.Countable === false // count property will be added if CountRestrictions is false
if (insertRestrictions.Insertable !== false) {
Expand Down Expand Up @@ -616,7 +616,7 @@
* @param {boolean} byKey Access by key
* @return Operation Text
*/
function operationSummary(operation, name, sourceName, level, collection, byKey) {

Check warning on line 619 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Function 'operationSummary' has too many parameters (6). Maximum allowed is 4

Check warning on line 619 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / Node.js 24

Function 'operationSummary' has too many parameters (6). Maximum allowed is 4

Check warning on line 619 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Function 'operationSummary' has too many parameters (6). Maximum allowed is 4
const lname = splitName(name);
const sname = splitName(sourceName);

Expand Down Expand Up @@ -1339,8 +1339,7 @@
* @param {boolean} byKey read by key
*/
function pathItemsForBoundOperations(paths, prefix, prefixParameters, element, sourceName, byKey = false) {
//ignore operations on navigation path
if (element.$Kind === "NavigationProperty") {
if (element.$Kind === "NavigationProperty" && !element.$ContainsTarget) {
return;
}
const overloads = meta.boundOverloads[element.$Type + (!byKey && element.$Collection ? '-c' : '')] || [];
Expand Down
3 changes: 2 additions & 1 deletion scripts/regenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const specialOptions = {
host: 'services.odata.org',
basePath: '/V4/(S(cnbm44wtbc1v5bgrlek5lpcc))/TripPinServiceRW',
diagram: true
}
},
'autoexposed-texts': {}
};

// Default options for all other test cases.
Expand Down
103 changes: 103 additions & 0 deletions test/lib/compile/data/TripPin.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,53 @@
}
}
},
"/Me/Trips({TripId_1})/Microsoft.OData.SampleService.Models.TripPin.GetInvolvedPeople": {
"get": {
"summary": "Invokes function GetInvolvedPeople",
"tags": [
"Me"
],
"parameters": [
{
"description": "key: TripId",
"in": "path",
"name": "TripId_1",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"title": "Collection of Person",
"properties": {
"@count": {
"$ref": "#/components/schemas/count"
},
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Microsoft.OData.SampleService.Models.TripPin.Person"
}
}
}
}
}
}
},
"4XX": {
"$ref": "#/components/responses/error"
}
}
}
},
"/Me/Trips({TripId_1})/Photos": {
"parameters": [
{
Expand Down Expand Up @@ -2518,6 +2565,62 @@
}
}
},
"/People('{UserName}')/Trips({TripId_1})/Microsoft.OData.SampleService.Models.TripPin.GetInvolvedPeople": {
"get": {
"summary": "Invokes function GetInvolvedPeople",
"tags": [
"People"
],
"parameters": [
{
"description": "key: UserName",
"in": "path",
"name": "UserName",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "key: TripId",
"in": "path",
"name": "TripId_1",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"title": "Collection of Person",
"properties": {
"@count": {
"$ref": "#/components/schemas/count"
},
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Microsoft.OData.SampleService.Models.TripPin.Person"
}
}
}
}
}
}
},
"4XX": {
"$ref": "#/components/responses/error"
}
}
}
},
"/People('{UserName}')/Trips({TripId_1})/Photos": {
"parameters": [
{
Expand Down
Loading
Loading