@sap/cds-dk 4.9.7 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/bin/activate.js +4 -4
- package/bin/add.js +11 -5
- package/bin/bind.js +16 -28
- package/bin/build/all.js +2 -2
- package/bin/build/index.js +12 -19
- package/bin/cds.js +22 -19
- package/bin/compile/index.js +12 -3
- package/bin/deploy/index.js +15 -9
- package/bin/deploy/to-hana.js +4 -4
- package/bin/deploy/to-sqlite.js +1 -1
- package/bin/env.js +13 -4
- package/bin/eval.js +1 -1
- package/bin/fix-redirects.js +1 -1
- package/bin/import.js +44 -179
- package/bin/repl.js +1 -1
- package/bin/watch.js +10 -15
- package/lib/bind/BindingManager.js +87 -0
- package/lib/bind/bindingResolver.js +15 -87
- package/lib/bind/bindingUtil.js +18 -11
- package/lib/bind/cfKeyProvider.js +58 -29
- package/lib/bind/kubernetesCredentialsProvider.js +44 -21
- package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
- package/lib/cds.js +13 -0
- package/lib/client/base_command.js +3 -2
- package/lib/client/extend.js +6 -7
- package/lib/client/helper/fs_helper.js +7 -8
- package/lib/client/settings_manager.js +14 -10
- package/lib/compile/index.js +9 -10
- package/lib/compile/openapi/csdl2openapi.js +151 -43
- package/lib/compile/openapi/index.js +2 -2
- package/lib/compile/to-xsuaa.js +3 -2
- package/lib/import/common.js +342 -27
- package/lib/import/importapi.js +81 -13
- package/lib/import/message.js +4 -4
- package/lib/import/odata/index.js +141 -0
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverter.js +2 -2
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverterFactory.js +1 -1
- package/lib/import/{utils → odata/util}/MultiMap.js +0 -0
- package/lib/import/{v2parser.js → odata/v2parser.js} +405 -468
- package/lib/import/{v4parser.js → odata/v4parser.js} +311 -322
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Aggregation.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Authorization.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Capabilities.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Core.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Measures.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Validation.V1.json +0 -0
- package/lib/import/openapi/importOpenAPI.js +521 -0
- package/lib/import/openapi/index.js +19 -0
- package/lib/import/openapi/utilities.js +38 -0
- package/lib/index.js +1 -1
- package/lib/init/constants.js +7 -2
- package/lib/init/index.js +10 -3
- package/lib/init/template/_merging/existences.js +79 -19
- package/lib/init/template/approuter/files/mta.yaml.hbs +25 -11
- package/lib/init/template/approuter/files/package.json +1 -1
- package/lib/init/template/approuter/files/xs-app.json.hbs +7 -0
- package/lib/init/template/approuter/index.js +61 -54
- package/lib/init/template/auditlog/index.js +2 -2
- package/lib/init/template/data/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +17 -17
- package/lib/init/template/hana/index.js +8 -4
- package/lib/init/template/helm/index.js +39 -0
- package/lib/init/template/helm/update/index.js +28 -0
- package/lib/init/template/java/index.js +7 -9
- package/lib/init/template/kibana-logging/index.js +5 -6
- package/lib/init/template/lint/index.js +1 -1
- package/lib/init/template/mta/index.js +4 -4
- package/lib/init/template/mtx/files/java/package.json +9 -9
- package/lib/init/template/mtx/files/mta.yaml.hbs +0 -7
- package/lib/init/template/mtx/files/xs-security.json.hbs +11 -20
- package/lib/init/template/mtx/index.js +50 -57
- package/lib/init/template/nodejs/files/package.json.hbs +2 -2
- package/lib/init/template/notebook/index.js +2 -0
- package/lib/init/template/templateBase.js +8 -6
- package/lib/init/template/xsuaa/index.js +9 -5
- package/lib/init/util/fsUtil.js +25 -10
- package/lib/init/util/logger.js +1 -1
- package/lib/init/util/mvnArchetypeUtil.js +4 -10
- package/lib/init/util/projectReader.js +17 -9
- package/lib/init/util/templateUtil.js +30 -34
- package/lib/k8s/ChartAdder.js +65 -0
- package/lib/k8s/ChartBuilder.js +186 -0
- package/lib/k8s/Context.js +71 -0
- package/lib/k8s/ImageUtil.js +21 -0
- package/lib/k8s/Model.d.ts +53 -0
- package/lib/k8s/auditlog/index.js +29 -0
- package/lib/k8s/auditlog/templates/auditlog.yaml +1 -0
- package/lib/k8s/buildModel.js +70 -0
- package/lib/k8s/connectivity/index.js +80 -0
- package/lib/k8s/connectivity/templates/connectivity-binding.yaml +9 -0
- package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +20 -0
- package/lib/k8s/connectivity/templates/connectivity.yaml +1 -0
- package/lib/k8s/deployment/index.js +81 -0
- package/lib/k8s/deployment/subchart/Chart.yaml +6 -0
- package/lib/k8s/deployment/subchart/templates/_helpers.tpl +156 -0
- package/lib/k8s/deployment/subchart/templates/api-rule.yaml +24 -0
- package/lib/k8s/deployment/subchart/templates/deployment.yaml +110 -0
- package/lib/k8s/deployment/subchart/templates/network-policy.yaml +16 -0
- package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +11 -0
- package/lib/k8s/deployment/subchart/templates/secret.yaml +10 -0
- package/lib/k8s/deployment/subchart/templates/service-binding.yaml +27 -0
- package/lib/k8s/deployment/subchart/templates/service.yaml +11 -0
- package/lib/k8s/deployment/subchart/values-lint.yaml +8 -0
- package/lib/k8s/deployment/subchart/values.schema.json +449 -0
- package/lib/k8s/deployment/subchart/values.yaml +76 -0
- package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +81 -0
- package/lib/k8s/destinations/index.js +40 -0
- package/lib/k8s/destinations/lib.js +16 -0
- package/lib/k8s/destinations/templates/destinations.yaml +1 -0
- package/lib/k8s/docker/push.js +8 -0
- package/lib/k8s/event-mesh/index.js +53 -0
- package/lib/k8s/event-mesh/lib.js +9 -0
- package/lib/k8s/event-mesh/templates/event-mesh.yaml +1 -0
- package/lib/k8s/hana-deployer/index.js +38 -0
- package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +41 -0
- package/lib/k8s/helm/Release.js +80 -0
- package/lib/k8s/html5-apps-deployer/index.js +43 -0
- package/lib/k8s/html5-apps-deployer/templates/_html5_deployment_helpers.tpl +16 -0
- package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +53 -0
- package/lib/k8s/html5-apps-repo-host/index.js +26 -0
- package/lib/k8s/html5-apps-repo-host/lib.js +16 -0
- package/lib/k8s/html5-apps-repo-host/templates/html5-apps-repo-host.yaml +1 -0
- package/lib/k8s/index.js +153 -0
- package/lib/k8s/modules.js +36 -0
- package/lib/k8s/multitenancy/index.js +24 -0
- package/lib/k8s/multitenancy/lib.js +25 -0
- package/lib/k8s/multitenancy/templates/saas-registry.yaml +19 -0
- package/lib/k8s/readProject.js +14 -0
- package/lib/k8s/resources/helm/chart/templates/NOTES.txt +11 -0
- package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +221 -0
- package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +167 -0
- package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +103 -0
- package/lib/k8s/util.js +186 -0
- package/lib/k8s/wrapFeature.js +55 -0
- package/lib/k8s/xsuaa/index.js +64 -0
- package/lib/k8s/xsuaa/lib.js +17 -0
- package/lib/k8s/xsuaa/templates/xsuaa.yaml +1 -0
- package/lib/lint/generators.js +1 -1
- package/lib/util/exec.js +1 -1
- package/lib/util/write.js +1 -1
- package/lib/watch/node-watch.js +43 -14
- package/npm-shrinkwrap.json +923 -2705
- package/package.json +5 -5
- package/lib/import/index.js +0 -235
|
@@ -10,7 +10,6 @@ var pluralize = require('pluralize')
|
|
|
10
10
|
// - inject $Name or $$Name into each model element to make parameter passing easier?
|
|
11
11
|
// - allow passing additional files for referenced documents
|
|
12
12
|
// - delta: headers Prefer and Preference-Applied
|
|
13
|
-
// - custom headers and query options - https://issues.oasis-open.org/browse/ODATA-1099
|
|
14
13
|
// - response codes and descriptions - https://issues.oasis-open.org/browse/ODATA-884
|
|
15
14
|
// - inline definitions for Edm.* to make OpenAPI documents self-contained
|
|
16
15
|
// - both "clickable" and freestyle $expand, $select, $orderby - does not work yet, open issue for OpenAPI UI
|
|
@@ -51,15 +50,18 @@ module.exports.csdl2openapi = function (
|
|
|
51
50
|
preProcess(csdl, boundOverloads, derivedTypes, alias, namespace, namespaceUrl, voc);
|
|
52
51
|
|
|
53
52
|
const entityContainer = csdl.$EntityContainer ? modelElement(csdl.$EntityContainer) : {};
|
|
54
|
-
const keyAsSegment = entityContainer[voc.Capabilities.KeyAsSegmentSupported];
|
|
55
|
-
const deepUpdate = entityContainer[voc.Capabilities.DeepUpdateSupport] && entityContainer[voc.Capabilities.DeepUpdateSupport].Supported;
|
|
53
|
+
const keyAsSegment = entityContainer ? entityContainer[voc.Capabilities.KeyAsSegmentSupported] : {};
|
|
54
|
+
const deepUpdate = entityContainer ? entityContainer[voc.Capabilities.DeepUpdateSupport] && entityContainer[voc.Capabilities.DeepUpdateSupport].Supported : {};
|
|
56
55
|
|
|
57
56
|
const openapi = {
|
|
58
57
|
openapi: '3.0.2',
|
|
59
58
|
info: getInfo(csdl, entityContainer),
|
|
59
|
+
'x-sap-api-type': 'ODATAV4',
|
|
60
|
+
'x-odata-version': '4.0',
|
|
61
|
+
'x-sap-shortText': getShortText(csdl, entityContainer),
|
|
60
62
|
servers: getServers(serviceRoot),
|
|
61
|
-
tags: getTags(entityContainer),
|
|
62
|
-
paths: getPaths(entityContainer),
|
|
63
|
+
tags: entityContainer ? getTags(entityContainer) : {},
|
|
64
|
+
paths: entityContainer ? getPaths(entityContainer) : {},
|
|
63
65
|
components: getComponents(csdl, entityContainer)
|
|
64
66
|
};
|
|
65
67
|
if (!csdl.$EntityContainer) {
|
|
@@ -131,10 +133,23 @@ module.exports.csdl2openapi = function (
|
|
|
131
133
|
} else {
|
|
132
134
|
element = modelElement(segments[0].substring(0, open));
|
|
133
135
|
let args = segments[0].substring(open + 1, segments[0].length - 1);
|
|
134
|
-
element = element.find(
|
|
135
|
-
overload
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
element = element.find(
|
|
137
|
+
(overload) =>
|
|
138
|
+
(overload.$Kind == "Action" &&
|
|
139
|
+
overload.$IsBound != true &&
|
|
140
|
+
args == "") ||
|
|
141
|
+
(overload.$Kind == "Action" &&
|
|
142
|
+
args ==
|
|
143
|
+
(overload.$Parameter[0].$Collection
|
|
144
|
+
? `Collection(${overload.$Parameter[0].$Type})`
|
|
145
|
+
: overload.$Parameter[0].$Type || "")) ||
|
|
146
|
+
(overload.$Parameter || [])
|
|
147
|
+
.map((p) => {
|
|
148
|
+
const type = p.$Type || "Edm.String";
|
|
149
|
+
return p.$Collection ? `Collection(${type})` : type;
|
|
150
|
+
})
|
|
151
|
+
.join(",") == args
|
|
152
|
+
);
|
|
138
153
|
}
|
|
139
154
|
if (!element) {
|
|
140
155
|
// console.warn(`Invalid annotation target '${target}'`)
|
|
@@ -180,9 +195,8 @@ module.exports.csdl2openapi = function (
|
|
|
180
195
|
const terms = {
|
|
181
196
|
Authorization: ['Authorizations', 'SecuritySchemes'],
|
|
182
197
|
Capabilities: ['BatchSupport', 'BatchSupported', 'ChangeTracking', 'CountRestrictions', 'DeleteRestrictions', 'DeepUpdateSupport', 'ExpandRestrictions',
|
|
183
|
-
'FilterRestrictions', 'IndexableByKey', 'InsertRestrictions', 'KeyAsSegmentSupported', 'NavigationRestrictions',
|
|
184
|
-
'SearchRestrictions', 'SelectSupport', 'SkipSupported', 'SortRestrictions',
|
|
185
|
-
'ReadRestrictions', 'TopSupported', 'UpdateRestrictions'],
|
|
198
|
+
'FilterRestrictions', 'IndexableByKey', 'InsertRestrictions', 'KeyAsSegmentSupported', 'NavigationRestrictions', 'OperationRestrictions',
|
|
199
|
+
'ReadRestrictions', 'SearchRestrictions', 'SelectSupport', 'SkipSupported', 'SortRestrictions', 'TopSupported', 'UpdateRestrictions'],
|
|
186
200
|
Core: ['AcceptableMediaTypes', 'Computed', 'DefaultNamespace', 'Description', 'Example', 'Immutable', 'LongDescription',
|
|
187
201
|
'OptionalParameter', 'Permissions', 'SchemaVersion'],
|
|
188
202
|
JSON: ['Schema'],
|
|
@@ -210,16 +224,33 @@ module.exports.csdl2openapi = function (
|
|
|
210
224
|
function getInfo(csdl, entityContainer) {
|
|
211
225
|
const namespace = csdl.$EntityContainer ? nameParts(csdl.$EntityContainer).qualifier : null;
|
|
212
226
|
const containerSchema = csdl.$EntityContainer ? csdl[namespace] : {};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
let description;
|
|
228
|
+
if (entityContainer && entityContainer[voc.Core.LongDescription]) {
|
|
229
|
+
description = entityContainer[voc.Core.LongDescription];
|
|
230
|
+
}
|
|
231
|
+
else if (containerSchema && containerSchema[voc.Core.LongDescription]) {
|
|
232
|
+
description = containerSchema[voc.Core.LongDescription];
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
description = ('This service is located at [' + serviceRoot + '/]('
|
|
236
|
+
+ serviceRoot.replace(/\(/g, '%28').replace(/\)/g, '%29') + '/)');
|
|
237
|
+
}
|
|
238
|
+
description += (diagram ? getResourceDiagram(csdl, entityContainer) : '');
|
|
239
|
+
let title;
|
|
240
|
+
if (entityContainer && entityContainer[voc.Core.Description]) {
|
|
241
|
+
title = entityContainer[voc.Core.Description];
|
|
242
|
+
}
|
|
243
|
+
else if (containerSchema && containerSchema[voc.Core.Description]) {
|
|
244
|
+
title = containerSchema[voc.Core.Description];
|
|
245
|
+
}
|
|
246
|
+
else if (csdl.$EntityContainer) {
|
|
247
|
+
title = 'Service for namespace ' + namespace;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
title = 'OData CSDL document';
|
|
251
|
+
}
|
|
219
252
|
return {
|
|
220
|
-
title:
|
|
221
|
-
|| containerSchema[voc.Core.Description]
|
|
222
|
-
|| (csdl.$EntityContainer ? 'Service for namespace ' + namespace : 'OData CSDL document'),
|
|
253
|
+
title: title,
|
|
223
254
|
description: csdl.$EntityContainer ? description : '',
|
|
224
255
|
version: containerSchema[voc.Core.SchemaVersion] || ''
|
|
225
256
|
};
|
|
@@ -349,6 +380,31 @@ module.exports.csdl2openapi = function (
|
|
|
349
380
|
return schema ? schema[q.name] : null;
|
|
350
381
|
}
|
|
351
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Construct the short text
|
|
385
|
+
* @param {object} csdl CSDL document
|
|
386
|
+
* @param {object} entityContainer Entity Container object
|
|
387
|
+
* @return {string} short text
|
|
388
|
+
*/
|
|
389
|
+
function getShortText(csdl, entityContainer) {
|
|
390
|
+
const namespace = csdl.$EntityContainer ? nameParts(csdl.$EntityContainer).qualifier : null;
|
|
391
|
+
const containerSchema = csdl.$EntityContainer ? csdl[namespace] : {};
|
|
392
|
+
let shortText;
|
|
393
|
+
if (entityContainer && entityContainer[voc.Core.Description]) {
|
|
394
|
+
shortText = entityContainer[voc.Core.Description];
|
|
395
|
+
}
|
|
396
|
+
else if (containerSchema && containerSchema[voc.Core.Description]) {
|
|
397
|
+
shortText = containerSchema[voc.Core.Description];
|
|
398
|
+
}
|
|
399
|
+
else if (csdl.$EntityContainer) {
|
|
400
|
+
shortText = 'Service for namespace ' + namespace;
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
shortText = 'OData CSDL document';
|
|
404
|
+
}
|
|
405
|
+
return shortText;
|
|
406
|
+
}
|
|
407
|
+
|
|
352
408
|
/**
|
|
353
409
|
* Construct an array of Server Objects
|
|
354
410
|
* @param {object} csdl The CSDL document
|
|
@@ -552,6 +608,7 @@ module.exports.csdl2openapi = function (
|
|
|
552
608
|
};
|
|
553
609
|
if (insertRestrictions.LongDescription) pathItem.post.description = insertRestrictions.LongDescription;
|
|
554
610
|
if (targetName && sourceName != targetName) pathItem.post.tags.push(targetName);
|
|
611
|
+
customParameters(pathItem.post, insertRestrictions);
|
|
555
612
|
}
|
|
556
613
|
}
|
|
557
614
|
|
|
@@ -629,6 +686,7 @@ module.exports.csdl2openapi = function (
|
|
|
629
686
|
}
|
|
630
687
|
if (descriptions.LongDescription) operation.description = descriptions.LongDescription;
|
|
631
688
|
if (target && sourceName != targetName) operation.tags.push(targetName);
|
|
689
|
+
customParameters(operation, byKey ? readByKeyRestrictions || readRestrictions : readRestrictions);
|
|
632
690
|
|
|
633
691
|
if (collection) {
|
|
634
692
|
optionTop(operation.parameters, target, restrictions);
|
|
@@ -646,6 +704,47 @@ module.exports.csdl2openapi = function (
|
|
|
646
704
|
}
|
|
647
705
|
}
|
|
648
706
|
|
|
707
|
+
/**
|
|
708
|
+
* Add custom headers and query options
|
|
709
|
+
* @param {object} operation Operation object to augment
|
|
710
|
+
* @param {object} restrictions Restrictions for operation
|
|
711
|
+
*/
|
|
712
|
+
function customParameters(operation, restrictions) {
|
|
713
|
+
if (
|
|
714
|
+
!operation.parameters &&
|
|
715
|
+
(restrictions.CustomHeaders || restrictions.CustomQueryOptions)
|
|
716
|
+
)
|
|
717
|
+
operation.parameters = [];
|
|
718
|
+
for (const custom of restrictions.CustomHeaders || []) {
|
|
719
|
+
operation.parameters.push(customParameter(custom, "header"));
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
for (const custom of restrictions.CustomQueryOptions || []) {
|
|
723
|
+
operation.parameters.push(customParameter(custom, "query"));
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Construct custom parameter
|
|
729
|
+
* @param {object} custom custom parameter in OData format
|
|
730
|
+
* @param {string} location "header" or "query"
|
|
731
|
+
*/
|
|
732
|
+
function customParameter(custom, location) {
|
|
733
|
+
return {
|
|
734
|
+
name: custom.Name,
|
|
735
|
+
in: location,
|
|
736
|
+
required: custom.Required || false,
|
|
737
|
+
...(custom.Description && { description: custom.Description }),
|
|
738
|
+
schema: {
|
|
739
|
+
type: "string",
|
|
740
|
+
...(custom.DocumentationURL && {
|
|
741
|
+
externalDocs: { url: custom.DocumentationURL },
|
|
742
|
+
}),
|
|
743
|
+
//TODO: Examples
|
|
744
|
+
},
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
|
|
649
748
|
/**
|
|
650
749
|
* Add parameter for query option $count
|
|
651
750
|
* @param {Array} parameters Array of parameters to augment
|
|
@@ -681,7 +780,10 @@ module.exports.csdl2openapi = function (
|
|
|
681
780
|
parameters.push({
|
|
682
781
|
name: queryOptionPrefix + 'expand',
|
|
683
782
|
description: (targetRestrictions && targetRestrictions[voc.Core.Description])
|
|
684
|
-
|| '
|
|
783
|
+
|| 'The value of $expand query option is a comma-separated list of navigation property names, \
|
|
784
|
+
stream property names, or $value indicating the stream content of a media-entity. \
|
|
785
|
+
The corresponding related entities and stream values will be represented inline, \
|
|
786
|
+
see [Expand](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptionexpand)',
|
|
685
787
|
in: 'query',
|
|
686
788
|
explode: false,
|
|
687
789
|
schema: {
|
|
@@ -1015,7 +1117,7 @@ module.exports.csdl2openapi = function (
|
|
|
1015
1117
|
|
|
1016
1118
|
if (updateRestrictions.Updatable !== false) {
|
|
1017
1119
|
const type = modelElement(element.$Type);
|
|
1018
|
-
|
|
1120
|
+
const operation = {
|
|
1019
1121
|
summary: updateRestrictions.Description || operationSummary('Change', name, sourceName, level, element.$Collection, byKey),
|
|
1020
1122
|
tags: [sourceName],
|
|
1021
1123
|
requestBody: {
|
|
@@ -1029,7 +1131,10 @@ module.exports.csdl2openapi = function (
|
|
|
1029
1131
|
},
|
|
1030
1132
|
responses: response(204, 'Success')
|
|
1031
1133
|
};
|
|
1032
|
-
if (updateRestrictions.LongDescription)
|
|
1134
|
+
if (updateRestrictions.LongDescription) operation.description = updateRestrictions.LongDescription;
|
|
1135
|
+
customParameters(operation, updateRestrictions);
|
|
1136
|
+
const updateMethod = updateRestrictions.UpdateMethod ? updateRestrictions.UpdateMethod.toLowerCase() : "patch";
|
|
1137
|
+
pathItem[updateMethod] = operation;
|
|
1033
1138
|
}
|
|
1034
1139
|
}
|
|
1035
1140
|
|
|
@@ -1054,6 +1159,7 @@ module.exports.csdl2openapi = function (
|
|
|
1054
1159
|
responses: response(204, 'Success')
|
|
1055
1160
|
};
|
|
1056
1161
|
if (deleteRestrictions.LongDescription) pathItem.delete.description = deleteRestrictions.LongDescription;
|
|
1162
|
+
customParameters(pathItem.delete, deleteRestrictions);
|
|
1057
1163
|
}
|
|
1058
1164
|
}
|
|
1059
1165
|
|
|
@@ -1275,7 +1381,7 @@ module.exports.csdl2openapi = function (
|
|
|
1275
1381
|
};
|
|
1276
1382
|
const description = actionImport[voc.Core.LongDescription] || overload[voc.Core.LongDescription];
|
|
1277
1383
|
if (description) pathItem.post.description = description;
|
|
1278
|
-
if (prefixParameters.length > 0) pathItem.post.parameters = prefixParameters;
|
|
1384
|
+
if (prefixParameters.length > 0) pathItem.post.parameters = [...prefixParameters];
|
|
1279
1385
|
let parameters = overload.$Parameter || [];
|
|
1280
1386
|
if (overload.$IsBound) parameters = parameters.slice(1);
|
|
1281
1387
|
if (parameters.length > 0) {
|
|
@@ -1293,6 +1399,7 @@ module.exports.csdl2openapi = function (
|
|
|
1293
1399
|
}
|
|
1294
1400
|
}
|
|
1295
1401
|
}
|
|
1402
|
+
customParameters(pathItem.post, overload[voc.Capabilities.OperationRestrictions] || {});
|
|
1296
1403
|
paths[prefix] = pathItem;
|
|
1297
1404
|
}
|
|
1298
1405
|
|
|
@@ -1385,6 +1492,7 @@ module.exports.csdl2openapi = function (
|
|
|
1385
1492
|
};
|
|
1386
1493
|
const iDescription = functionImport[voc.Core.LongDescription] || overload[voc.Core.LongDescription];
|
|
1387
1494
|
if (iDescription) pathItem.get.description = iDescription;
|
|
1495
|
+
customParameters(pathItem.get, overload[voc.Capabilities.OperationRestrictions] || {});
|
|
1388
1496
|
paths[prefix + pathParameters] = pathItem;
|
|
1389
1497
|
}
|
|
1390
1498
|
|
|
@@ -1638,6 +1746,9 @@ module.exports.csdl2openapi = function (
|
|
|
1638
1746
|
Object.keys(properties).forEach(iName => {
|
|
1639
1747
|
const property = properties[iName];
|
|
1640
1748
|
allProperties[iName] = getSchema(property);
|
|
1749
|
+
if ((Object.prototype.hasOwnProperty.call(property, '@Common.FieldControl')) && property['@Common.FieldControl'] === 'Mandatory') {
|
|
1750
|
+
required.push(iName)
|
|
1751
|
+
}
|
|
1641
1752
|
if (property.$Kind == 'NavigationProperty') {
|
|
1642
1753
|
if (property.$Collection) {
|
|
1643
1754
|
allProperties[`${iName}@${csdl.$Version === '4.0' ? 'odata.' : ''}count`] = ref('count');
|
|
@@ -1878,8 +1989,7 @@ module.exports.csdl2openapi = function (
|
|
|
1878
1989
|
break;
|
|
1879
1990
|
case 'Edm.Decimal':
|
|
1880
1991
|
s = {
|
|
1881
|
-
anyOf: [{ type: 'number' }, { type: 'string' }],
|
|
1882
|
-
format: 'decimal',
|
|
1992
|
+
anyOf: [{ type: 'number', format: 'decimal'}, { type: 'string' }],
|
|
1883
1993
|
example: 0
|
|
1884
1994
|
};
|
|
1885
1995
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -1887,21 +1997,20 @@ module.exports.csdl2openapi = function (
|
|
|
1887
1997
|
if (scale !== null) {
|
|
1888
1998
|
// Node.js 12.13.0 has problems with negative exponents, 10 ** -5 --> 0.000009999999999999999
|
|
1889
1999
|
if (scale <= 0)
|
|
1890
|
-
s.multipleOf = 10 ** -scale;
|
|
2000
|
+
s.anyOf[0].multipleOf = 10 ** -scale;
|
|
1891
2001
|
else
|
|
1892
|
-
s.multipleOf = 1 / 10 ** scale;
|
|
2002
|
+
s.anyOf[0].multipleOf = 1 / 10 ** scale;
|
|
1893
2003
|
}
|
|
1894
2004
|
if (element.$Precision < 16) {
|
|
1895
2005
|
let limit = 10 ** (element.$Precision - scale);
|
|
1896
2006
|
let delta = 10 ** -scale;
|
|
1897
|
-
s.maximum = limit - delta;
|
|
1898
|
-
s.minimum = -s.maximum;
|
|
2007
|
+
s.anyOf[0].maximum = limit - delta;
|
|
2008
|
+
s.anyOf[0].minimum = -s.anyOf[0].maximum;
|
|
1899
2009
|
}
|
|
1900
2010
|
break;
|
|
1901
2011
|
case 'Edm.Double':
|
|
1902
2012
|
s = {
|
|
1903
|
-
anyOf: [{ type: 'number' }, { type: 'string' }],
|
|
1904
|
-
format: 'double',
|
|
2013
|
+
anyOf: [{ type: 'number', format: 'double' }, { type: 'string' }],
|
|
1905
2014
|
example: 3.14
|
|
1906
2015
|
};
|
|
1907
2016
|
break;
|
|
@@ -1938,8 +2047,7 @@ module.exports.csdl2openapi = function (
|
|
|
1938
2047
|
break;
|
|
1939
2048
|
case 'Edm.Int64':
|
|
1940
2049
|
s = {
|
|
1941
|
-
anyOf: [{ type: 'integer' }, { type: 'string' }],
|
|
1942
|
-
format: 'int64',
|
|
2050
|
+
anyOf: [{ type: 'integer', format: 'int64' }, { type: 'string' }],
|
|
1943
2051
|
example: "42"
|
|
1944
2052
|
};
|
|
1945
2053
|
break;
|
|
@@ -1956,8 +2064,7 @@ module.exports.csdl2openapi = function (
|
|
|
1956
2064
|
break;
|
|
1957
2065
|
case 'Edm.Single':
|
|
1958
2066
|
s = {
|
|
1959
|
-
anyOf: [{ type: 'number' }, { type: 'string' }],
|
|
1960
|
-
format: 'float',
|
|
2067
|
+
anyOf: [{ type: 'number', format: 'float' }, { type: 'string' }],
|
|
1961
2068
|
example: 3.14
|
|
1962
2069
|
};
|
|
1963
2070
|
break;
|
|
@@ -2037,6 +2144,7 @@ module.exports.csdl2openapi = function (
|
|
|
2037
2144
|
if (element.$Nullable) {
|
|
2038
2145
|
if (!s.anyOf && !s.allOf) s.type = "string";
|
|
2039
2146
|
if (s.format) s.format += ",null";
|
|
2147
|
+
if (s.anyOf && s.anyOf[0].format) s.anyOf[0].format += ",null";
|
|
2040
2148
|
s.default = "null";
|
|
2041
2149
|
if (s.pattern) {
|
|
2042
2150
|
s.pattern = s.pattern.replace(/^\^/, "^(null|");
|
|
@@ -2047,13 +2155,13 @@ module.exports.csdl2openapi = function (
|
|
|
2047
2155
|
|
|
2048
2156
|
if (element[voc.Validation.Maximum] != undefined) {
|
|
2049
2157
|
if (s.$ref) s = { allOf: [s] };
|
|
2050
|
-
s.maximum = element[voc.Validation.Maximum];
|
|
2158
|
+
s.anyOf[0].maximum = element[voc.Validation.Maximum];
|
|
2051
2159
|
if (element[voc.Validation.Maximum + voc.Validation.Exclusive]) s.exclusiveMaximum = true;
|
|
2052
2160
|
}
|
|
2053
2161
|
|
|
2054
2162
|
if (element[voc.Validation.Minimum] != undefined) {
|
|
2055
2163
|
if (s.$ref) s = { allOf: [s] };
|
|
2056
|
-
s.minimum = element[voc.Validation.Minimum];
|
|
2164
|
+
s.anyOf[0].minimum = element[voc.Validation.Minimum];
|
|
2057
2165
|
if (element[voc.Validation.Minimum + voc.Validation.Exclusive]) s.exclusiveMinimum = true;
|
|
2058
2166
|
}
|
|
2059
2167
|
|
|
@@ -2108,7 +2216,7 @@ module.exports.csdl2openapi = function (
|
|
|
2108
2216
|
name = nsp + '.' + parts.name;
|
|
2109
2217
|
url = namespaceUrl[nsp] || '';
|
|
2110
2218
|
//TODO: introduce better way than guessing
|
|
2111
|
-
if (url.endsWith('.xml')) url = url.
|
|
2219
|
+
if (url.endsWith('.xml')) url = url.substring(0, url.length - 3) + "openapi3.json";
|
|
2112
2220
|
}
|
|
2113
2221
|
return {
|
|
2114
2222
|
$ref: url + '#/components/schemas/' + name + suffix
|
|
@@ -2121,7 +2229,7 @@ module.exports.csdl2openapi = function (
|
|
|
2121
2229
|
* @param {object} entityContainer Entity Container object
|
|
2122
2230
|
*/
|
|
2123
2231
|
function getSecuritySchemes(components, entityContainer) {
|
|
2124
|
-
const authorizations = entityContainer[voc.Authorization.Authorizations]
|
|
2232
|
+
const authorizations = entityContainer && entityContainer[voc.Authorization.Authorizations] ? entityContainer[voc.Authorization.Authorizations] : [];
|
|
2125
2233
|
const schemes = {};
|
|
2126
2234
|
const location = { Header: 'header', QueryOption: 'query', Cookie: 'cookie' };
|
|
2127
2235
|
authorizations.forEach(auth => {
|
|
@@ -2129,7 +2237,7 @@ module.exports.csdl2openapi = function (
|
|
|
2129
2237
|
const flow = {};
|
|
2130
2238
|
if (auth.Description) scheme.description = auth.Description;
|
|
2131
2239
|
const qualifiedType = auth['@type'] || auth['@odata.type']
|
|
2132
|
-
const type = qualifiedType.
|
|
2240
|
+
const type = qualifiedType.substring(qualifiedType.lastIndexOf(".") + 1);
|
|
2133
2241
|
let unknown = false
|
|
2134
2242
|
switch (type) {
|
|
2135
2243
|
case 'ApiKey':
|
|
@@ -2197,7 +2305,7 @@ module.exports.csdl2openapi = function (
|
|
|
2197
2305
|
* @param {object} entityContainer Entity Container object
|
|
2198
2306
|
*/
|
|
2199
2307
|
function security(openapi, entityContainer) {
|
|
2200
|
-
const securitySchemes = entityContainer[voc.Authorization.SecuritySchemes]
|
|
2308
|
+
const securitySchemes = entityContainer && entityContainer[voc.Authorization.SecuritySchemes] ? entityContainer[voc.Authorization.SecuritySchemes] : [];
|
|
2201
2309
|
if (securitySchemes.length > 0) openapi.security = [];
|
|
2202
2310
|
securitySchemes.forEach(scheme => {
|
|
2203
2311
|
const s = {};
|
package/lib/compile/to-xsuaa.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const cds = require
|
|
1
|
+
const cds = require('../cds')
|
|
2
2
|
const fs = require('fs')
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
@@ -99,7 +99,8 @@ module.exports = function compile_to_xsuaa (model, options) {
|
|
|
99
99
|
valueRequired: false
|
|
100
100
|
}
|
|
101
101
|
}),
|
|
102
|
-
'role-templates': roleTemplates
|
|
102
|
+
'role-templates': roleTemplates,
|
|
103
|
+
'authorities-inheritance': false
|
|
103
104
|
}
|
|
104
105
|
return mergeConfig(base, generated)
|
|
105
106
|
}
|