Skip to content

Commit acbebb3

Browse files
authored
Merge pull request finos#1752 from rocketstack-matt/calm-cleanup
CALM Schema Cleanup - shared project
2 parents 1620d5c + 72cd502 commit acbebb3

24 files changed

+32
-2017
lines changed

shared/src/commands/generate/generate.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ vi.mock('../../logger', () => {
1515
};
1616
});
1717

18-
vi.mock('../../consts', () => ({
19-
get CALM_META_SCHEMA_DIRECTORY() { return '../calm/draft/2025-03/meta'; }
20-
}));
21-
2218
vi.mock('./components/instantiate', () => ({
2319
instantiate: vi.fn(() => Promise.resolve({
2420
nodes: [{ 'unique-id': 'mock-node' }],

shared/src/commands/validate/validate.spec.ts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { validate, sortSpectralIssueBySeverity, convertSpectralDiagnosticToValidationOutputs, convertJsonSchemaIssuesToValidationOutputs, stripRefs, exitBasedOffOfValidationOutcome, extractChoicesFromArchitecture } from './validate';
2-
import { readFileSync } from 'fs';
3-
import path from 'path';
42
import { ISpectralDiagnostic } from '@stoplight/spectral-core';
53
import { ValidationOutcome, ValidationOutput } from './validation.output';
64
import { ErrorObject } from 'ajv';
@@ -196,7 +194,7 @@ describe('validation support functions', () => {
196194
const given: ErrorObject[] = [
197195
{
198196
'instancePath': '/nodes/0/interfaces/0/port',
199-
'schemaPath': 'https://calm.finos.org/draft/2024-10/meta/interface.json#/defs/host-port-interface/properties/port/type',
197+
'schemaPath': 'https://calm.finos.org/release/1.0/meta/interface.json#/defs/host-port-interface/properties/port/type',
200198
'keyword': 'type',
201199
'params': {
202200
'type': 'integer'
@@ -211,7 +209,7 @@ describe('validation support functions', () => {
211209
'error',
212210
'must be integer',
213211
'/nodes/0/interfaces/0/port',
214-
'https://calm.finos.org/draft/2024-10/meta/interface.json#/defs/host-port-interface/properties/port/type'
212+
'https://calm.finos.org/release/1.0/meta/interface.json#/defs/host-port-interface/properties/port/type'
215213
)
216214
];
217215

@@ -553,42 +551,6 @@ describe('validate - architecture only', () => {
553551
expect(response.allValidationOutputs()).not.toBeNull();
554552
expect(response.allValidationOutputs().length).toBe(0);
555553
});
556-
557-
it('validates architecture against schema specified in $schema property when no pattern provided', async () => {
558-
const expectedSpectralOutput: ISpectralDiagnostic[] = [];
559-
mocks.spectralRun.mockReturnValue(expectedSpectralOutput);
560-
561-
// Create a simple valid architecture with a CALM schema reference
562-
const validArchitecture = {
563-
'$schema': 'https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/calm.json',
564-
'nodes': [
565-
{
566-
'unique-id': 'test-node',
567-
'node-type': 'system',
568-
'name': 'Test Node',
569-
'description': 'A test node'
570-
}
571-
],
572-
'relationships': []
573-
};
574-
575-
const calmSchema = readFileSync(path.resolve(__dirname, '../../../test_fixtures/calm/calm.json'), 'utf8');
576-
const coreSchema = readFileSync(path.resolve(__dirname, '../../../test_fixtures/calm/core.json'), 'utf8');
577-
schemaDirectory.getSchema = vi.fn((id: string) => {
578-
if (id.includes('calm.json')) return JSON.parse(calmSchema);
579-
if (id.includes('core.json')) return JSON.parse(coreSchema);
580-
return undefined;
581-
});
582-
583-
const response = await validate(validArchitecture, undefined, schemaDirectory, false);
584-
585-
expect(response).not.toBeNull();
586-
expect(response).not.toBeUndefined();
587-
588-
// For a valid architecture, we should not have errors
589-
expect(response.hasErrors).toBeFalsy();
590-
expect(response.hasWarnings).toBeFalsy();
591-
});
592554
});
593555

594556
function buildISpectralDiagnostic(code: string, message: string, severity: number): ISpectralDiagnostic {

shared/src/schema-directory.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SchemaDirectory } from '.';
22
import { DocumentLoader } from './document-loader/document-loader';
33
import { readFileSync } from 'node:fs';
4+
import path from 'node:path';
45

56
vi.mock('./logger', () => {
67
return {
@@ -53,8 +54,8 @@ describe('SchemaDirectory', () => {
5354
it('resolves a reference from a stored schema', async () => {
5455
const schemaDir = new SchemaDirectory(mockDocLoader);
5556

56-
const nodeJson = loadSchema('test_fixtures/calm/core.json');
57-
const nodeRef = 'https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/core.json#/defs/node';
57+
const nodeJson = loadSchema(path.join(__dirname, '../../calm/release/1.0/meta/core.json'));
58+
const nodeRef = 'https://calm.finos.org/release/1.0/meta/core.json#/defs/node';
5859

5960
mockDocLoader.loadMissingDocument.mockReturnValueOnce(new Promise(resolve => resolve(nodeJson)));
6061

shared/test_fixtures/additional-props.json

Lines changed: 0 additions & 184 deletions
This file was deleted.

shared/test_fixtures/api-gateway-self-reference.json

Lines changed: 0 additions & 62 deletions
This file was deleted.

shared/test_fixtures/api-gateway-with-no-relationships.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/calm.json",
3-
"$id": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/pattern/api-gateway",
2+
"$schema": "https://calm.finos.org/release/1.0/meta/calm.json",
3+
"$id": "https://calm.finos.org/pattern/api-gateway",
44
"title": "API Gateway Pattern",
55
"type": "object",
66
"properties": {
@@ -9,7 +9,7 @@
99
"minItems": 3,
1010
"prefixItems": [
1111
{
12-
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/core.json#/defs/node",
12+
"$ref": "https://calm.finos.org/release/1.0/meta/core.json#/defs/node",
1313
"properties": {
1414
"ingress-host": {
1515
"type": "string"
@@ -40,7 +40,7 @@
4040
]
4141
},
4242
{
43-
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/core.json#/defs/node",
43+
"$ref": "https://calm.finos.org/release/1.0/meta/core.json#/defs/node",
4444
"properties": {
4545
"description": {
4646
"const": "The API Consumer making an authenticated and authorized request"
@@ -57,7 +57,7 @@
5757
}
5858
},
5959
{
60-
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/core.json#/defs/node",
60+
"$ref": "https://calm.finos.org/release/1.0/meta/core.json#/defs/node",
6161
"properties": {
6262
"host": {
6363
"type": "string"
@@ -84,7 +84,7 @@
8484
]
8585
},
8686
{
87-
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-03/meta/core.json#/defs/node",
87+
"$ref": "https://calm.finos.org/release/1.0/meta/core.json#/defs/node",
8888
"properties": {
8989
"description": {
9090
"const": "The Identity Provider used to verify the bearer token"

0 commit comments

Comments
 (0)