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 @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Removed
### Fixed
- Autoexposed `.texts` entities are now excluded from OpenAPI document
- Generate navigation paths to CRUD-disabled entities

### Security

Expand Down
5 changes: 3 additions & 2 deletions lib/compile/csdl2openapi.js
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a separate PR, we should get rid of the many lint warnings here.

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 }} 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 20. 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 20. 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 20. Maximum allowed is 15

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 20. 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 20. 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 20. Maximum allowed is 15
csdl,
{
url: serviceRoot,
Expand All @@ -104,10 +104,10 @@
} = {}
) {
// 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 107 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 107 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'csdl'

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 'csdl'

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 'csdl'

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

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'csdl'

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 'csdl'
csdl.$Version = odataVersion ? odataVersion : '4.01'
const meta = new CSDLMeta(csdl)
serviceRoot = serviceRoot ?? (`${scheme}://${host}${basePath}`);

Check warning on line 110 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 110 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'serviceRoot'

Check warning on line 110 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 110 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 110 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'serviceRoot'

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

View workflow job for this annotation

GitHub Actions / Node.js 24

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

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

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

View workflow job for this annotation

GitHub Actions / Node.js 20

Unexpected string concatenation

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected string concatenation

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

View workflow job for this annotation

GitHub Actions / Node.js 24

Unexpected string concatenation

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

View workflow job for this annotation

GitHub Actions / Node.js 20

Unexpected string concatenation

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected string concatenation

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

View workflow job for this annotation

GitHub Actions / Node.js 24

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 @@ -406,7 +406,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 409 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 409 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'tag'

Check warning on line 409 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 409 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 409 in lib/compile/csdl2openapi.js

View workflow job for this annotation

GitHub Actions / lint

Assignment to function parameter 'tag'

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

View workflow job for this annotation

GitHub Actions / Node.js 24

Assignment to function parameter 'tag'
} else {
tag.name = normalise(tag.name);
}
Expand Down Expand Up @@ -458,7 +458,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 461 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 461 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

Check warning on line 461 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 461 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 461 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

Check warning on line 461 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
const name = prefix.substring(prefix.lastIndexOf('/') + 1);
const type = meta.modelElement(element.$Type);
const pathItem = {};
Expand Down Expand Up @@ -540,7 +540,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 543 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 543 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

Check warning on line 543 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 543 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 543 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

Check warning on line 543 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
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 All @@ -557,11 +557,12 @@
operationUpdate(pathItem, element, name, sourceName, target, level, restrictions, true);
operationDelete(pathItem, element, name, sourceName, target, level, restrictions, true);
}
if (Object.keys(pathItem).filter((i) => i !== "parameters").length === 0)
delete paths[path];

pathItemsForBoundOperations(paths, path, parameters, element, sourceName, true);
pathItemsWithNavigation(paths, path, parameters, type, root, sourceName, level, navigationPath);

if (Object.keys(pathItem).filter((i) => i !== "parameters").length === 0)
delete paths[path];
}
}
}
Expand All @@ -577,7 +578,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 581 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 581 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

Check warning on line 581 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 581 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 581 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

Check warning on line 581 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
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 @@ -613,7 +614,7 @@
* @param {boolean} byKey Access by key
* @return Operation Text
*/
function operationSummary(operation, name, sourceName, level, collection, byKey) {

Check warning on line 617 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 617 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

Check warning on line 617 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 617 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 617 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

Check warning on line 617 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
const lname = splitName(name);
const sname = splitName(sourceName);

Expand All @@ -638,7 +639,7 @@
* @param {boolean} byKey Read by key
* @param {array} nonExpandable Non-expandable navigation properties
*/
function operationRead(pathItem, element, name, sourceName, targetName, target, level, restrictions, byKey, nonExpandable) {

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

View workflow job for this annotation

GitHub Actions / Node.js 20

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

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

View workflow job for this annotation

GitHub Actions / lint

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

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

View workflow job for this annotation

GitHub Actions / Node.js 24

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

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

View workflow job for this annotation

GitHub Actions / Node.js 20

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

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

View workflow job for this annotation

GitHub Actions / lint

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

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

View workflow job for this annotation

GitHub Actions / Node.js 24

Function 'operationRead' has too many parameters (10). Maximum allowed is 4
const targetRestrictions = target?.[meta.voc.Capabilities.ReadRestrictions];
const readRestrictions = restrictions.ReadRestrictions || targetRestrictions || {};
const readByKeyRestrictions = readRestrictions.ReadByKeyRestrictions;
Expand Down
Loading
Loading