Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Filter out internal and private metadata #82

Merged
Show file tree
Hide file tree
Changes from 8 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
100 changes: 15 additions & 85 deletions __tests__/__snapshots__/ordCdsrc.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,6 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
{
"$schema": "https://sap.github.io/open-resource-discovery/spec-v1/interfaces/Document.schema.json",
"apiResources": [
{
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved
"apiProtocol": "odata-v4",
"description": "Description for AdminService",
"entityTypeMappings": [
{
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:BusinessPartner:v1",
},
],
},
],
"entryPoints": [
"/odata/v4/admin",
],
"extensible": {
"supported": "yes",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "sap.test.cdsrc.sample:apiResource:AdminService:v1",
"partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "openapi-v3",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/AdminService.oas3.json",
},
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/xml",
"type": "edmx",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/AdminService.edmx",
},
],
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"apiProtocol": "odata-v4",
"description": "Description for CatalogService",
Expand Down Expand Up @@ -105,6 +56,21 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
"version": "1.0.0",
"visibility": "public",
},
{
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved
"entityTypeMappings": [
{
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:BusinessPartner:v1",
},
],
},
],
"extensible": {
"supported": "yes",
},
"ordId": "sap.test.cdsrc.sample:apiResource:AdminService:v1",
},
],
"consumptionBundles": [
{
Expand Down Expand Up @@ -144,42 +110,6 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
],
"description": "this is my custom description",
"eventResources": [
{
"description": "CAP Event resource describing events / messages.",
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved
"entityTypeMappings": {
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:test-from-extension:v1",
},
],
},
"extensible": {
"supported": "yes",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "sap.test.cdsrc.sample:eventResource:AdminService:v1",
"partOfGroups": [
"sap.cds:service:sap.test.cdsrc.sample:AdminService",
],
"partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-event:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "asyncapi-v2",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/AdminService.asyncapi2.json",
},
],
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"description": "CAP Event resource describing events / messages.",
"extensible": {
Expand Down
86 changes: 0 additions & 86 deletions __tests__/__snapshots__/ordPackageJson.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,6 @@ exports[`Tests for default ORD document when .cdsrc.json is not present Successf
{
"$schema": "https://sap.github.io/open-resource-discovery/spec-v1/interfaces/Document.schema.json",
"apiResources": [
{
"apiProtocol": "odata-v4",
"description": "Description for AdminService",
"entityTypeMappings": {
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:test-from-extension:v1",
},
],
},
"entryPoints": [
"/odata/v4/admin",
],
"extensible": {
"supported": "yes",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "customer.capirebookshopordsample:apiResource:AdminService:v1",
"partOfGroups": [
"sap.cds:service:customer.capirebookshopordsample:AdminService",
],
"partOfPackage": "customer.capirebookshopordsample:package:capirebookshopordsample:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "openapi-v3",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/AdminService.oas3.json",
},
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/xml",
"type": "edmx",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/AdminService.edmx",
},
],
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved
},
{
"apiProtocol": "odata-v4",
"description": "Description for CatalogService",
Expand Down Expand Up @@ -119,42 +69,6 @@ exports[`Tests for default ORD document when .cdsrc.json is not present Successf
],
"description": "this is an application description",
"eventResources": [
{
"description": "CAP Event resource describing events / messages.",
"entityTypeMappings": {
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:test-from-extension:v1",
},
],
},
"extensible": {
"supported": "yes",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "customer.capirebookshopordsample:eventResource:AdminService:v1",
"partOfGroups": [
"sap.cds:service:customer.capirebookshopordsample:AdminService",
],
"partOfPackage": "customer.capirebookshopordsample:package:capirebookshopordsample:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "asyncapi-v2",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/AdminService.asyncapi2.json",
},
],
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"description": "CAP Event resource describing events / messages.",
"extensible": {
Expand Down
4 changes: 4 additions & 0 deletions __tests__/ordCdsrc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ describe("Tests for default ORD document when .cdsrc.json is present", () => {

test("PartOfPackage values are valid ORD IDs ", () => {
for (const apiResource of document.apiResources) {
if (!apiResource.partOfPackage) continue;
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved

expect(apiResource.partOfPackage).toMatch(PACKAGE_ID_REGEX);
}
});

test("The partOfPackage references an existing package", () => {
for (const apiResource of document.apiResources) {
if (!apiResource.partOfPackage) continue;
aramovic79 marked this conversation as resolved.
Show resolved Hide resolved

expect(
document.packages.find(
(pck) => pck.ordId === apiResource.partOfPackage
Expand Down
Loading