From 68642b4ddfa8cf9456d685381eb7033e8fa9ba43 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 12 Oct 2023 21:54:19 +0100 Subject: [PATCH 01/17] feat(map): add map support for jsonschemavisitor Signed-off-by: Jonathan Casey --- .../fromcto/jsonschema/jsonschemavisitor.js | 56 +++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js index 819766f0..dff2a82c 100644 --- a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -381,11 +381,6 @@ class JSONSchemaVisitor { visitField(field, parameters, isScalarUUID = false) { debug('entering visitField', field.getName()); - - if (ModelUtil.isMap?.(field)) { - return; - } - // Is this a primitive typed property? let jsonSchema; if (field.isPrimitive()) { @@ -411,6 +406,34 @@ class JSONSchemaVisitor { jsonSchema.description = 'The instance identifier for this type'; } + } else if (ModelUtil.isMap?.(field)) { + const mapDeclaration = field.getParent().getModelFile().getModelManager().getType(field.getFullyQualifiedTypeName()); + + let valueDeclaration = mapDeclaration.getModelFile() + .getAllDeclarations() + .find(decl => decl.name === mapDeclaration.getValue().getType()); + + const jsonSchema = { + $id: field.getFullyQualifiedName(), + schema: { + title: mapDeclaration.getName(), + description : `An instance of ${field.getFullyQualifiedTypeName()}`, + type: 'object', + propertyNames: { + type: 'string' + }, + additionalProperties: { + type: this.toJsonType(mapDeclaration.getValue().getType()) + } + } + }; + + // if its a ClassDeclaration, add reference to its schema. + if (valueDeclaration?.isClassDeclaration()) { + jsonSchema.schema.additionalProperties.$ref = `#/definitions/${field.getParent().getModelFile().getNamespace().concat(`.${mapDeclaration.getValue().getType()}`)}`; + } + + return jsonSchema; // Not primitive, so must be a class or enumeration! } else { // Look up the type of the property. @@ -546,6 +569,29 @@ class JSONSchemaVisitor { // Return the schema. return jsonSchema; } + + /** + * Converts a Concerto type to a JSON type. Primitive types are converted + * everything else is passed through unchanged. + * @param {string} type - the concerto type + * @return {string} the corresponding type in Json + * @private + */ + toJsonType(type) { + switch (type) { + case 'Boolean': + return 'boolean'; + case 'String': + case 'DateTime': + return 'string'; + case 'Double': + case 'Long': + case 'Integer': + return 'number'; + default: + return type; + } + } } module.exports = JSONSchemaVisitor; From aceec6e1ea56329ab71888f62fc91e70ed2d93b4 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 12 Oct 2023 21:54:49 +0100 Subject: [PATCH 02/17] test(map): test cases Signed-off-by: Jonathan Casey --- .../fromcto/jsonschema/jsonschemavisitor.js | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/test/codegen/fromcto/jsonschema/jsonschemavisitor.js b/test/codegen/fromcto/jsonschema/jsonschemavisitor.js index c4dd1bef..22e88f3c 100644 --- a/test/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/test/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -178,6 +178,63 @@ concept OtherThing identified by id { o String someId } `; + + +const MODEL_MAP_STRING = ` +namespace test + +map Dictionary { + o String + o String +} + +concept Foo { + o Dictionary dictionary +} +`; + +const MODEL_MAP_NUMBER = ` +namespace test + +map Dictionary { + o String + o Double +} + +concept Foo { + o Dictionary dictionary +} +`; + +const MODEL_MAP_BOOLEAN = ` +namespace test + +map Dictionary { + o String + o Boolean +} + +concept Foo { + o Dictionary dictionary +} +`; + +const MODEL_MAP_COMPLEX = ` +namespace test + +concept Person { + o String name +} +map Dictionary { + o String + o Person +} + +concept Foo { + o Dictionary dictionary +} +`; + const MODEL_RELATIONSHIP_SIMPLE = ` namespace test @@ -287,6 +344,57 @@ describe('JSONSchema (samples)', function () { expect(schema.properties.someId.format).to.be.undefined; }); + it('should generate for Map of type ', () => { + const modelManager = new ModelManager(); + modelManager.addCTOModel( MODEL_MAP_STRING ); + const visitor = new JSONSchemaVisitor(); + const schema = modelManager.accept(visitor, { rootType: 'test.Foo'}); + expect(schema.properties.dictionary.schema.title).equal('Dictionary'); + expect(schema.properties.dictionary.schema.description).equal('An instance of test.Dictionary'); + expect(schema.properties.dictionary.schema.type).equal('object'); + expect(schema.properties.dictionary.schema.propertyNames.type).equal('string'); + expect(schema.properties.dictionary.schema.additionalProperties.type).equal('string'); + }); + + + it('should generate for Map of type ', () => { + const modelManager = new ModelManager(); + modelManager.addCTOModel( MODEL_MAP_COMPLEX ); + const visitor = new JSONSchemaVisitor(); + const schema = modelManager.accept(visitor, { rootType: 'test.Foo'}); + expect(schema.properties.dictionary.schema.title).equal('Dictionary'); + expect(schema.properties.dictionary.schema.description).equal('An instance of test.Dictionary'); + expect(schema.properties.dictionary.schema.type).equal('object'); + expect(schema.properties.dictionary.schema.propertyNames.type).equal('string'); + expect(schema.properties.dictionary.schema.additionalProperties.type).equal('Person'); + expect(schema.properties.dictionary.schema.additionalProperties.$ref).equal('#/definitions/test.Person'); + }); + + it('should generate for Map of type ', () => { + const modelManager = new ModelManager(); + modelManager.addCTOModel( MODEL_MAP_NUMBER ); + const visitor = new JSONSchemaVisitor(); + const schema = modelManager.accept(visitor, { rootType: 'test.Foo'}); + expect(schema.properties.dictionary.schema.title).equal('Dictionary'); + expect(schema.properties.dictionary.schema.description).equal('An instance of test.Dictionary'); + expect(schema.properties.dictionary.schema.type).equal('object'); + expect(schema.properties.dictionary.schema.propertyNames.type).equal('string'); + expect(schema.properties.dictionary.schema.additionalProperties.type).equal('number'); + }); + + + it('should generate for Map of type ', () => { + const modelManager = new ModelManager(); + modelManager.addCTOModel( MODEL_MAP_BOOLEAN ); + const visitor = new JSONSchemaVisitor(); + const schema = modelManager.accept(visitor, { rootType: 'test.Foo'}); + expect(schema.properties.dictionary.schema.title).equal('Dictionary'); + expect(schema.properties.dictionary.schema.description).equal('An instance of test.Dictionary'); + expect(schema.properties.dictionary.schema.type).equal('object'); + expect(schema.properties.dictionary.schema.propertyNames.type).equal('string'); + expect(schema.properties.dictionary.schema.additionalProperties.type).equal('boolean'); + }); + it('should use min max length for string fields when length validator is configured', () => { const modelManager = new ModelManager(); modelManager.addCTOModel(fs.readFileSync(path.resolve(__dirname, '../data/model/stringlength.cto'), 'utf8'), 'stringlength.cto'); From 464674131bb1b3a9895fd06071c4dfe265caf908 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 12 Oct 2023 21:54:58 +0100 Subject: [PATCH 03/17] test(map): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 340 +++++++++++++++++++++ 1 file changed, 340 insertions(+) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index b031ca12..2bdf5f72 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1476,6 +1476,91 @@ exports[`codegen #formats check we can convert all formats from namespace unvers }, "country": { "type": "string" + }, + "dictionary1": { + "$id": "org.acme.hr.Address.dictionary1", + "schema": { + "title": "Map1", + "description": "An instance of org.acme.hr.Map1", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary2": { + "$id": "org.acme.hr.Address.dictionary2", + "schema": { + "title": "Map2", + "description": "An instance of org.acme.hr.Map2", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary3": { + "$id": "org.acme.hr.Address.dictionary3", + "schema": { + "title": "Map3", + "description": "An instance of org.acme.hr.Map3", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "SSN" + } + } + }, + "dictionary4": { + "$id": "org.acme.hr.Address.dictionary4", + "schema": { + "title": "Map4", + "description": "An instance of org.acme.hr.Map4", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Concept" + } + } + }, + "dictionary5": { + "$id": "org.acme.hr.Address.dictionary5", + "schema": { + "title": "Map5", + "description": "An instance of org.acme.hr.Map5", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary6": { + "$id": "org.acme.hr.Address.dictionary6", + "schema": { + "title": "Map6", + "description": "An instance of org.acme.hr.Map6", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Employee", + "$ref": "#/definitions/org.acme.hr.Employee" + } + } } }, "required": [ @@ -2505,6 +2590,91 @@ exports[`codegen #formats check we can convert all formats from namespace unvers }, "country": { "type": "string" + }, + "dictionary1": { + "$id": "org.acme.hr.Address.dictionary1", + "schema": { + "title": "Map1", + "description": "An instance of org.acme.hr.Map1", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary2": { + "$id": "org.acme.hr.Address.dictionary2", + "schema": { + "title": "Map2", + "description": "An instance of org.acme.hr.Map2", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary3": { + "$id": "org.acme.hr.Address.dictionary3", + "schema": { + "title": "Map3", + "description": "An instance of org.acme.hr.Map3", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "SSN" + } + } + }, + "dictionary4": { + "$id": "org.acme.hr.Address.dictionary4", + "schema": { + "title": "Map4", + "description": "An instance of org.acme.hr.Map4", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Concept" + } + } + }, + "dictionary5": { + "$id": "org.acme.hr.Address.dictionary5", + "schema": { + "title": "Map5", + "description": "An instance of org.acme.hr.Map5", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary6": { + "$id": "org.acme.hr.Address.dictionary6", + "schema": { + "title": "Map6", + "description": "An instance of org.acme.hr.Map6", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Employee", + "$ref": "#/definitions/org.acme.hr.Employee" + } + } } }, "required": [ @@ -6602,6 +6772,91 @@ exports[`codegen #formats check we can convert all formats from namespace versio }, "country": { "type": "string" + }, + "dictionary1": { + "$id": "org.acme.hr@1.0.0.Address.dictionary1", + "schema": { + "title": "Map1", + "description": "An instance of org.acme.hr@1.0.0.Map1", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary2": { + "$id": "org.acme.hr@1.0.0.Address.dictionary2", + "schema": { + "title": "Map2", + "description": "An instance of org.acme.hr@1.0.0.Map2", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary3": { + "$id": "org.acme.hr@1.0.0.Address.dictionary3", + "schema": { + "title": "Map3", + "description": "An instance of org.acme.hr@1.0.0.Map3", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "SSN" + } + } + }, + "dictionary4": { + "$id": "org.acme.hr@1.0.0.Address.dictionary4", + "schema": { + "title": "Map4", + "description": "An instance of org.acme.hr@1.0.0.Map4", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Concept" + } + } + }, + "dictionary5": { + "$id": "org.acme.hr@1.0.0.Address.dictionary5", + "schema": { + "title": "Map5", + "description": "An instance of org.acme.hr@1.0.0.Map5", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary6": { + "$id": "org.acme.hr@1.0.0.Address.dictionary6", + "schema": { + "title": "Map6", + "description": "An instance of org.acme.hr@1.0.0.Map6", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Employee", + "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" + } + } } }, "required": [ @@ -7647,6 +7902,91 @@ exports[`codegen #formats check we can convert all formats from namespace versio }, "country": { "type": "string" + }, + "dictionary1": { + "$id": "org.acme.hr@1.0.0.Address.dictionary1", + "schema": { + "title": "Map1", + "description": "An instance of org.acme.hr@1.0.0.Map1", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary2": { + "$id": "org.acme.hr@1.0.0.Address.dictionary2", + "schema": { + "title": "Map2", + "description": "An instance of org.acme.hr@1.0.0.Map2", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary3": { + "$id": "org.acme.hr@1.0.0.Address.dictionary3", + "schema": { + "title": "Map3", + "description": "An instance of org.acme.hr@1.0.0.Map3", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "SSN" + } + } + }, + "dictionary4": { + "$id": "org.acme.hr@1.0.0.Address.dictionary4", + "schema": { + "title": "Map4", + "description": "An instance of org.acme.hr@1.0.0.Map4", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Concept" + } + } + }, + "dictionary5": { + "$id": "org.acme.hr@1.0.0.Address.dictionary5", + "schema": { + "title": "Map5", + "description": "An instance of org.acme.hr@1.0.0.Map5", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "string" + } + } + }, + "dictionary6": { + "$id": "org.acme.hr@1.0.0.Address.dictionary6", + "schema": { + "title": "Map6", + "description": "An instance of org.acme.hr@1.0.0.Map6", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "Employee", + "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" + } + } } }, "required": [ From b7a9f41e809e296d3659d3b81164460e52ff9fd3 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 12 Oct 2023 21:58:56 +0100 Subject: [PATCH 04/17] feat(map): add type defs Signed-off-by: Jonathan Casey --- .../lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts b/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts index 3c6a6ffe..08fd13f6 100644 --- a/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts +++ b/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts @@ -162,4 +162,12 @@ declare class JSONSchemaVisitor { * @private */ private visitRelationshipDeclaration; + /** + * Converts a Concerto type to a JSON type. Primitive types are converted + * everything else is passed through unchanged. + * @param {string} type - the concerto type + * @return {string} the corresponding type in Json + * @private + */ + private toJsonType; } From 9c54ae1b3bed1d8a0175635d98a8bf45de439672 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 19 Oct 2023 09:47:50 +0100 Subject: [PATCH 05/17] feat(map): remove redundant property from additionalProperties Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/jsonschema/jsonschemavisitor.js | 2 +- test/codegen/__snapshots__/codegen.js.snap | 4 ---- test/codegen/fromcto/jsonschema/jsonschemavisitor.js | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js index dff2a82c..add81245 100644 --- a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -430,7 +430,7 @@ class JSONSchemaVisitor { // if its a ClassDeclaration, add reference to its schema. if (valueDeclaration?.isClassDeclaration()) { - jsonSchema.schema.additionalProperties.$ref = `#/definitions/${field.getParent().getModelFile().getNamespace().concat(`.${mapDeclaration.getValue().getType()}`)}`; + jsonSchema.schema.additionalProperties = {$ref: `#/definitions/${field.getParent().getModelFile().getNamespace().concat(`.${mapDeclaration.getValue().getType()}`)}`}; } return jsonSchema; diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 2bdf5f72..4f12c437 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1557,7 +1557,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "additionalProperties": { - "type": "Employee", "$ref": "#/definitions/org.acme.hr.Employee" } } @@ -2671,7 +2670,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "additionalProperties": { - "type": "Employee", "$ref": "#/definitions/org.acme.hr.Employee" } } @@ -6853,7 +6851,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "additionalProperties": { - "type": "Employee", "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" } } @@ -7983,7 +7980,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "additionalProperties": { - "type": "Employee", "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" } } diff --git a/test/codegen/fromcto/jsonschema/jsonschemavisitor.js b/test/codegen/fromcto/jsonschema/jsonschemavisitor.js index 22e88f3c..f0fe8774 100644 --- a/test/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/test/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -366,7 +366,6 @@ describe('JSONSchema (samples)', function () { expect(schema.properties.dictionary.schema.description).equal('An instance of test.Dictionary'); expect(schema.properties.dictionary.schema.type).equal('object'); expect(schema.properties.dictionary.schema.propertyNames.type).equal('string'); - expect(schema.properties.dictionary.schema.additionalProperties.type).equal('Person'); expect(schema.properties.dictionary.schema.additionalProperties.$ref).equal('#/definitions/test.Person'); }); From 635ee29513cd3d8a28f3e713fc2d5f1758bdca73 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Thu, 19 Oct 2023 10:42:53 +0100 Subject: [PATCH 06/17] feat(map): use getFieldOrScalarDeclarationValidatorsForSchema to get the type Signed-off-by: Jonathan Casey --- .../fromcto/jsonschema/jsonschemavisitor.js | 39 +++++-------------- .../fromcto/jsonschema/jsonschemavisitor.d.ts | 11 +----- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js index add81245..693ba8b7 100644 --- a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -60,16 +60,16 @@ class JSONSchemaVisitor { /** * Get the validators for a field or a scalar definition in JSON schema form. - * @param {Object} field - the scalar declaration being visited + * @param {Object} type - the scalar declaration being visited * @param {bool} [isScalarUUID] - flag to indicate given field type is scalar uuid + * @param {bool} [validator] - the field validator * @return {Object} the result of visiting or null * @private */ - getFieldOrScalarDeclarationValidatorsForSchema(field, isScalarUUID = false) { - const validator = field.getValidator(); + getFieldOrScalarDeclarationValidatorsForSchema(type, isScalarUUID = false, validator) { let jsonSchema = {}; - switch (field.getType()) { + switch (type) { case 'String': jsonSchema.type = 'string'; if (isScalarUUID) { @@ -117,6 +117,8 @@ class JSONSchemaVisitor { case 'Boolean': jsonSchema.type = 'boolean'; break; + default: + jsonSchema.type = type; } return jsonSchema; @@ -354,7 +356,7 @@ class JSONSchemaVisitor { debug('entering visitScalarDeclaration', scalarDeclaration.getName()); return { $id: scalarDeclaration.getFullyQualifiedName(), - schema: this.getFieldOrScalarDeclarationValidatorsForSchema(scalarDeclaration) + schema: this.getFieldOrScalarDeclarationValidatorsForSchema(scalarDeclaration.getType(), false, scalarDeclaration.getValidator()) }; } @@ -393,7 +395,7 @@ class JSONSchemaVisitor { jsonSchema = { ...jsonSchema, - ...this.getFieldOrScalarDeclarationValidatorsForSchema(field, isScalarUUID) + ...this.getFieldOrScalarDeclarationValidatorsForSchema(field.getType(), isScalarUUID, field.getValidator()) }; // If this field has a default value, add it. @@ -423,7 +425,7 @@ class JSONSchemaVisitor { type: 'string' }, additionalProperties: { - type: this.toJsonType(mapDeclaration.getValue().getType()) + type: this.getFieldOrScalarDeclarationValidatorsForSchema(mapDeclaration.getValue().getType()).type } } }; @@ -569,29 +571,6 @@ class JSONSchemaVisitor { // Return the schema. return jsonSchema; } - - /** - * Converts a Concerto type to a JSON type. Primitive types are converted - * everything else is passed through unchanged. - * @param {string} type - the concerto type - * @return {string} the corresponding type in Json - * @private - */ - toJsonType(type) { - switch (type) { - case 'Boolean': - return 'boolean'; - case 'String': - case 'DateTime': - return 'string'; - case 'Double': - case 'Long': - case 'Integer': - return 'number'; - default: - return type; - } - } } module.exports = JSONSchemaVisitor; diff --git a/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts b/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts index 08fd13f6..ab763b43 100644 --- a/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts +++ b/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts @@ -30,8 +30,9 @@ declare class JSONSchemaVisitor { getDecorators(decorated: object): object; /** * Get the validators for a field or a scalar definition in JSON schema form. - * @param {Object} field - the scalar declaration being visited + * @param {Object} type - the scalar declaration being visited * @param {bool} [isScalarUUID] - flag to indicate given field type is scalar uuid + * @param {bool} [validator] - the field validator * @return {Object} the result of visiting or null * @private */ @@ -162,12 +163,4 @@ declare class JSONSchemaVisitor { * @private */ private visitRelationshipDeclaration; - /** - * Converts a Concerto type to a JSON type. Primitive types are converted - * everything else is passed through unchanged. - * @param {string} type - the concerto type - * @return {string} the corresponding type in Json - * @private - */ - private toJsonType; } From 5f2f7a6c52f7ff33a8e3763a5d58b35da45e8756 Mon Sep 17 00:00:00 2001 From: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:17:02 +0100 Subject: [PATCH 07/17] feat(map): Codegen for GraphQL Target (#66) * feat(map): add graphqlvisitor Signed-off-by: Jonathan Casey * test(map): update snapshot Signed-off-by: Jonathan Casey * test(map): adds graphqlvisitor Signed-off-by: Jonathan Casey * test(map): restores sandbox Signed-off-by: Jonathan Casey --------- Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/graphql/graphqlvisitor.js | 25 +++++++++- test/codegen/__snapshots__/codegen.js.snap | 48 +++++++++++++++++++ .../codegen/fromcto/graphql/graphqlvisitor.js | 35 ++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/lib/codegen/fromcto/graphql/graphqlvisitor.js b/lib/codegen/fromcto/graphql/graphqlvisitor.js index bb0f2323..a8100b3c 100644 --- a/lib/codegen/fromcto/graphql/graphqlvisitor.js +++ b/lib/codegen/fromcto/graphql/graphqlvisitor.js @@ -15,6 +15,7 @@ 'use strict'; const util = require('util'); +const { ModelUtil } = require('@accordproject/concerto-core'); /** * Convert the contents of a ModelManager to GraphQL types, based on @@ -52,7 +53,7 @@ class GraphQLVisitor { } else if (thing.isField?.()) { return this.visitField(thing, parameters); } else if (thing.isMapDeclaration?.()) { - return; + return this.visitMapDeclaration(thing, parameters); } else if (thing.isRelationship?.()) { return this.visitRelationship(thing, parameters); } else if (thing.isEnumValue?.()) { @@ -171,6 +172,28 @@ class GraphQLVisitor { return null; } + /** + * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + visitMapDeclaration(mapDeclaration, parameters) { + const keyType = mapDeclaration.getKey().getType(); + const valueType = mapDeclaration.getValue().getType(); + + let key = ModelUtil.isPrimitiveType(keyType) ? this.toGraphQLType(keyType) : keyType; + let value = ModelUtil.isPrimitiveType(valueType) ? this.toGraphQLType(valueType) : valueType; + + parameters.fileWriter.writeLine(0, `type ${mapDeclaration.getName()} {`); + parameters.fileWriter.writeLine(1, `key: ${key}`); + parameters.fileWriter.writeLine(1, `value: ${value}`); + parameters.fileWriter.writeLine(0, '}'); + + return null; + } + /** * Visitor design pattern * @param {Relationship} relationship - the object being visited diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 4f12c437..cd085d53 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -632,6 +632,30 @@ type Address { dictionary5: Map5! dictionary6: Map6! } +type Map1 { + key: String + value: String +} +type Map2 { + key: String + value: DateTime +} +type Map3 { + key: String + value: SSN +} +type Map4 { + key: String + value: Concept +} +type Map5 { + key: SSN + value: String +} +type Map6 { + key: SSN + value: Employee +} type Company { name: String! headquarters: Address! @@ -5926,6 +5950,30 @@ type Address { dictionary5: Map5! dictionary6: Map6! } +type Map1 { + key: String + value: String +} +type Map2 { + key: String + value: DateTime +} +type Map3 { + key: String + value: SSN +} +type Map4 { + key: String + value: Concept +} +type Map5 { + key: SSN + value: String +} +type Map6 { + key: SSN + value: Employee +} type Company { name: String! headquarters: Address! diff --git a/test/codegen/fromcto/graphql/graphqlvisitor.js b/test/codegen/fromcto/graphql/graphqlvisitor.js index 1bf7db3a..a944000a 100644 --- a/test/codegen/fromcto/graphql/graphqlvisitor.js +++ b/test/codegen/fromcto/graphql/graphqlvisitor.js @@ -23,10 +23,14 @@ const GraphQLVisitor = require('../../../../lib/codegen/fromcto/graphql/graphqlv const ModelFile = require('@accordproject/concerto-core').ModelFile; const ModelManager = require('@accordproject/concerto-core').ModelManager; const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; +const MapDeclaration = require('@accordproject/concerto-core').MapDeclaration; const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration; const Field = require('@accordproject/concerto-core').Field; const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; +const { ModelUtil } = require('@accordproject/concerto-core'); + +let sandbox = sinon.createSandbox(); const MODEL_WITH_DECORATORS = ` namespace test @@ -339,6 +343,37 @@ describe('GraphQLVisitor', function () { }); }); + describe('visitMapDeclaration', () => { + it('should write a type for a Map', () => { + let param = { + fileWriter: mockFileWriter + }; + + sandbox.stub(ModelUtil, 'isPrimitiveType').callsFake(() => { + return true; + }); + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + getKeyType.returns('String'); + getValueType.returns('String'); + mockMapDeclaration.getName.returns('map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + graphQLVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.withArgs(0, 'type map1 {').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'key: String').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'value: String').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(0, '}').calledOnce.should.be.ok; + + sandbox.restore(); + }); + }); + describe('visitRelationship', () => { it('should write a line for a relationship', () => { let param = { From 511616891e8add61764b2bd24a3aa2741e311009 Mon Sep 17 00:00:00 2001 From: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:17:25 +0100 Subject: [PATCH 08/17] feat!(codegen): remove loopback src (#59) feat(codegen): remove loopback src Signed-off-by: Jonathan Casey --- .../fromcto/loopback/loopbackvisitor.js | 584 ------- .../fromcto/loopback/loopbackvisitor.js | 1367 ----------------- .../loopback/loopbackvisitorcircular.js | 64 - 3 files changed, 2015 deletions(-) delete mode 100644 lib/codegen/fromcto/loopback/loopbackvisitor.js delete mode 100644 test/codegen/fromcto/loopback/loopbackvisitor.js delete mode 100644 test/codegen/fromcto/loopback/loopbackvisitorcircular.js diff --git a/lib/codegen/fromcto/loopback/loopbackvisitor.js b/lib/codegen/fromcto/loopback/loopbackvisitor.js deleted file mode 100644 index 339da9b4..00000000 --- a/lib/codegen/fromcto/loopback/loopbackvisitor.js +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const debug = require('debug')('concerto-core:loopbackvisitor'); -const util = require('util'); - -/** - * Convert a fully qualified type name, for example org.example.mynetwork.MyAsset, - * into a name that is safe for use as a LoopBack model name. - * @private - * @param {String} fqn The fully qualified type name. - * @returns {String} A name that is safe for use as a LoopBack model name. - */ -function loopbackify(fqn) { - return fqn.replace(/\./g, '_'); -} - -/** - * Convert the contents of a {@link ModelManager} instance to a set of LoopBack - * Definition Language model files - one per concrete asset and transaction type. - * Set a fileWriter property (instance of {@link FileWriter}) on the parameters - * object to control where the generated code is written to disk. - * @private - * @class - * @memberof module:concerto-codegen - */ -class LoopbackVisitor { - - /** - * Constructor. - * @param {boolean} [namespaces] - whether or not namespaces should be used. - */ - constructor(namespaces) { - this.namespaces = !!namespaces; - } - - /** - * Visitor design pattern - * @param {Object} thing - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @public - */ - visit(thing, parameters) { - if (thing.isModelManager?.()) { - return this.visitModelManager(thing, parameters); - } else if (thing.isModelFile?.()) { - return this.visitModelFile(thing, parameters); - } else if (thing.isAsset?.()) { - return this.visitAssetDeclaration(thing, parameters); - } else if (thing.isParticipant?.()) { - return this.visitParticipantDeclaration(thing, parameters); - } else if (thing.isConcept?.()) { - return this.visitConceptDeclaration(thing, parameters); - } else if (thing.isMapDeclaration?.()) { - return; - } else if (thing.isTransaction?.()) { - return this.visitTransactionDeclaration(thing, parameters); - } else if (thing.isEvent?.()) { - return this.visitEventDeclaration(thing, parameters); - } else if (thing.isEnum?.()) { - return this.visitEnumDeclaration(thing, parameters); - } else if (thing.isTypeScalar?.()) { - return this.visitField(thing.getScalarField(), parameters); - } else if (thing.isField?.()) { - return this.visitField(thing, parameters); - } else if (thing.isRelationship?.()) { - return this.visitRelationshipDeclaration(thing, parameters); - } else if (thing.isEnumValue?.()) { - return this.visitEnumValueDeclaration(thing, parameters); - } else { - throw new Error('Unrecognised type: ' + typeof thing + ', value: ' + util.inspect(thing, { showHidden: true, depth: 1 })); - } - } - - /** - * Visitor design pattern - * @param {ModelManager} modelManager - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitModelManager(modelManager, parameters) { - debug('entering visitModelManager'); - - // Save the model manager so that we have access to it later. - parameters.modelManager = modelManager; - - // Visit all of the files in the model manager. - let jsonSchemas = []; - modelManager.getModelFiles().forEach((modelFile) => { - jsonSchemas = jsonSchemas.concat(modelFile.accept(this, parameters)); - }); - return jsonSchemas; - - } - - /** - * Visitor design pattern - * @param {ModelFile} modelFile - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitModelFile(modelFile, parameters) { - debug('entering visitModelFile', modelFile.getNamespace()); - - // Save the model file so that we have access to it later. - parameters.modelFile = modelFile; - - // Visit all of the asset and transaction declarations, but ignore the abstract ones. - let jsonSchemas = []; - modelFile.getAssetDeclarations() - .concat(modelFile.getConceptDeclarations()) - .concat(modelFile.getParticipantDeclarations()) - .concat(modelFile.getTransactionDeclarations()) - .forEach((declaration) => { - parameters.first = true; - jsonSchemas.push(declaration.accept(this, parameters)); - }); - return jsonSchemas; - - } - - /** - * Visitor design pattern - * @param {AssetDeclaration} assetDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitAssetDeclaration(assetDeclaration, parameters) { - debug('entering visitAssetDeclaration', assetDeclaration.getName()); - - // If this is the first declaration, then we are building a schema for this asset. - let jsonSchema = {}; - let name = this.namespaces ? assetDeclaration.getFullyQualifiedName() : assetDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `An asset named ${assetDeclaration.getName()}`, - plural: name, - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'asset' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(assetDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {ParticipantDeclaration} participantDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitParticipantDeclaration(participantDeclaration, parameters) { - debug('entering visitParticipantDeclaration', participantDeclaration.getName()); - - // If this is the first declaration, then we are building a schema for this participant. - let jsonSchema = {}; - let name = this.namespaces ? participantDeclaration.getFullyQualifiedName() : participantDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `A participant named ${participantDeclaration.getName()}`, - plural: name, - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'participant' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(participantDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {ConceptDeclaration} conceptDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitConceptDeclaration(conceptDeclaration, parameters) { - debug('entering visitConceptDeclaration', conceptDeclaration.getName()); - - // If this is the top declaration, then we are building a schema for this concept. - let jsonSchema = {}; - let name = this.namespaces ? conceptDeclaration.getFullyQualifiedName() : conceptDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `A concept named ${conceptDeclaration.getName()}`, - plural: name, - // Concepts are not PersistedModel instances as they cannot exist by themselves. - // base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'concept' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(conceptDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {TransactionDeclaration} transactionDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitTransactionDeclaration(transactionDeclaration, parameters) { - debug('entering visitTransactionDeclaration', transactionDeclaration.getName()); - - // If this is the top declaration, then we are building a schema for this transaction. - let jsonSchema = {}; - let name = this.namespaces ? transactionDeclaration.getFullyQualifiedName() : transactionDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `A transaction named ${transactionDeclaration.getName()}`, - plural: name, - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'transaction' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(transactionDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {EventDeclaration} eventDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitEventDeclaration(eventDeclaration, parameters) { - debug('entering visitEventDeclaration', eventDeclaration.getName()); - return null; - } - - /** - * Visitor design pattern - * @param {ClassDeclaration} classDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @param {Object} jsonSchema - the base JSON Schema object to use - * @return {Object} the result of visiting or null - * @private - */ - visitClassDeclarationCommon(classDeclaration, parameters, jsonSchema) { - debug('entering visitClassDeclarationCommon', classDeclaration.getName()); - - // remember that we have visited this fqn - // in case one of our properties is of the same type (issue #2193) - parameters[classDeclaration.getFullyQualifiedName()] = 'visited'; - - // Add information from the class declaration into the composer section. - if (jsonSchema.options && jsonSchema.options.composer) { - Object.assign(jsonSchema.options.composer, { - namespace: classDeclaration.getNamespace(), - name: classDeclaration.getName(), - fqn: classDeclaration.getFullyQualifiedName(), - abstract: classDeclaration.isAbstract() - }); - } - - // Set the required properties into the schema. - Object.assign(jsonSchema, { - properties: {} - }); - - // If no description exists, add it now. - if (!jsonSchema.description) { - jsonSchema.description = `An instance of ${classDeclaration.getName()}`; - } - - // Every class declaration has a $class property. - jsonSchema.properties.$class = { - type: 'string', - default: classDeclaration.getFullyQualifiedName(), - required: false, - description: 'The class identifier for this type' - }; - - // Walk over all of the properties of this class and its super classes. - classDeclaration.getProperties().forEach((property) => { - - // Get the schema for the property - jsonSchema.properties[property.getName()] = property.accept(this, parameters); - }); - - // For transaction declarations, we need to change the model slightly. - if (classDeclaration.getIdentifierFieldName()) { - // The ID field will be supplied at submission time, not by the client. - jsonSchema.forceId = true; - const identifierFieldName = classDeclaration.getIdentifierFieldName(); - jsonSchema.properties[identifierFieldName].generated = true; - jsonSchema.properties[identifierFieldName].required = false; - } - - // If this is a top level schema, now we need to write it to disk. - if (jsonSchema.$first) { - delete jsonSchema.$first; - let fileContents = JSON.stringify(jsonSchema, null, 4); - if (parameters.fileWriter) { - let name = this.namespaces ? classDeclaration.getFullyQualifiedName() : classDeclaration.getName(); - let fileName = `${name}.json`; - parameters.fileWriter.openFile(fileName); - parameters.fileWriter.write(fileContents); - parameters.fileWriter.closeFile(); - } - } - - // Return the created schema. - return jsonSchema; - - } - - /** - * Given a primitive Concerto type returns the corresponding loopback type - * @param {string} type - the concerto primitive type name - * @return {string} the loopback type - * @private - */ - static toLoopbackType(type) { - - let result = 'string'; - - switch (type) { - case 'String': - result = 'string'; - break; - case 'Double': - case 'Integer': - case 'Long': - result= 'number'; - break; - case 'DateTime': - result = 'date'; - break; - case 'Boolean': - result = 'boolean'; - break; - } - - return result; - } - - /** - * Visitor design pattern - * @param {Field} field - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitField(field, parameters) { - debug('entering visitField', field.getName()); - - // Is this a primitive typed property? - let jsonSchema; - if (field.isPrimitive()) { - - // Render the type as JSON Schema. - jsonSchema = {}; - jsonSchema.type = LoopbackVisitor.toLoopbackType(field.getType()); - - // If this field has a default value, add it. - if (field.getDefaultValue()) { - jsonSchema.default = field.getDefaultValue(); - } - - // If this is the identifying field, mark it as such. - if (field.getName() === field.getParent().getIdentifierFieldName()) { - jsonSchema.id = true; - jsonSchema.description = 'The instance identifier for this type'; - } - - // Is this an enumeration? - } else if (field.isTypeEnum()) { - - // Look up the type of the property. - let type = field.getParent().getModelFile().getType(field.getType()); - - // Visit it, and grab the schema. - jsonSchema = type.accept(this, parameters); - - // If this field has a default value, add it. - if (field.getDefaultValue()) { - jsonSchema.default = field.getDefaultValue(); - } - - // Not primitive, so must be a class! - } else { - - // Render the type as JSON Schema. - let typeName = this.namespaces ? field.getFullyQualifiedTypeName() : field.getType(); - jsonSchema = { - type: loopbackify(typeName) - }; - - // Look up the type of the property. - let type = field.getParent().getModelFile().getType(field.getType()); - - // Visit it, but ignore the response. - // We do not visit types that have already been visited to prevent recursion (issue #2193) - if(!parameters[field.getFullyQualifiedTypeName()]) { - type.accept(this, parameters); - } - } - - // Is the type an array? - if (field.isArray()) { - - // Set the type to an array of the already set type from above. - jsonSchema.type = [ jsonSchema.type ]; - - // Array properties have to be optional and have a default value as LoopBack does not cope with - // the difference between a required array property and an empty array property (issue #3438). - jsonSchema.default = []; - jsonSchema.required = false; - - } else { - - // Is the field required? - jsonSchema.required = !field.isOptional(); - - } - - // Return the schema. - return jsonSchema; - - } - - /** - * Visitor design pattern - * @param {EnumDeclaration} enumDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitEnumDeclaration(enumDeclaration, parameters) { - debug('entering visitEnumDeclaration', enumDeclaration.getName()); - - // Create the schema. - let jsonSchema = { - type: 'string' - }; - - // Walk over all of the properties which should just be enum value declarations. - jsonSchema.enum = enumDeclaration.getProperties().map((property) => { - return property.accept(this, parameters); - }); - - // Return the schema. - return jsonSchema; - - } - - /** - * Visitor design pattern - * @param {EnumValueDeclaration} enumValueDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitEnumValueDeclaration(enumValueDeclaration, parameters) { - debug('entering visitEnumValueDeclaration', enumValueDeclaration.getName()); - - // The schema in this case is just the name of the value. - return enumValueDeclaration.getName(); - - } - - /** - * Visitor design pattern - * @param {RelationshipDeclaration} relationshipDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitRelationshipDeclaration(relationshipDeclaration, parameters) { - debug('entering visitRelationship', relationshipDeclaration.getName()); - - // Create the schema. - let jsonSchema = { - type: 'any', - description: `The identifier of an instance of ${relationshipDeclaration.getName()}`, - required: !relationshipDeclaration.isOptional() - }; - - // Is the type an array? - if (relationshipDeclaration.isArray()) { - jsonSchema.type = [ jsonSchema.type ]; - } - - // Return the schema. - return jsonSchema; - - } - -} - -module.exports = LoopbackVisitor; diff --git a/test/codegen/fromcto/loopback/loopbackvisitor.js b/test/codegen/fromcto/loopback/loopbackvisitor.js deleted file mode 100644 index 1905efdf..00000000 --- a/test/codegen/fromcto/loopback/loopbackvisitor.js +++ /dev/null @@ -1,1367 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const chai = require('chai'); -const should = chai.should(); -const sinon = require('sinon'); - -let LoopbackVisitor= require('../../../../lib/codegen/fromcto/loopback/loopbackvisitor.js'); - -const AssetDeclaration = require('@accordproject/concerto-core').AssetDeclaration; -const ParticipantDeclaration = require('@accordproject/concerto-core').ParticipantDeclaration; -const EventDeclaration = require('@accordproject/concerto-core').EventDeclaration; -const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; -const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration; -const ConceptDeclaration = require('@accordproject/concerto-core').ConceptDeclaration; -const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration; -const Field = require('@accordproject/concerto-core').Field; -const ModelFile = require('@accordproject/concerto-core').ModelFile; -const ModelManager = require('@accordproject/concerto-core').ModelManager; -const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; -const TransactionDeclaration = require('@accordproject/concerto-core').TransactionDeclaration; -const FileWriter = require('@accordproject/concerto-util').FileWriter; - -describe('LoopbackVisitor', () => { - let loopbackVisit; - let mockFileWriter; - beforeEach(() => { - loopbackVisit = new LoopbackVisitor(); - mockFileWriter = sinon.createStubInstance(FileWriter); - }); - - describe('visit', () => { - let param; - beforeEach(() => { - param = { - property1: 'value1' - }; - }); - - it('should call visitModelManager for a ModelManager', () => { - let thing = sinon.createStubInstance(ModelManager); - thing.isModelManager.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitModelManager'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitModelFile for a ModelFile', () => { - let thing = sinon.createStubInstance(ModelFile); - thing.isModelFile.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitModelFile'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitAssetDeclaration for a AssetDeclaration', () => { - let thing = sinon.createStubInstance(AssetDeclaration); - thing.isAsset.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitAssetDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitParticipantDeclaration for a ParticipantDeclaration', () => { - let thing = sinon.createStubInstance(ParticipantDeclaration); - thing.isParticipant.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitParticipantDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitConceptDeclaration for a ConceptDeclaration', () => { - let thing = sinon.createStubInstance(ConceptDeclaration); - thing.isConcept.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitConceptDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitTransactionDeclaration for a TransactionDeclaration', () => { - let thing = sinon.createStubInstance(TransactionDeclaration); - thing.isTransaction.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitTransactionDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitEventDeclaration for a EventDeclaration', () => { - let thing = sinon.createStubInstance(EventDeclaration); - thing.isEvent.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitEventDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitEnumDeclaration for a EnumDeclaration', () => { - let thing = sinon.createStubInstance(EnumDeclaration); - thing.isEnum.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitEnumDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitField for a Field', () => { - let thing = sinon.createStubInstance(Field); - thing.isField.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitField'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitRelationshipDeclaration for a RelationshipDeclaration', () => { - let thing = sinon.createStubInstance(RelationshipDeclaration); - thing.isRelationship.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitRelationshipDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitEnumValueDeclaration for a EnumValueDeclaration', () => { - let thing = sinon.createStubInstance(EnumValueDeclaration); - thing.isEnumValue.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitEnumValueDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should throw an error when an unrecognised type is supplied', () => { - let thing = 'Something of unrecognised type'; - - (() => { - loopbackVisit.visit(thing, param); - }).should.throw('Unrecognised type: string, value: \'Something of unrecognised type\''); - }); - }); - - describe('visitModelManager', () => { - it('should return a value of the concatenated output of each modelFiles accept', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.accept.returns(['Duck', 'Duck']); - let mockModelFile2 = sinon.createStubInstance(ModelFile); - mockModelFile2.isModelFile.returns(true); - mockModelFile2.accept.returns(['Duck', 'Goose']); - - let mockModelManager = sinon.createStubInstance(ModelManager); - mockModelManager.isModelManager.returns(true); - mockModelManager.getModelFiles.returns([mockModelFile, mockModelFile2]); - - loopbackVisit.visitModelManager(mockModelManager, param).should.deep.equal(['Duck', 'Duck', 'Duck', 'Goose']); - mockModelFile.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - mockModelFile2.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - param.should.deep.equal({ - modelManager: mockModelManager - }); - }); - }); - - describe('visitModelFile', () => { - it('should return an array of each declaration\'s accept', () => { - let param = {}; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.accept.returns('Duck'); - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.accept.returns('Duck'); - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.accept.returns('Duck'); - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.accept.returns('Goose'); - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getNamespace.returns; - mockModelFile.getAssetDeclarations.returns([mockAssetDeclaration]); - mockModelFile.getTransactionDeclarations.returns([mockTransactionDeclaration]); - mockModelFile.getConceptDeclarations.returns([mockConceptDeclaration]); - mockModelFile.getParticipantDeclarations.returns([mockParticipantDeclaration]); - - loopbackVisit.visitModelFile(mockModelFile, param).should.deep.equal(['Duck', 'Duck', 'Duck', 'Goose']); - - param.should.deep.equal({ - first: true, - modelFile: mockModelFile - }); - }); - }); - - describe('visitAssetDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockAssetDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockAssetDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitAssetDeclaration(mockAssetDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockAssetDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'An asset named Bob', - plural: 'Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'asset' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockAssetDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitAssetDeclaration(mockAssetDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockAssetDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'An asset named Bob', - plural: 'org.acme.Person.Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'asset' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockAssetDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitAssetDeclaration(mockAssetDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitParticipantDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockParticipantDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockParticipantDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitParticipantDeclaration(mockParticipantDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockParticipantDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'A participant named Bob', - plural: 'Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'participant' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockParticipantDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitParticipantDeclaration(mockParticipantDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockParticipantDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'A participant named Bob', - plural: 'org.acme.Person.Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'participant' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockParticipantDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitParticipantDeclaration(mockParticipantDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitConceptDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockConceptDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockConceptDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitConceptDeclaration(mockConceptDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockConceptDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'A concept named Bob', - plural: 'Bob', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'concept' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockConceptDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitConceptDeclaration(mockConceptDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockConceptDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'A concept named Bob', - plural: 'org.acme.Person.Bob', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'concept' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockConceptDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitConceptDeclaration(mockConceptDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitTransactionDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockTransactionDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockTransactionDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitTransactionDeclaration(mockTransactionDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockTransactionDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'A transaction named Bob', - plural: 'Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'transaction' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockTransactionDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitTransactionDeclaration(mockTransactionDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockTransactionDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'A transaction named Bob', - plural: 'org.acme.Person.Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'transaction' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockTransactionDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitTransactionDeclaration(mockTransactionDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitEventDeclaration', () => { - it('should return null', () => { - let mockEventDeclaration = sinon.createStubInstance(EventDeclaration); - mockEventDeclaration.isEvent.returns(true); - mockEventDeclaration.getName.returns('Bob'); - - should.equal(loopbackVisit.visitEventDeclaration(mockEventDeclaration, {}), null); - }); - }); - - describe('visitClassDeclarationCommon', () => { - it('should return a created JSONSchema', () => { - let param = {}; - let jsonSchema = { - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal({ - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - description: 'The class identifier for this type', - required: false - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }); - }); - - it('should return a created JSONSchema autogenerating the description', () => { - let param = {}; - let jsonSchema = { - title: 'A schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal({ - title: 'A schema', - description: 'An instance of Person', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - description: 'The class identifier for this type', - required: false - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }); - }); - - it('should return a created JSONSchema adding to the composer options', () => { - let param = {}; - let jsonSchema = { - title: 'A schema', - description: 'A particularly good schema', - options: { - composer: {} - } - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getNamespace.returns('org.acme'); - mockClassDeclaration.isAbstract.returns(true); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal({ - title: 'A schema', - description: 'A particularly good schema', - options: { - composer: { - namespace: 'org.acme', - name: 'Person', - fqn: 'org.acme.Person', - abstract: true - } - }, - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - description: 'The class identifier for this type', - required: false - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }); - }); - - it('should return a created top level JSON Schema and write it to a file with the name of the FQN', () => { - let param = { - fileWriter: mockFileWriter - }; - let jsonSchema = { - $first: true, - $schema: true, - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }; - - loopbackVisit.namespaces = true; - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - - param.fileWriter.openFile.withArgs('org.acme.Person.json').calledOnce.should.be.ok; - param.fileWriter.write.withArgs(JSON.stringify(expectedResult, null, 4)).calledOnce.should.be.ok; - param.fileWriter.closeFile.calledOnce.should.be.ok; - }); - - it('should return a created top level JSON Schema and write it to a file with the name of the FQN', () => { - let param = { - fileWriter: null - }; - let jsonSchema = { - $first: true, - $schema: true, - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }; - - loopbackVisit.namespaces = true; - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - }); - - it('should return a created top level JSONSchema and write it to a file with the name of the class name', () => { - let param = { - fileWriter: mockFileWriter - }; - let jsonSchema = { - $first: true, - $schema: true, - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }; - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - - param.fileWriter.openFile.withArgs('Person.json').calledOnce.should.be.ok; - param.fileWriter.write.withArgs(JSON.stringify(expectedResult, null, 4)).calledOnce.should.be.ok; - param.fileWriter.closeFile.calledOnce.should.be.ok; - }); - - it('should return a created top level JSONSchema with extra data if a TransactionDeclaration', () => { - let param = {}; - let jsonSchema = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - noseLength: {} - } - }; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getName.returns('Person'); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockTransactionDeclaration.getIdentifierFieldName.returns('Bob'); - mockTransactionDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return { - prop: 'Guineapig' - }; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return { - prop: 'Goldfish' - }; - } - }, - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: { - prop: 'Guineapig', - generated: true, - required: false - }, - Trevor: { - prop: 'Goldfish' - }, - }, - forceId: true, - - }; - loopbackVisit.visitClassDeclarationCommon(mockTransactionDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - }); - }); - - describe('toLoopbackType', () => { - it('should return date for DateTime', () => { - LoopbackVisitor.toLoopbackType('DateTime').should.deep.equal('date'); - }); - - it('should return boolean for Boolean', () => { - LoopbackVisitor.toLoopbackType('Boolean').should.deep.equal('boolean'); - }); - - it('should return String for String', () => { - LoopbackVisitor.toLoopbackType('String').should.deep.equal('string'); - }); - - it('should return number for Double', () => { - LoopbackVisitor.toLoopbackType('Double').should.deep.equal('number'); - }); - - it('should return number for Long', () => { - LoopbackVisitor.toLoopbackType('Long').should.deep.equal('number'); - }); - - it('should return number for Integer', () => { - LoopbackVisitor.toLoopbackType('Integer').should.deep.equal('number'); - }); - - it('should return the string as default', () => { - LoopbackVisitor.toLoopbackType('Penguin').should.deep.equal('string'); - }); - }); - - describe('visitField', () => { - it('should return a JSON schema for a primitive', () => { - let param = {}; - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isPrimitive.returns(true); - mockField.getType.returns('String'); - mockField.getParent.returns({ - getIdentifierFieldName: () => { - return 'Farmer'; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'string', - required: true - }); - }); - - it('should return a JSON schema for a primitive with a default value and when it is an identifying field', () => { - let param = {}; - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Farmer'); - mockField.isPrimitive.returns(true); - mockField.getType.returns('String'); - mockField.getParent.returns({ - getIdentifierFieldName: () => { - return 'Farmer'; - } - }); - mockField.getDefaultValue.returns('Ploughed'); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'string', - default: 'Ploughed', - id: true, - description: 'The instance identifier for this type', - required: true - }); - }); - - it('should return a JSON schema for an enumeration', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.accept.withArgs(loopbackVisit, param).returns({ - type: 'Square' - }); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isTypeEnum.returns(true); - mockField.getType.returns('Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Square', - required: true - }); - }); - - it('should return a JSON schema for an enumeration with a default value', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.accept.withArgs(loopbackVisit, param).returns({ - type: 'Square' - }); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isTypeEnum.returns(true); - mockField.getType.returns('Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - mockField.getDefaultValue.returns('Trampled'); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Square', - default: 'Trampled', - required: true - }); - }); - - it('should return a JSON schema for a class using type', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.getType.returns('Acreage'); - mockField.getFullyQualifiedTypeName.returns('org.acme.Horse.Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Acreage', - required: true - }); - - mockModelFile.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - }); - - it('should return a JSON schema for a class using FQN', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.getType.returns('Acreage'); - mockField.getFullyQualifiedTypeName.returns('org.acme.Horse.Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'org_acme_Horse_Acreage', - required: true - }); - - mockModelFile.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - }); - - it('should return a JSON schema for a class without calling accept', () => { - let param = { - 'org.acme.Horse.Acreage': 'Something' - }; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.getType.returns('Acreage'); - mockField.getFullyQualifiedTypeName.returns('org.acme.Horse.Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Acreage', - required: true - }); - - mockModelFile.accept.callCount.should.deep.equal(0); - }); - - it('should return a JSON schema for a primitive that is an array', () => { - let param = {}; - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isPrimitive.returns(true); - mockField.getType.returns('String'); - mockField.getParent.returns({ - getIdentifierFieldName: () => { - return 'Farmer'; - } - }); - mockField.isOptional.returns(false); - mockField.isArray.returns(true); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: ['string'], - required: false, - default: [] - }); - }); - }); - - describe('visitEnumDeclaration', () => { - it('should create a JSON schema for an enum declaration', () => { - let param = {}; - - let mockEnumDecl = sinon.createStubInstance(EnumDeclaration); - mockEnumDecl.accept.withArgs(loopbackVisit, param).returns('Duck'); - mockEnumDecl.isEnum.returns(true); - mockEnumDecl.getProperties.returns([ - { - accept: mockEnumDecl.accept - }, - { - accept: mockEnumDecl.accept - } - ]); - - loopbackVisit.visitEnumDeclaration(mockEnumDecl, param).should.deep.equal({ - type: 'string', - enum: ['Duck', 'Duck'] - }); - }); - }); - - describe('visitEnumValueDeclaration', () => { - it('should return the enumValueDeclaration\'s name', () => { - let mockEnumValDecl = sinon.createStubInstance(EnumValueDeclaration); - mockEnumValDecl.isEnumValue.returns(true); - mockEnumValDecl.getName.returns('Bob'); - - loopbackVisit.visitEnumValueDeclaration(mockEnumValDecl, {}).should.deep.equal('Bob'); - }); - }); - - describe('visitRelationshipDeclaration', () => { - it('should return a JSONSchema for a relationship', () => { - let mockRelationshipDeclaration = sinon.createStubInstance(RelationshipDeclaration); - mockRelationshipDeclaration.isRelationship.returns(true); - mockRelationshipDeclaration.getName.returns('Bob'); - mockRelationshipDeclaration.isOptional.returns(false); - - loopbackVisit.visitRelationshipDeclaration(mockRelationshipDeclaration, {}).should.deep.equal({ - type: 'any', - description: 'The identifier of an instance of Bob', - required: true - }); - }); - - it('should return a JSONSchema for a relationship that is an array', () => { - let mockRelationshipDeclaration = sinon.createStubInstance(RelationshipDeclaration); - mockRelationshipDeclaration.isRelationship.returns(true); - mockRelationshipDeclaration.getName.returns('Bob'); - mockRelationshipDeclaration.isOptional.returns(false); - mockRelationshipDeclaration.isArray.returns(true); - - loopbackVisit.visitRelationshipDeclaration(mockRelationshipDeclaration, {}).should.deep.equal({ - type: ['any'], - description: 'The identifier of an instance of Bob', - required: true - }); - }); - }); -}); \ No newline at end of file diff --git a/test/codegen/fromcto/loopback/loopbackvisitorcircular.js b/test/codegen/fromcto/loopback/loopbackvisitorcircular.js deleted file mode 100644 index ec31d3d0..00000000 --- a/test/codegen/fromcto/loopback/loopbackvisitorcircular.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const fs = require('fs'); -const FileWriter = require('@accordproject/concerto-util').FileWriter; -const ModelManager = require('@accordproject/concerto-core').ModelManager; -const LoopbackVisitor = require('../../../../lib/codegen/fromcto/loopback/loopbackvisitor'); -const path = require('path'); - -require('chai').should(); -const sinon = require('sinon'); - -describe('LoopbackVisitor with Circular Model', () => { - - let mockFileWriter; - let modelManager; - let visitor; - - let sandbox; - - [undefined, true, false].forEach((namespaces) => { - - describe(`namespaces = ${namespaces}`, () => { - - beforeEach(() => { - mockFileWriter = sinon.createStubInstance(FileWriter); - modelManager = new ModelManager(); - modelManager.addCTOModel(fs.readFileSync(path.resolve(__dirname, '../data/model/circular.cto'), 'utf8'), 'circular.cto'); - visitor = new LoopbackVisitor(namespaces); - sandbox = sinon.createSandbox(); - }); - - afterEach(() => { - sandbox.restore(); - }); - - describe('#visit', () => { - - it('should generate Loopback model files for each type when given a model manager', () => { - - // Visit all of the loaded model files and check that they were all generated - const schemas = modelManager.accept(visitor, { fileWriter: mockFileWriter }); - schemas.length.should.equal(29); - }); - - }); - - }); - }); - -}); From d93a3e0f3965dddd2e56ab979cced9b4e85427e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:39:51 +0100 Subject: [PATCH 09/17] chore(deps-dev): bump @babel/traverse from 7.22.11 to 7.23.2 (#67) Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.11 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index eaa9e074..b71e662d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -245,12 +245,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.10.tgz", - "integrity": "sha512-79KIf7YiWjjdZ81JnLujDRApWtl7BxTqWD88+FFdQEIOG8LJ0etDOM7CXuIgGJa55sGOwZVwuEsaLEm0PJ5/+A==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.22.10", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -393,22 +393,22 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -570,9 +570,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -630,9 +630,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.14", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.14.tgz", - "integrity": "sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1809,33 +1809,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.11.tgz", - "integrity": "sha512-mzAenteTfomcB7mfPtyi+4oe5BZ6MXxWcn4CX+h4IRJ+OOGXBrWU6jDQavkQI9Vuc5P+donFabBfFCcmWka9lQ==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.10", - "@babel/generator": "^7.22.10", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.11", - "@babel/types": "^7.22.11", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1844,13 +1844,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.11.tgz", - "integrity": "sha512-siazHiGuZRz9aB9NpHy9GOs9xiQPKnMzgdr493iI1M67vRXpnEq8ZOOKzezC5q7zwuQ6sDhdSp4SD9ixKSqKZg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { From 5e4707d221cc94b45819a6ba6ead2570ec26423e Mon Sep 17 00:00:00 2001 From: Dan Selman Date: Thu, 2 Nov 2023 15:06:53 +0000 Subject: [PATCH 10/17] test(codegen) update HR model to use multiple namespaces (#68) Signed-off-by: Dan Selman --- lib/codegen/fromcto/csharp/csharpvisitor.js | 4 +- .../fromcto/typescript/typescriptvisitor.js | 4 +- lib/common/graph.js | 4 +- package-lock.json | 142 +- package.json | 8 +- test/codegen/__snapshots__/codegen.js.snap | 2316 +++++++++++------ test/codegen/codegen.js | 7 +- test/codegen/fromcto/csharp/csharpvisitor.js | 25 +- test/codegen/fromcto/data/model/hr.cto | 60 +- test/codegen/fromcto/data/model/hr_base.cto | 32 + ...cordproject.protocol.v1_0_0-expected.proto | 2 +- test/common/graph.js | 148 +- .../fromcto/graphql/graphqlvisitor.d.ts | 8 + 13 files changed, 1799 insertions(+), 961 deletions(-) create mode 100644 test/codegen/fromcto/data/model/hr_base.cto diff --git a/lib/codegen/fromcto/csharp/csharpvisitor.js b/lib/codegen/fromcto/csharp/csharpvisitor.js index 753544e7..10f40d72 100644 --- a/lib/codegen/fromcto/csharp/csharpvisitor.js +++ b/lib/codegen/fromcto/csharp/csharpvisitor.js @@ -314,8 +314,8 @@ class CSharpVisitor { writeField(field, parameters, externalFieldType, isOptional = false) { // write Map field - if ( Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) { - const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name); + if (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) { + const decl = field.getModelFile().getType(field.getType()); parameters.fileWriter.writeLine(1, `public Dictionary ${field.getName()} { get; set; }`); return null; } diff --git a/lib/codegen/fromcto/typescript/typescriptvisitor.js b/lib/codegen/fromcto/typescript/typescriptvisitor.js index 3da9d1c6..fc001537 100644 --- a/lib/codegen/fromcto/typescript/typescriptvisitor.js +++ b/lib/codegen/fromcto/typescript/typescriptvisitor.js @@ -288,9 +288,7 @@ class TypescriptVisitor { const isPrimitive = ModelUtil.isPrimitiveType(mapDeclaration.getValue().getType()); if (isScalar) { - const scalar = mapDeclaration.getModelFile() - .getAllDeclarations() - .find(decl => decl.name === mapDeclaration.getValue().getType()); + const scalar = mapDeclaration.getModelFile(mapDeclaration.getValue().getType()); const scalarType = scalar.getType(); valueType = this.toTsType(scalarType, false, false); } else if (isPrimitive) { diff --git a/lib/common/graph.js b/lib/common/graph.js index de872197..774f0627 100644 --- a/lib/common/graph.js +++ b/lib/common/graph.js @@ -203,7 +203,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { let valueEdge = mapDeclaration.getValue().getType(); if(!ModelUtil.isPrimitiveType(keyEdge)) { - keyEdge = modelFile.getAllDeclarations().find(d => d.name === mapDeclaration.getKey().getType()).getFullyQualifiedName(); + keyEdge = modelFile.getType(mapDeclaration.getKey().getType()).getFullyQualifiedName(); } if(!ModelUtil.isPrimitiveType(valueEdge)) { @@ -211,7 +211,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { if (!modelFile.isLocalType(mapDeclaration.getValue().getType())) { valueEdge = modelFile.resolveImport(mapDeclaration.getValue().getType()); } else { - valueEdge = modelFile.getAllDeclarations().find(d => d.name === mapDeclaration.getValue().getType()).getFullyQualifiedName(); + valueEdge = modelFile.getType(mapDeclaration.getValue().getType()).getFullyQualifiedName(); } } diff --git a/package-lock.json b/package-lock.json index b71e662d..3f18fcfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "3.16.2", "license": "Apache-2.0", "dependencies": { - "@accordproject/concerto-core": "3.12.3", - "@accordproject/concerto-util": "3.12.3", - "@accordproject/concerto-vocabulary": "3.12.3", + "@accordproject/concerto-core": "3.14.2", + "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-vocabulary": "3.14.2", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", @@ -22,7 +22,7 @@ "pluralize": "8.0.0" }, "devDependencies": { - "@accordproject/concerto-cto": "3.12.3", + "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -60,34 +60,62 @@ } }, "node_modules/@accordproject/concerto-core": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.12.3.tgz", - "integrity": "sha512-xFCzM3xwV8Th719sUp4htElqiHWAIwOCqukSaYZ2OxrrXmIBvoj0aWCkGiWYHlMujVegXQrP7R8G+8O+QuGxUg==", - "dependencies": { - "@accordproject/concerto-cto": "3.12.3", - "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.12.3", - "dayjs": "1.10.8", - "debug": "4.3.1", - "lorem-ipsum": "2.0.3", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.2.tgz", + "integrity": "sha512-pnmA8LgPw4lXs//JGlIGJc5zS5bY8B9AyAJTexfcJIrihMZccQVONJ4AQ3/8eL2vh0OgofC65XCx4qrJXXw0Bw==", + "dependencies": { + "@accordproject/concerto-cto": "3.14.2", + "@accordproject/concerto-metamodel": "3.9.0", + "@accordproject/concerto-util": "3.14.2", + "dayjs": "1.11.10", + "debug": "4.3.4", + "lorem-ipsum": "2.0.8", "randexp": "0.5.3", "semver": "7.5.4", "slash": "3.0.0", "urijs": "1.19.11", - "uuid": "8.3.2" + "uuid": "9.0.1" }, "engines": { "node": ">=16", "npm": ">=8" } }, + "node_modules/@accordproject/concerto-core/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@accordproject/concerto-core/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@accordproject/concerto-cto": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.12.3.tgz", - "integrity": "sha512-iR8IL4/bbCrwoHijCtJVmYa02JygoZI+ODG5TmsYE4Ryl+Rqz4B6oYgISdy1j5ZSDGXSjy2I1bj9K130OtKBbA==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.2.tgz", + "integrity": "sha512-+gCGQzNKO+kbMAEIsESyOHpcAivOLVUHZU3P34PKMan/stLExLJNIERVWS+BeGvpHu8iQzaA6RiJ6XkjQNhUuA==", "dependencies": { - "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.12.3", + "@accordproject/concerto-metamodel": "3.9.0", + "@accordproject/concerto-util": "3.14.2", "path-browserify": "1.0.1" }, "engines": { @@ -96,11 +124,12 @@ } }, "node_modules/@accordproject/concerto-metamodel": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.8.1.tgz", - "integrity": "sha512-R0CAtzW/IciPz2BxlEyMgKZtya7sqgZ/YSk5iLD6g16NXsJtj6jytDuSZmNMz0B0FpjtEjSoSXPexCR/aPL1qA==", + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.9.0.tgz", + "integrity": "sha512-SbzLormyTORUZDt46umGZT2aVgOCkH5bo67SjuVRPd5YzywMb/vJfncyd6XCm/vzmUWZ3D9OkPqnnfPvPTRMNg==", "dependencies": { - "@accordproject/concerto-util": "3.9.1" + "@accordproject/concerto-util": "3.9.1", + "@types/node": "20.7.0" }, "engines": { "node": ">=14", @@ -133,14 +162,14 @@ } }, "node_modules/@accordproject/concerto-util": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.12.3.tgz", - "integrity": "sha512-LWgMWwxL54LcpxzirDVKB/rDoyDTgB1q6//3CiGDNm/b91o/t+U3Q1QIVHcDpSYtUCdcyQxq3V+l14QQjmuJfg==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.2.tgz", + "integrity": "sha512-TagOBlneJlPXRKi75rWIshnqzQvsmWeXtFU7jwsvuFr2GeP+JeZwj4Clh4L3P8ah3Yu5mu5Z3n+w4M8KLbAxbg==", "dependencies": { "@supercharge/promise-pool": "1.7.0", "axios": "0.23.0", "colors": "1.4.0", - "debug": "4.3.1", + "debug": "4.3.4", "json-colorizer": "2.2.2", "slash": "3.0.0" }, @@ -157,12 +186,28 @@ "follow-redirects": "^1.14.4" } }, + "node_modules/@accordproject/concerto-util/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/@accordproject/concerto-vocabulary": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.12.3.tgz", - "integrity": "sha512-UDoa75d6jYPbX511Y5qd+/I87OUBt9eHL7bzpR8rvB6kdevVFVTTH4LiZ2m8QgS+IGnE7MviIxGsiumkx/QCtA==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.2.tgz", + "integrity": "sha512-cparnUNjstm1IFq96hvG2TzaY5PBPotgH1zoJRxhwng7WDQP6dqatNiGmaF6tkpe0Edmkm/2VbA0CB9aSzavAg==", "dependencies": { - "@accordproject/concerto-metamodel": "3.8.1", + "@accordproject/concerto-metamodel": "3.9.0", "yaml": "2.2.2" }, "engines": { @@ -2546,10 +2591,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", - "integrity": "sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==", - "dev": true + "version": "20.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.0.tgz", + "integrity": "sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==" }, "node_modules/@types/stack-utils": { "version": "2.0.1", @@ -3440,7 +3484,8 @@ "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true }, "node_modules/commondir": { "version": "1.0.1", @@ -3488,9 +3533,9 @@ } }, "node_modules/dayjs": { - "version": "1.10.8", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.8.tgz", - "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==" + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" }, "node_modules/debug": { "version": "4.3.1", @@ -5789,11 +5834,11 @@ } }, "node_modules/lorem-ipsum": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-2.0.3.tgz", - "integrity": "sha512-CX2r84DMWjW/DWiuzicTI9aRaJPAw2cvAGMJYZh/nx12OkTGqloj8y8FU0S8ZkKwOdqhfxEA6Ly8CW2P6Yxjwg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-2.0.8.tgz", + "integrity": "sha512-5RIwHuCb979RASgCJH0VKERn9cQo/+NcAi2BMe9ddj+gp7hujl6BI+qdOG4nVsLDpwWEJwTVYXNKP6BGgbcoGA==", "dependencies": { - "commander": "^2.17.1" + "commander": "^9.3.0" }, "bin": { "lorem-ipsum": "dist/bin/lorem-ipsum.bin.js" @@ -5803,6 +5848,14 @@ "npm": ">= 5.x" } }, + "node_modules/lorem-ipsum/node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/loupe": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", @@ -8026,6 +8079,7 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, "bin": { "uuid": "dist/bin/uuid" } diff --git a/package.json b/package.json index 8c57e8db..72518b54 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "author": "accordproject.org", "license": "Apache-2.0", "devDependencies": { - "@accordproject/concerto-cto": "3.12.3", + "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -69,9 +69,9 @@ "webpack-cli": "4.9.1" }, "dependencies": { - "@accordproject/concerto-core": "3.12.3", - "@accordproject/concerto-util": "3.12.3", - "@accordproject/concerto-vocabulary": "3.12.3", + "@accordproject/concerto-core": "3.14.2", + "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-vocabulary": "3.14.2", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index cd085d53..98efae51 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -64,8 +64,8 @@ protocol MyProtocol { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 3`] = ` { - "key": "org.acme.hr.avdl", - "value": "@namespace("org.acme.hr") + "key": "org.acme.hr.base.avdl", + "value": "@namespace("org.acme.hr.base") protocol MyProtocol { import idl "concerto@1.0.0.avdl"; @@ -79,23 +79,42 @@ protocol MyProtocol { CA } + enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE + } + record Address { string street; string city; union { null, State } state; string zipCode; string country; - Map1 dictionary1; - Map2 dictionary2; - Map3 dictionary3; - Map4 dictionary4; - Map5 dictionary5; - Map6 dictionary6; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 4`] = ` +{ + "key": "org.acme.hr.avdl", + "value": "@namespace("org.acme.hr") +protocol MyProtocol { + + import idl "org.acme.hr.base.avdl"; + import idl "concerto@1.0.0.avdl"; + record Company { string name; Address headquarters; + union { null, CompanyProperties } companyProperties; + union { null, EmployeeDirectory } employeeDirectory; + union { null, EmployeeTShirtSizes } employeeTShirtSizes; + union { null, EmployeeProfiles } employeeProfiles; + union { null, EmployeeSocialSecurityNumbers } employeeSocialSecurityNumbers; } enum Department { @@ -131,6 +150,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Employee { @@ -151,6 +171,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Contractor { @@ -165,6 +186,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Manager { @@ -186,6 +208,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record CompanyEvent { @@ -305,8 +328,8 @@ public abstract class Event : Concept { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 3`] = ` { - "key": "org.acme.hr.cs", - "value": "namespace org.acme.hr; + "key": "org.acme.hr.base.cs", + "value": "namespace org.acme.hr.base; using AccordProject.Concerto; [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum State { @@ -317,32 +340,49 @@ public enum State { IL, CA, } -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Address")] +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr.base", Version = null, Name = "Address")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Address : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Address"; + public override string _class { get; } = "org.acme.hr.base.Address"; public string street { get; set; } public string city { get; set; } public State? state { get; set; } public string zipCode { get; set; } public string country { get; set; } - public Dictionary dictionary1 { get; set; } - public Dictionary dictionary2 { get; set; } - public Dictionary dictionary3 { get; set; } - public Dictionary dictionary4 { get; set; } - public Dictionary dictionary5 { get; set; } - public Dictionary dictionary6 { get; set; } } //Dummy implementation of the scalar declaration to avoid compilation errors. class Time_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class SSN_Dummy {} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 4`] = ` +{ + "key": "org.acme.hr.cs", + "value": "namespace org.acme.hr; +using org.acme.hr.base; +using AccordProject.Concerto; [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Company")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Company : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr.Company"; public string name { get; set; } - public Address headquarters { get; set; } + public org.acme.hr.base.Address headquarters { get; set; } + public Dictionary companyProperties { get; set; } + public Dictionary employeeDirectory { get; set; } + public Dictionary employeeTShirtSizes { get; set; } + public Dictionary employeeProfiles { get; set; } + public Dictionary employeeSocialSecurityNumbers { get; set; } } [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum Department { @@ -373,8 +413,6 @@ public class Laptop : Equipment { public override string _class { get; } = "org.acme.hr.Laptop"; public LaptopMake make { get; set; } } -//Dummy implementation of the scalar declaration to avoid compilation errors. -class SSN_Dummy {} [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Person")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public abstract class Person : Participant { @@ -385,11 +423,12 @@ public abstract class Person : Participant { public string firstName { get; set; } public string lastName { get; set; } public string? middleNames { get; set; } - public Address homeAddress { get; set; } + public org.acme.hr.base.Address homeAddress { get; set; } [System.ComponentModel.DataAnnotations.RegularExpression(@"\\d{3}-\\d{2}-\\{4}+", ErrorMessage = "Invalid characters")] public string ssn { get; set; } public float height { get; set; } public System.DateTime dob { get; set; } + public Dictionary nextOfKin { get; set; } } [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Employee")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] @@ -401,7 +440,7 @@ public class Employee : Person { public int numDependents { get; set; } public bool retired { get; set; } public Department department { get; set; } - public Address officeAddress { get; set; } + public org.acme.hr.base.Address officeAddress { get; set; } public Equipment[] companyAssets { get; set; } public Manager manager { get; set; } } @@ -439,8 +478,12 @@ public class ChangeOfAddress : Transaction { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr.ChangeOfAddress"; public Person Person { get; set; } - public Address newAddress { get; set; } + public org.acme.hr.base.Address newAddress { get; set; } } +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinName_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinTelephone_Dummy {} ", } `; @@ -502,10 +545,9 @@ type Event struct { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 3`] = ` { - "key": "org.acme.hr.go", - "value": "// Package org_acme_hr contains domain objects and was generated from Concerto namespace org.acme.hr. -package org_acme_hr -import "time" + "key": "org.acme.hr.base.go", + "value": "// Package org_acme_hr_base contains domain objects and was generated from Concerto namespace org.acme.hr.base. +package org_acme_hr_base import "concerto_1_0_0"; type State int @@ -517,6 +559,12 @@ const ( IL CA ) +type TShirtSizeType int +const ( + SMALL TShirtSizeType = 1 + iota + MEDIUM + LARGE +) type Address struct { concerto_1_0_0.Concept Street string \`json:"street"\` @@ -524,17 +572,29 @@ type Address struct { State State \`json:"state"\` ZipCode string \`json:"zipCode"\` Country string \`json:"country"\` - Dictionary1 Map1 \`json:"dictionary1"\` - Dictionary2 Map2 \`json:"dictionary2"\` - Dictionary3 Map3 \`json:"dictionary3"\` - Dictionary4 Map4 \`json:"dictionary4"\` - Dictionary5 Map5 \`json:"dictionary5"\` - Dictionary6 Map6 \`json:"dictionary6"\` } +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 4`] = ` +{ + "key": "org.acme.hr.go", + "value": "// Package org_acme_hr contains domain objects and was generated from Concerto namespace org.acme.hr. +package org_acme_hr +import "time" +import "org_acme_hr_base"; +import "concerto_1_0_0"; + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` Headquarters Address \`json:"headquarters"\` + CompanyProperties CompanyProperties \`json:"companyProperties"\` + EmployeeDirectory EmployeeDirectory \`json:"employeeDirectory"\` + EmployeeTShirtSizes EmployeeTShirtSizes \`json:"employeeTShirtSizes"\` + EmployeeProfiles EmployeeProfiles \`json:"employeeProfiles"\` + EmployeeSocialSecurityNumbers EmployeeSocialSecurityNumbers \`json:"employeeSocialSecurityNumbers"\` } type Department int const ( @@ -568,6 +628,7 @@ type Person struct { Ssn string \`json:"ssn"\` Height float64 \`json:"height"\` Dob time.Time \`json:"dob"\` + NextOfKin NextOfKin \`json:"nextOfKin"\` } type Employee struct { Person @@ -610,7 +671,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "model.gql", "value": "directive @resource on OBJECT | FIELD_DEFINITION scalar DateTime -# namespace org.acme.hr +# namespace org.acme.hr.base enum State { MA NY @@ -619,46 +680,55 @@ enum State { IL CA } +enum TShirtSizeType { + SMALL + MEDIUM + LARGE +} +type EmployeeTShirtSizes { + key: SSN + value: TShirtSizeType +} type Address { street: String! city: String! state: State zipCode: String! country: String! - dictionary1: Map1! - dictionary2: Map2! - dictionary3: Map3! - dictionary4: Map4! - dictionary5: Map5! - dictionary6: Map6! -} -type Map1 { +} +# namespace org.acme.hr +type CompanyProperties { key: String value: String } -type Map2 { +type EmployeeLoginTimes { key: String - value: DateTime + value: Time } -type Map3 { +type EmployeeSocialSecurityNumbers { key: String value: SSN } -type Map4 { +type NextOfKin { + key: KinName + value: KinTelephone +} +type EmployeeProfiles { key: String value: Concept } -type Map5 { - key: SSN - value: String -} -type Map6 { +type EmployeeDirectory { key: SSN value: Employee } type Company { name: String! headquarters: Address! + companyProperties: CompanyProperties + employeeDirectory: EmployeeDirectory + employeeTShirtSizes: EmployeeTShirtSizes + employeeProfiles: EmployeeProfiles + employeeSocialSecurityNumbers: EmployeeSocialSecurityNumbers } enum Department { Sales @@ -690,6 +760,7 @@ type Person @resource { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Employee { @@ -709,6 +780,7 @@ type Employee { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Contractor { @@ -722,6 +794,7 @@ type Contractor { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Manager { @@ -742,6 +815,7 @@ type Manager { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type CompanyEvent { @@ -885,9 +959,9 @@ public abstract class Event extends Concept { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 6`] = ` { - "key": "org/acme/hr/State.java", + "key": "org/acme/hr/base/State.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"$class"}) @@ -905,9 +979,26 @@ public enum State { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 7`] = ` { - "key": "org/acme/hr/Address.java", + "key": "org/acme/hr/base/TShirtSizeType.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 8`] = ` +{ + "key": "org/acme/hr/base/Address.java", + "value": "// this code is generated and should not be modified +package org.acme.hr.base; import concerto.Concept; import concerto.Asset; @@ -923,12 +1014,6 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map1 dictionary1; - private Map2 dictionary2; - private Map3 dictionary3; - private Map4 dictionary4; - private Map5 dictionary5; - private Map6 dictionary6; public String getStreet() { return this.street; } @@ -944,24 +1029,6 @@ public class Address extends Concept { public String getCountry() { return this.country; } - public Map1 getDictionary1() { - return this.dictionary1; - } - public Map2 getDictionary2() { - return this.dictionary2; - } - public Map3 getDictionary3() { - return this.dictionary3; - } - public Map4 getDictionary4() { - return this.dictionary4; - } - public Map5 getDictionary5() { - return this.dictionary5; - } - public Map6 getDictionary6() { - return this.dictionary6; - } public void setStreet(String street) { this.street = street; } @@ -977,35 +1044,22 @@ public class Address extends Concept { public void setCountry(String country) { this.country = country; } - public void setDictionary1(Map1 dictionary1) { - this.dictionary1 = dictionary1; - } - public void setDictionary2(Map2 dictionary2) { - this.dictionary2 = dictionary2; - } - public void setDictionary3(Map3 dictionary3) { - this.dictionary3 = dictionary3; - } - public void setDictionary4(Map4 dictionary4) { - this.dictionary4 = dictionary4; - } - public void setDictionary5(Map5 dictionary5) { - this.dictionary5 = dictionary5; - } - public void setDictionary6(Map6 dictionary6) { - this.dictionary6 = dictionary6; - } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 8`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 9`] = ` { "key": "org/acme/hr/Company.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1017,24 +1071,59 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; + private CompanyProperties companyProperties; + private EmployeeDirectory employeeDirectory; + private EmployeeTShirtSizes employeeTShirtSizes; + private EmployeeProfiles employeeProfiles; + private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; public String getName() { return this.name; } public Address getHeadquarters() { return this.headquarters; } + public CompanyProperties getCompanyProperties() { + return this.companyProperties; + } + public EmployeeDirectory getEmployeeDirectory() { + return this.employeeDirectory; + } + public EmployeeTShirtSizes getEmployeeTShirtSizes() { + return this.employeeTShirtSizes; + } + public EmployeeProfiles getEmployeeProfiles() { + return this.employeeProfiles; + } + public EmployeeSocialSecurityNumbers getEmployeeSocialSecurityNumbers() { + return this.employeeSocialSecurityNumbers; + } public void setName(String name) { this.name = name; } public void setHeadquarters(Address headquarters) { this.headquarters = headquarters; } + public void setCompanyProperties(CompanyProperties companyProperties) { + this.companyProperties = companyProperties; + } + public void setEmployeeDirectory(EmployeeDirectory employeeDirectory) { + this.employeeDirectory = employeeDirectory; + } + public void setEmployeeTShirtSizes(EmployeeTShirtSizes employeeTShirtSizes) { + this.employeeTShirtSizes = employeeTShirtSizes; + } + public void setEmployeeProfiles(EmployeeProfiles employeeProfiles) { + this.employeeProfiles = employeeProfiles; + } + public void setEmployeeSocialSecurityNumbers(EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers) { + this.employeeSocialSecurityNumbers = employeeSocialSecurityNumbers; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 9`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 10`] = ` { "key": "org/acme/hr/Department.java", "value": "// this code is generated and should not be modified @@ -1054,12 +1143,17 @@ public enum Department { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 10`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 11`] = ` { "key": "org/acme/hr/Equipment.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1088,7 +1182,7 @@ public abstract class Equipment extends Asset { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 11`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 12`] = ` { "key": "org/acme/hr/LaptopMake.java", "value": "// this code is generated and should not be modified @@ -1104,12 +1198,17 @@ public enum LaptopMake { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 12`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 13`] = ` { "key": "org/acme/hr/Laptop.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1138,12 +1237,17 @@ public class Laptop extends Equipment { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 13`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 14`] = ` { "key": "org/acme/hr/Person.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1168,6 +1272,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; + private NextOfKin nextOfKin; public String getEmail() { return this.email; } @@ -1192,6 +1297,9 @@ public abstract class Person extends Participant { public java.util.Date getDob() { return this.dob; } + public NextOfKin getNextOfKin() { + return this.nextOfKin; + } public void setEmail(String email) { this.email = email; } @@ -1216,17 +1324,25 @@ public abstract class Person extends Participant { public void setDob(java.util.Date dob) { this.dob = dob; } + public void setNextOfKin(NextOfKin nextOfKin) { + this.nextOfKin = nextOfKin; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 14`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 15`] = ` { "key": "org/acme/hr/Employee.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1304,12 +1420,17 @@ public class Employee extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 15`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 16`] = ` { "key": "org/acme/hr/Contractor.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1345,12 +1466,17 @@ public class Contractor extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 16`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 17`] = ` { "key": "org/acme/hr/Manager.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1379,12 +1505,17 @@ public class Manager extends Employee { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 17`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 18`] = ` { "key": "org/acme/hr/CompanyEvent.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1398,12 +1529,17 @@ public class CompanyEvent extends Event { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 18`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 19`] = ` { "key": "org/acme/hr/Onboarded.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1424,12 +1560,17 @@ public class Onboarded extends CompanyEvent { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 19`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 20`] = ` { "key": "org/acme/hr/ChangeOfAddress.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1463,9 +1604,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { - "org.acme.hr.State": { + "org.acme.hr.base.State": { "title": "State", - "description": "An instance of org.acme.hr.State", + "description": "An instance of org.acme.hr.base.State", "enum": [ "MA", "NY", @@ -1475,16 +1616,25 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "CA" ] }, - "org.acme.hr.Address": { + "org.acme.hr.base.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base.Address": { "title": "Address", - "description": "An instance of org.acme.hr.Address", + "description": "An instance of org.acme.hr.base.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr.Address", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", - "description": "The class identifier for org.acme.hr.Address" + "default": "org.acme.hr.base.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base\\\\.Address$", + "description": "The class identifier for org.acme.hr.base.Address" }, "street": { "type": "string" @@ -1493,7 +1643,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "state": { - "$ref": "#/definitions/org.acme.hr.State" + "$ref": "#/definitions/org.acme.hr.base.State" }, "zipCode": { "type": "string" @@ -1591,19 +1741,17 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr.Time": { + "org.acme.hr.base.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr.Company": { "title": "Company", "description": "An instance of org.acme.hr.Company", @@ -1619,7 +1767,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "headquarters": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" } }, "required": [ @@ -1697,10 +1845,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "serialNumber" ] }, - "org.acme.hr.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr.Person": { "title": "Person", "description": "An instance of org.acme.hr.Person", @@ -1726,7 +1870,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1749,7 +1893,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -1782,7 +1927,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/definitions/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -1815,7 +1960,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1845,7 +1990,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Contractor": { @@ -1880,7 +2026,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1904,7 +2050,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Manager": { @@ -1941,7 +2088,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/definitions/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -1974,7 +2121,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2004,7 +2151,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.CompanyEvent": { @@ -2060,7 +2208,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "The identifier of an instance of org.acme.hr.Person" }, "newAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" } }, "required": [ @@ -2068,6 +2216,13 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "Person", "newAddress" ] + }, + "org.acme.hr.KinName": { + "type": "string" + }, + "org.acme.hr.KinTelephone": { + "format": "date-time", + "type": "string" } } } @@ -2078,16 +2233,16 @@ exports[`codegen #formats check we can convert all formats from namespace unvers exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'markdown' 1`] = ` { "key": "models.md", - "value": "# Namespace org.acme.hr + "value": "# Namespace org.acme.hr.base ## Overview -- 2 concepts -- 3 enumerations -- 2 assets -- 4 participants -- 1 transactions -- 2 events -- 22 total declarations +- 1 concepts +- 2 enumerations +- 0 assets +- 0 participants +- 0 transactions +- 0 events +- 6 total declarations ## Imports - concerto@1.0.0.Concept @@ -2099,7 +2254,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers ## Diagram \`\`\`mermaid classDiagram -class \`org.acme.hr.State\` { +class \`org.acme.hr.base.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -2109,35 +2264,68 @@ class \`org.acme.hr.State\` { + \`CA\` } -class \`org.acme.hr.Address\` { +class \`org.acme.hr.base.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +class \`org.acme.hr.base.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.State\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map1\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map2\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map3\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map4\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map5\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map6\` +} + +\`org.acme.hr.base.Address\` "1" *-- "1" \`org.acme.hr.base.State\` +\`\`\` + +# Namespace org.acme.hr + +## Overview +- 1 concepts +- 2 enumerations +- 2 assets +- 4 participants +- 1 transactions +- 2 events +- 20 total declarations + +## Imports +- org.acme.hr.base.Address +- org.acme.hr.base.State +- org.acme.hr.base.SSN +- org.acme.hr.base.Time +- org.acme.hr.base.EmployeeTShirtSizes +- concerto@1.0.0.Concept +- concerto@1.0.0.Asset +- concerto@1.0.0.Transaction +- concerto@1.0.0.Participant +- concerto@1.0.0.Event + +## Diagram +\`\`\`mermaid +classDiagram class \`org.acme.hr.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.base.Address\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.CompanyProperties\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.EmployeeDirectory\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.base.EmployeeTShirtSizes\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.EmployeeProfiles\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.EmployeeSocialSecurityNumbers\` class \`org.acme.hr.Department\` { << enumeration>> + \`Sales\` @@ -2176,10 +2364,12 @@ class \`org.acme.hr.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.Address\` -\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.SSN\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.base.Address\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.base.SSN\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.NextOfKin\` class \`org.acme.hr.Employee\` { << participant>> + \`String\` \`employeeId\` @@ -2193,7 +2383,7 @@ class \`org.acme.hr.Employee\` { } \`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Department\` -\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Address\` +\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.base.Address\` \`org.acme.hr.Employee\` "1" *-- "*" \`org.acme.hr.Equipment\` \`org.acme.hr.Employee\` "1" o-- "1" \`org.acme.hr.Manager\` : manager \`org.acme.hr.Employee\` --|> \`org.acme.hr.Person\` @@ -2230,7 +2420,7 @@ class \`org.acme.hr.ChangeOfAddress\` { } \`org.acme.hr.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr.Person\` : Person -\`org.acme.hr.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.Address\` +\`org.acme.hr.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base.Address\` \`\`\` ", @@ -2241,7 +2431,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "model.mmd", "value": "classDiagram -class \`org.acme.hr.State\` { +class \`org.acme.hr.base.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -2251,27 +2441,34 @@ class \`org.acme.hr.State\` { + \`CA\` } -\`org.acme.hr.State\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Address\` { +\`org.acme.hr.base.State\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +\`org.acme.hr.base.TShirtSizeType\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` } -\`org.acme.hr.Address\` --|> \`concerto@1.0.0.Concept\` +\`org.acme.hr.base.Address\` --|> \`concerto@1.0.0.Concept\` class \`org.acme.hr.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` } \`org.acme.hr.Company\` --|> \`concerto@1.0.0.Concept\` @@ -2315,6 +2512,7 @@ class \`org.acme.hr.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } \`org.acme.hr.Person\` --|> \`concerto@1.0.0.Participant\` @@ -2405,7 +2603,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 2`] = ` { - "key": "org.acme.hr.csdl", + "key": "org.acme.hr.base.csdl", "value": " @@ -2415,7 +2613,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2430,34 +2628,65 @@ exports[`codegen #formats check we can convert all formats from namespace unvers + + + + + + + + - + - - - + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 3`] = ` +{ + "key": "org.acme.hr.csdl", + "value": " + + + + + + + + + + + + + + - + - + - + - + - - - + - + @@ -2501,7 +2730,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2509,6 +2738,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers + + @@ -2521,7 +2752,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2547,7 +2778,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2576,9 +2807,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers }, "components": { "schemas": { - "org.acme.hr.State": { + "org.acme.hr.base.State": { "title": "State", - "description": "An instance of org.acme.hr.State", + "description": "An instance of org.acme.hr.base.State", "enum": [ "MA", "NY", @@ -2588,16 +2819,25 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "CA" ] }, - "org.acme.hr.Address": { + "org.acme.hr.base.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base.Address": { "title": "Address", - "description": "An instance of org.acme.hr.Address", + "description": "An instance of org.acme.hr.base.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr.Address", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", - "description": "The class identifier for org.acme.hr.Address" + "default": "org.acme.hr.base.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base\\\\.Address$", + "description": "The class identifier for org.acme.hr.base.Address" }, "street": { "type": "string" @@ -2606,7 +2846,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "state": { - "$ref": "#/components/schemas/org.acme.hr.State" + "$ref": "#/components/schemas/org.acme.hr.base.State" }, "zipCode": { "type": "string" @@ -2704,19 +2944,17 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr.Time": { + "org.acme.hr.base.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr.Company": { "title": "Company", "description": "An instance of org.acme.hr.Company", @@ -2732,7 +2970,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "headquarters": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" } }, "required": [ @@ -2810,10 +3048,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "serialNumber" ] }, - "org.acme.hr.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr.Person": { "title": "Person", "description": "An instance of org.acme.hr.Person", @@ -2839,7 +3073,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2862,7 +3096,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -2895,7 +3130,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/components/schemas/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -2928,7 +3163,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2958,7 +3193,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Contractor": { @@ -2993,7 +3229,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -3017,7 +3253,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Manager": { @@ -3054,7 +3291,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/components/schemas/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -3087,7 +3324,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -3117,7 +3354,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.CompanyEvent": { @@ -3173,7 +3411,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "The identifier of an instance of org.acme.hr.Person" }, "newAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" } }, "required": [ @@ -3181,6 +3419,13 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "Person", "newAddress" ] + }, + "org.acme.hr.KinName": { + "type": "string" + }, + "org.acme.hr.KinTelephone": { + "format": "date-time", + "type": "string" } } }, @@ -3444,7 +3689,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers title Model endtitle -class org.acme.hr.State << (E,grey) >> { +class org.acme.hr.base.State << (E,grey) >> { + MA + NY + CO @@ -3452,24 +3697,29 @@ class org.acme.hr.State << (E,grey) >> { + IL + CA } -org.acme.hr.State --|> concerto_1_0_0.Concept -class org.acme.hr.Address { +org.acme.hr.base.State --|> concerto_1_0_0.Concept +class org.acme.hr.base.TShirtSizeType << (E,grey) >> { + + SMALL + + MEDIUM + + LARGE +} +org.acme.hr.base.TShirtSizeType --|> concerto_1_0_0.Concept +class org.acme.hr.base.Address { + String street + String city + State state + String zipCode + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr.Address --|> concerto_1_0_0.Concept +} +org.acme.hr.base.Address --|> concerto_1_0_0.Concept class org.acme.hr.Company { + String name + Address headquarters + + CompanyProperties companyProperties + + EmployeeDirectory employeeDirectory + + EmployeeTShirtSizes employeeTShirtSizes + + EmployeeProfiles employeeProfiles + + EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers } org.acme.hr.Company --|> concerto_1_0_0.Concept class org.acme.hr.Department << (E,grey) >> { @@ -3503,6 +3753,7 @@ class org.acme.hr.Person << (P,lightblue) >> { + String ssn + Double height + DateTime dob + + NextOfKin nextOfKin } org.acme.hr.Person --|> concerto_1_0_0.Participant class org.acme.hr.Employee << (P,lightblue) >> { @@ -3549,10 +3800,10 @@ org.acme.hr.ChangeOfAddress --|> concerto_1_0_0.Transaction exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'protobuf' 1`] = ` { - "key": "org.acme.hr.v.proto", + "key": "org.acme.hr.base.v.proto", "value": "syntax = "proto3"; -package org.acme.hr.v; +package org.acme.hr.base.v; import "google/protobuf/timestamp.proto"; @@ -3565,23 +3816,42 @@ enum State { State_WA = 5; } +enum TShirtSizeType { + TShirtSizeType_LARGE = 0; + TShirtSizeType_MEDIUM = 1; + TShirtSizeType_SMALL = 2; +} + message Address { string city = 1; string country = 2; - Map1 dictionary1 = 3; - Map2 dictionary2 = 4; - Map3 dictionary3 = 5; - Map4 dictionary4 = 6; - Map5 dictionary5 = 7; - Map6 dictionary6 = 8; - optional State state = 9; - string street = 10; - string zipCode = 11; + optional State state = 3; + string street = 4; + string zipCode = 5; +} + +", } +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'protobuf' 2`] = ` +{ + "key": "org.acme.hr.v.proto", + "value": "syntax = "proto3"; + +package org.acme.hr.v; + +import "google/protobuf/timestamp.proto"; +import "org.acme.hr.base.v.proto"; message Company { - Address headquarters = 1; - string name = 2; + optional CompanyProperties companyProperties = 1; + optional EmployeeDirectory employeeDirectory = 2; + optional EmployeeProfiles employeeProfiles = 3; + optional EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers = 4; + optional EmployeeTShirtSizes employeeTShirtSizes = 5; + Address headquarters = 6; + string name = 7; } enum Department { @@ -3629,11 +3899,12 @@ message Employee { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - bool retired = 14; - sint64 salary = 15; - string ssn = 16; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + bool retired = 15; + sint64 salary = 16; + string ssn = 17; } message _Subclasses_of_class_Employee { @@ -3653,7 +3924,8 @@ message Contractor { string lastName = 7; optional string manager = 8; optional string middleNames = 9; - string ssn = 10; + NextOfKin nextOfKin = 10; + string ssn = 11; } message Manager { @@ -3668,12 +3940,13 @@ message Manager { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - repeated string reports = 14; - bool retired = 15; - sint64 salary = 16; - string ssn = 17; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + repeated string reports = 15; + bool retired = 16; + sint64 salary = 17; + string ssn = 18; } message CompanyEvent { @@ -3707,6 +3980,8 @@ pub mod concerto_1_0_0; #[allow(unused_imports)] pub mod concerto; #[allow(unused_imports)] +pub mod org_acme_hr_base; +#[allow(unused_imports)] pub mod org_acme_hr; #[allow(unused_imports)] pub mod utils; @@ -3901,7 +4176,7 @@ pub struct Event { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 5`] = ` { - "key": "org_acme_hr.rs", + "key": "org_acme_hr_base.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; @@ -3924,6 +4199,16 @@ pub enum State { CA, } +#[derive(Debug, Serialize, Deserialize)] +pub enum TShirtSizeType { + #[allow(non_camel_case_types)] + SMALL, + #[allow(non_camel_case_types)] + MEDIUM, + #[allow(non_camel_case_types)] + LARGE, +} + #[derive(Debug, Serialize, Deserialize)] pub struct Address { #[serde( @@ -3956,54 +4241,68 @@ pub struct Address { rename = "country", )] pub country: String, - - #[serde( - rename = "dictionary1", - )] - pub dictionary1: Map1, - - #[serde( - rename = "dictionary2", - )] - pub dictionary2: Map2, - +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 6`] = ` +{ + "key": "org_acme_hr.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::org_acme_hr_base::*; +use crate::concerto_1_0_0::*; +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Company { #[serde( - rename = "dictionary3", + rename = "$class", )] - pub dictionary3: Map3, + pub _class: String, #[serde( - rename = "dictionary4", + rename = "name", )] - pub dictionary4: Map4, + pub name: String, #[serde( - rename = "dictionary5", + rename = "headquarters", )] - pub dictionary5: Map5, + pub headquarters: Address, #[serde( - rename = "dictionary6", + rename = "companyProperties", + skip_serializing_if = "Option::is_none", )] - pub dictionary6: Map6, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Company { + pub company_properties: Option, + #[serde( - rename = "$class", + rename = "employeeDirectory", + skip_serializing_if = "Option::is_none", )] - pub _class: String, + pub employee_directory: Option, #[serde( - rename = "name", + rename = "employeeTShirtSizes", + skip_serializing_if = "Option::is_none", )] - pub name: String, + pub employee_t_shirt_sizes: Option, #[serde( - rename = "headquarters", + rename = "employeeProfiles", + skip_serializing_if = "Option::is_none", )] - pub headquarters: Address, + pub employee_profiles: Option, + + #[serde( + rename = "employeeSocialSecurityNumbers", + skip_serializing_if = "Option::is_none", + )] + pub employee_social_security_numbers: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -4121,6 +4420,11 @@ pub struct Person { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4215,6 +4519,11 @@ pub struct Employee { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4279,6 +4588,11 @@ pub struct Contractor { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4376,6 +4690,11 @@ pub struct Manager { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4453,7 +4772,10 @@ exports[`codegen #formats check we can convert all formats from namespace unvers // Warning: Beware of circular dependencies when modifying these imports import type { State, - IAddress, + TShirtSizeType, + IAddress +} from './org.acme.hr.base'; +import type { ICompany, Department, LaptopMake @@ -4548,20 +4870,12 @@ export interface IEvent extends IConcept { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 3`] = ` { - "key": "org.acme.hr.ts", + "key": "org.acme.hr.base.ts", "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: org.acme.hr +// Generated code for namespace: org.acme.hr.base // imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports -import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; +import {IConcept} from './concerto@1.0.0'; // interfaces export enum State { @@ -4573,35 +4887,65 @@ export enum State { CA = 'CA', } +export enum TShirtSizeType { + SMALL = 'SMALL', + MEDIUM = 'MEDIUM', + LARGE = 'LARGE', +} + +export type EmployeeTShirtSizes = Map; + export interface IAddress extends IConcept { street: string; city: string; state?: State; zipCode: string; country: string; - dictionary1: Map1; - dictionary2: Map2; - dictionary3: Map3; - dictionary4: Map4; - dictionary5: Map5; - dictionary6: Map6; } -export type Map1 = Map; +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 4`] = ` +{ + "key": "org.acme.hr.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: org.acme.hr + +// imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports +import {IAddress,IEmployeeTShirtSizes,ISSN} from './org.acme.hr.base'; +import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; + +// interfaces +export type CompanyProperties = Map; -export type Map2 = Map; +export type EmployeeLoginTimes = Map; -export type Map3 = Map; +export type EmployeeSocialSecurityNumbers = Map; -export type Map4 = Map; +export type NextOfKin = Map; -export type Map5 = Map; +export type EmployeeProfiles = Map; -export type Map6 = Map; +export type EmployeeDirectory = Map; export interface ICompany extends IConcept { name: string; headquarters: IAddress; + companyProperties?: CompanyProperties; + employeeDirectory?: EmployeeDirectory; + employeeTShirtSizes?: EmployeeTShirtSizes; + employeeProfiles?: EmployeeProfiles; + employeeSocialSecurityNumbers?: EmployeeSocialSecurityNumbers; } export enum Department { @@ -4637,6 +4981,7 @@ export interface IPerson extends IParticipant { ssn: string; height: number; dob: Date; + nextOfKin: NextOfKin; } export type PersonUnion = IEmployee | @@ -4684,10 +5029,10 @@ export interface IChangeOfAddress extends ITransaction { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'vocabulary' 1`] = ` { - "key": "org.acme.hr_en.voc", - "value": "#Generated vocabulary for namespace: org.acme.hr + "key": "org.acme.hr.base_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr.base locale: en -namespace: org.acme.hr +namespace: org.acme.hr.base declarations: - State: State properties: @@ -4697,6 +5042,11 @@ declarations: - WA: WA of the State - IL: IL of the State - CA: CA of the State + - TShirtSizeType: TShirt Size Type + properties: + - SMALL: SMALL of the TShirt Size Type + - MEDIUM: MEDIUM of the TShirt Size Type + - LARGE: LARGE of the TShirt Size Type - Address: Address properties: - street: Street of the Address @@ -4704,17 +5054,28 @@ declarations: - state: State of the Address - zipCode: Zip Code of the Address - country: Country of the Address - - dictionary1: Dictionary1 of the Address - - dictionary2: Dictionary2 of the Address - - dictionary3: Dictionary3 of the Address - - dictionary4: Dictionary4 of the Address - - dictionary5: Dictionary5 of the Address - - dictionary6: Dictionary6 of the Address - Time: Time + - SSN: SSN +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'vocabulary' 2`] = ` +{ + "key": "org.acme.hr_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr +locale: en +namespace: org.acme.hr +declarations: - Company: Company properties: - name: Name of the Company - headquarters: Headquarters of the Company + - companyProperties: Company Properties of the Company + - employeeDirectory: Employee Directory of the Company + - employeeTShirtSizes: Employee TShirt Sizes of the Company + - employeeProfiles: Employee Profiles of the Company + - employeeSocialSecurityNumbers: Employee Social Security Numbers of the Company - Department: Department properties: - Sales: Sales of the Department @@ -4733,7 +5094,6 @@ declarations: - Laptop: Laptop properties: - make: Make of the Laptop - - SSN: SSN - Person: Person properties: - email: Email of the Person @@ -4744,6 +5104,7 @@ declarations: - ssn: Ssn of the Person - height: Height of the Person - dob: Dob of the Person + - nextOfKin: Next Of Kin of the Person - Employee: Employee properties: - employeeId: Employee Id of the Employee @@ -4769,6 +5130,8 @@ declarations: properties: - Person: Person of the Change Of Address - newAddress: New Address of the Change Of Address + - KinName: Kin Name + - KinTelephone: Kin Telephone ", } `; @@ -4885,9 +5248,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 3`] = ` { - "key": "org.acme.hr.xsd", + "key": "org.acme.hr.base.xsd", "value": " - @@ -4901,33 +5264,55 @@ xmlns:concerto="concerto" - + + + + + + + + + - + - - - - - - - + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 4`] = ` +{ + "key": "org.acme.hr.xsd", + "value": " + + + - + + + + + + @@ -4979,10 +5364,11 @@ xmlns:concerto="concerto" - + + @@ -4997,7 +5383,7 @@ xmlns:concerto="concerto" - + @@ -5050,7 +5436,7 @@ xmlns:concerto="concerto" - + @@ -5065,7 +5451,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "model.mmd", "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { +class \`org.acme.hr.base@1.0.0.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -5075,35 +5461,40 @@ class \`org.acme.hr@1.0.0.State\` { + \`CA\` } -class \`org.acme.hr@1.0.0.Address\` { +class \`org.acme.hr.base@1.0.0.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +class \`org.acme.hr.base@1.0.0.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` +} + +\`org.acme.hr.base@1.0.0.Address\` "1" *-- "1" \`org.acme.hr.base@1.0.0.State\` class \`org.acme.hr@1.0.0.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.CompanyProperties\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeDirectory\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeProfiles\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` class \`org.acme.hr@1.0.0.Department\` { << enumeration>> + \`Sales\` @@ -5142,10 +5533,12 @@ class \`org.acme.hr@1.0.0.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.NextOfKin\` class \`org.acme.hr@1.0.0.Employee\` { << participant>> + \`String\` \`employeeId\` @@ -5159,7 +5552,7 @@ class \`org.acme.hr@1.0.0.Employee\` { } \`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager \`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` @@ -5196,7 +5589,7 @@ class \`org.acme.hr@1.0.0.ChangeOfAddress\` { } \`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` ", } `; @@ -5208,7 +5601,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio title Model endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { +class org.acme.hr.base_1_0_0.State << (E,grey) >> { + MA + NY + CO @@ -5216,31 +5609,34 @@ class org.acme.hr_1_0_0.State << (E,grey) >> { + IL + CA } -class org.acme.hr_1_0_0.Address { +class org.acme.hr.base_1_0_0.TShirtSizeType << (E,grey) >> { + + SMALL + + MEDIUM + + LARGE +} +class org.acme.hr.base_1_0_0.Address { + String street + String city + State state + String zipCode + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map1 : dictionary1 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map2 : dictionary2 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map3 : dictionary3 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map4 : dictionary4 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map5 : dictionary5 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map6 : dictionary6 +} +org.acme.hr.base_1_0_0.Address "1" *-- "1" org.acme.hr.base_1_0_0.State : state class org.acme.hr_1_0_0.Company { + String name + Address headquarters -} -org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters + + CompanyProperties companyProperties + + EmployeeDirectory employeeDirectory + + EmployeeTShirtSizes employeeTShirtSizes + + EmployeeProfiles employeeProfiles + + EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers +} +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.Address : headquarters +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.CompanyProperties : companyProperties +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeDirectory : employeeDirectory +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.EmployeeTShirtSizes : employeeTShirtSizes +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeProfiles : employeeProfiles +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeSocialSecurityNumbers : employeeSocialSecurityNumbers class org.acme.hr_1_0_0.Department << (E,grey) >> { + Sales + Marketing @@ -5270,9 +5666,11 @@ class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + String ssn + Double height + DateTime dob + + NextOfKin nextOfKin } -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.Address : homeAddress -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.Address : homeAddress +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.NextOfKin : nextOfKin class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + String employeeId + Long salary @@ -5284,7 +5682,7 @@ class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + Manager manager } org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Department : department -org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Address : officeAddress +org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr.base_1_0_0.Address : officeAddress org.acme.hr_1_0_0.Employee "1" *-- "*" org.acme.hr_1_0_0.Equipment : companyAssets org.acme.hr_1_0_0.Employee "1" o-- "1" org.acme.hr_1_0_0.Manager : manager org.acme.hr_1_0_0.Employee --|> org.acme.hr_1_0_0.Person @@ -5312,7 +5710,7 @@ class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + Address newAddress } org.acme.hr_1_0_0.ChangeOfAddress "1" o-- "1" org.acme.hr_1_0_0.Person : Person -org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr_1_0_0.Address : newAddress +org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr.base_1_0_0.Address : newAddress @enduml ", } @@ -5382,8 +5780,8 @@ protocol MyProtocol { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 3`] = ` { - "key": "org.acme.hr@1.0.0.avdl", - "value": "@namespace("org.acme.hr@1.0.0") + "key": "org.acme.hr.base@1.0.0.avdl", + "value": "@namespace("org.acme.hr.base@1.0.0") protocol MyProtocol { import idl "concerto@1.0.0.avdl"; @@ -5397,23 +5795,42 @@ protocol MyProtocol { CA } + enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE + } + record Address { string street; string city; union { null, State } state; string zipCode; string country; - Map1 dictionary1; - Map2 dictionary2; - Map3 dictionary3; - Map4 dictionary4; - Map5 dictionary5; - Map6 dictionary6; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.avdl", + "value": "@namespace("org.acme.hr@1.0.0") +protocol MyProtocol { + + import idl "org.acme.hr.base@1.0.0.avdl"; + import idl "concerto@1.0.0.avdl"; + record Company { string name; Address headquarters; + union { null, CompanyProperties } companyProperties; + union { null, EmployeeDirectory } employeeDirectory; + union { null, EmployeeTShirtSizes } employeeTShirtSizes; + union { null, EmployeeProfiles } employeeProfiles; + union { null, EmployeeSocialSecurityNumbers } employeeSocialSecurityNumbers; } enum Department { @@ -5449,6 +5866,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Employee { @@ -5469,6 +5887,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Contractor { @@ -5483,6 +5902,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Manager { @@ -5504,6 +5924,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record CompanyEvent { @@ -5623,8 +6044,8 @@ public abstract class Event : Concept { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 3`] = ` { - "key": "org.acme.hr@1.0.0.cs", - "value": "namespace org.acme.hr; + "key": "org.acme.hr.base@1.0.0.cs", + "value": "namespace org.acme.hr.base; using AccordProject.Concerto; [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum State { @@ -5635,32 +6056,49 @@ public enum State { IL, CA, } -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Address")] +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr.base", Version = "1.0.0", Name = "Address")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Address : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Address"; + public override string _class { get; } = "org.acme.hr.base@1.0.0.Address"; public string street { get; set; } public string city { get; set; } public State? state { get; set; } public string zipCode { get; set; } public string country { get; set; } - public Dictionary dictionary1 { get; set; } - public Dictionary dictionary2 { get; set; } - public Dictionary dictionary3 { get; set; } - public Dictionary dictionary4 { get; set; } - public Dictionary dictionary5 { get; set; } - public Dictionary dictionary6 { get; set; } } //Dummy implementation of the scalar declaration to avoid compilation errors. class Time_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class SSN_Dummy {} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.cs", + "value": "namespace org.acme.hr; +using org.acme.hr.base; +using AccordProject.Concerto; [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Company")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Company : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr@1.0.0.Company"; public string name { get; set; } - public Address headquarters { get; set; } + public org.acme.hr.base.Address headquarters { get; set; } + public Dictionary companyProperties { get; set; } + public Dictionary employeeDirectory { get; set; } + public Dictionary employeeTShirtSizes { get; set; } + public Dictionary employeeProfiles { get; set; } + public Dictionary employeeSocialSecurityNumbers { get; set; } } [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum Department { @@ -5691,8 +6129,6 @@ public class Laptop : Equipment { public override string _class { get; } = "org.acme.hr@1.0.0.Laptop"; public LaptopMake make { get; set; } } -//Dummy implementation of the scalar declaration to avoid compilation errors. -class SSN_Dummy {} [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Person")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public abstract class Person : Participant { @@ -5703,11 +6139,12 @@ public abstract class Person : Participant { public string firstName { get; set; } public string lastName { get; set; } public string? middleNames { get; set; } - public Address homeAddress { get; set; } + public org.acme.hr.base.Address homeAddress { get; set; } [System.ComponentModel.DataAnnotations.RegularExpression(@"\\d{3}-\\d{2}-\\{4}+", ErrorMessage = "Invalid characters")] public string ssn { get; set; } public float height { get; set; } public System.DateTime dob { get; set; } + public Dictionary nextOfKin { get; set; } } [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Employee")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] @@ -5719,7 +6156,7 @@ public class Employee : Person { public int numDependents { get; set; } public bool retired { get; set; } public Department department { get; set; } - public Address officeAddress { get; set; } + public org.acme.hr.base.Address officeAddress { get; set; } public Equipment[] companyAssets { get; set; } public Manager manager { get; set; } } @@ -5757,8 +6194,12 @@ public class ChangeOfAddress : Transaction { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr@1.0.0.ChangeOfAddress"; public Person Person { get; set; } - public Address newAddress { get; set; } + public org.acme.hr.base.Address newAddress { get; set; } } +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinName_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinTelephone_Dummy {} ", } `; @@ -5820,10 +6261,9 @@ type Event struct { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 3`] = ` { - "key": "org.acme.hr@1.0.0.go", - "value": "// Package org_acme_hr_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr@1.0.0. -package org_acme_hr_1_0_0 -import "time" + "key": "org.acme.hr.base@1.0.0.go", + "value": "// Package org_acme_hr_base_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr.base@1.0.0. +package org_acme_hr_base_1_0_0 import "concerto_1_0_0"; type State int @@ -5835,6 +6275,12 @@ const ( IL CA ) +type TShirtSizeType int +const ( + SMALL TShirtSizeType = 1 + iota + MEDIUM + LARGE +) type Address struct { concerto_1_0_0.Concept Street string \`json:"street"\` @@ -5842,17 +6288,29 @@ type Address struct { State State \`json:"state"\` ZipCode string \`json:"zipCode"\` Country string \`json:"country"\` - Dictionary1 Map1 \`json:"dictionary1"\` - Dictionary2 Map2 \`json:"dictionary2"\` - Dictionary3 Map3 \`json:"dictionary3"\` - Dictionary4 Map4 \`json:"dictionary4"\` - Dictionary5 Map5 \`json:"dictionary5"\` - Dictionary6 Map6 \`json:"dictionary6"\` } +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.go", + "value": "// Package org_acme_hr_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr@1.0.0. +package org_acme_hr_1_0_0 +import "time" +import "org_acme_hr_base_1_0_0"; +import "concerto_1_0_0"; + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` Headquarters Address \`json:"headquarters"\` + CompanyProperties CompanyProperties \`json:"companyProperties"\` + EmployeeDirectory EmployeeDirectory \`json:"employeeDirectory"\` + EmployeeTShirtSizes EmployeeTShirtSizes \`json:"employeeTShirtSizes"\` + EmployeeProfiles EmployeeProfiles \`json:"employeeProfiles"\` + EmployeeSocialSecurityNumbers EmployeeSocialSecurityNumbers \`json:"employeeSocialSecurityNumbers"\` } type Department int const ( @@ -5886,6 +6344,7 @@ type Person struct { Ssn string \`json:"ssn"\` Height float64 \`json:"height"\` Dob time.Time \`json:"dob"\` + NextOfKin NextOfKin \`json:"nextOfKin"\` } type Employee struct { Person @@ -5928,7 +6387,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "model.gql", "value": "directive @resource on OBJECT | FIELD_DEFINITION scalar DateTime -# namespace org.acme.hr@1.0.0 +# namespace org.acme.hr.base@1.0.0 enum State { MA NY @@ -5937,46 +6396,55 @@ enum State { IL CA } +enum TShirtSizeType { + SMALL + MEDIUM + LARGE +} +type EmployeeTShirtSizes { + key: SSN + value: TShirtSizeType +} type Address { street: String! city: String! state: State zipCode: String! country: String! - dictionary1: Map1! - dictionary2: Map2! - dictionary3: Map3! - dictionary4: Map4! - dictionary5: Map5! - dictionary6: Map6! -} -type Map1 { +} +# namespace org.acme.hr@1.0.0 +type CompanyProperties { key: String value: String } -type Map2 { +type EmployeeLoginTimes { key: String - value: DateTime + value: Time } -type Map3 { +type EmployeeSocialSecurityNumbers { key: String value: SSN } -type Map4 { +type NextOfKin { + key: KinName + value: KinTelephone +} +type EmployeeProfiles { key: String value: Concept } -type Map5 { - key: SSN - value: String -} -type Map6 { +type EmployeeDirectory { key: SSN value: Employee } type Company { name: String! headquarters: Address! + companyProperties: CompanyProperties + employeeDirectory: EmployeeDirectory + employeeTShirtSizes: EmployeeTShirtSizes + employeeProfiles: EmployeeProfiles + employeeSocialSecurityNumbers: EmployeeSocialSecurityNumbers } enum Department { Sales @@ -6008,6 +6476,7 @@ type Person @resource { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Employee { @@ -6027,6 +6496,7 @@ type Employee { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Contractor { @@ -6040,6 +6510,7 @@ type Contractor { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Manager { @@ -6060,6 +6531,7 @@ type Manager { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type CompanyEvent { @@ -6203,9 +6675,9 @@ public abstract class Event extends Concept { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 6`] = ` { - "key": "org/acme/hr/State.java", + "key": "org/acme/hr/base/State.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"$class"}) @@ -6223,9 +6695,26 @@ public enum State { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 7`] = ` { - "key": "org/acme/hr/Address.java", + "key": "org/acme/hr/base/TShirtSizeType.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 8`] = ` +{ + "key": "org/acme/hr/base/Address.java", + "value": "// this code is generated and should not be modified +package org.acme.hr.base; import concerto.Concept; import concerto.Asset; @@ -6241,12 +6730,6 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map1 dictionary1; - private Map2 dictionary2; - private Map3 dictionary3; - private Map4 dictionary4; - private Map5 dictionary5; - private Map6 dictionary6; public String getStreet() { return this.street; } @@ -6262,24 +6745,6 @@ public class Address extends Concept { public String getCountry() { return this.country; } - public Map1 getDictionary1() { - return this.dictionary1; - } - public Map2 getDictionary2() { - return this.dictionary2; - } - public Map3 getDictionary3() { - return this.dictionary3; - } - public Map4 getDictionary4() { - return this.dictionary4; - } - public Map5 getDictionary5() { - return this.dictionary5; - } - public Map6 getDictionary6() { - return this.dictionary6; - } public void setStreet(String street) { this.street = street; } @@ -6295,35 +6760,22 @@ public class Address extends Concept { public void setCountry(String country) { this.country = country; } - public void setDictionary1(Map1 dictionary1) { - this.dictionary1 = dictionary1; - } - public void setDictionary2(Map2 dictionary2) { - this.dictionary2 = dictionary2; - } - public void setDictionary3(Map3 dictionary3) { - this.dictionary3 = dictionary3; - } - public void setDictionary4(Map4 dictionary4) { - this.dictionary4 = dictionary4; - } - public void setDictionary5(Map5 dictionary5) { - this.dictionary5 = dictionary5; - } - public void setDictionary6(Map6 dictionary6) { - this.dictionary6 = dictionary6; - } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 8`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 9`] = ` { "key": "org/acme/hr/Company.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6335,24 +6787,59 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; + private CompanyProperties companyProperties; + private EmployeeDirectory employeeDirectory; + private EmployeeTShirtSizes employeeTShirtSizes; + private EmployeeProfiles employeeProfiles; + private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; public String getName() { return this.name; } public Address getHeadquarters() { return this.headquarters; } + public CompanyProperties getCompanyProperties() { + return this.companyProperties; + } + public EmployeeDirectory getEmployeeDirectory() { + return this.employeeDirectory; + } + public EmployeeTShirtSizes getEmployeeTShirtSizes() { + return this.employeeTShirtSizes; + } + public EmployeeProfiles getEmployeeProfiles() { + return this.employeeProfiles; + } + public EmployeeSocialSecurityNumbers getEmployeeSocialSecurityNumbers() { + return this.employeeSocialSecurityNumbers; + } public void setName(String name) { this.name = name; } public void setHeadquarters(Address headquarters) { this.headquarters = headquarters; } + public void setCompanyProperties(CompanyProperties companyProperties) { + this.companyProperties = companyProperties; + } + public void setEmployeeDirectory(EmployeeDirectory employeeDirectory) { + this.employeeDirectory = employeeDirectory; + } + public void setEmployeeTShirtSizes(EmployeeTShirtSizes employeeTShirtSizes) { + this.employeeTShirtSizes = employeeTShirtSizes; + } + public void setEmployeeProfiles(EmployeeProfiles employeeProfiles) { + this.employeeProfiles = employeeProfiles; + } + public void setEmployeeSocialSecurityNumbers(EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers) { + this.employeeSocialSecurityNumbers = employeeSocialSecurityNumbers; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 9`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 10`] = ` { "key": "org/acme/hr/Department.java", "value": "// this code is generated and should not be modified @@ -6372,12 +6859,17 @@ public enum Department { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 10`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 11`] = ` { "key": "org/acme/hr/Equipment.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6406,7 +6898,7 @@ public abstract class Equipment extends Asset { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 11`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 12`] = ` { "key": "org/acme/hr/LaptopMake.java", "value": "// this code is generated and should not be modified @@ -6422,12 +6914,17 @@ public enum LaptopMake { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 12`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 13`] = ` { "key": "org/acme/hr/Laptop.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6456,12 +6953,17 @@ public class Laptop extends Equipment { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 13`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 14`] = ` { "key": "org/acme/hr/Person.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6486,6 +6988,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; + private NextOfKin nextOfKin; public String getEmail() { return this.email; } @@ -6510,6 +7013,9 @@ public abstract class Person extends Participant { public java.util.Date getDob() { return this.dob; } + public NextOfKin getNextOfKin() { + return this.nextOfKin; + } public void setEmail(String email) { this.email = email; } @@ -6534,17 +7040,25 @@ public abstract class Person extends Participant { public void setDob(java.util.Date dob) { this.dob = dob; } + public void setNextOfKin(NextOfKin nextOfKin) { + this.nextOfKin = nextOfKin; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 14`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 15`] = ` { "key": "org/acme/hr/Employee.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6622,12 +7136,17 @@ public class Employee extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 15`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 16`] = ` { "key": "org/acme/hr/Contractor.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6663,12 +7182,17 @@ public class Contractor extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 16`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 17`] = ` { "key": "org/acme/hr/Manager.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6697,12 +7221,17 @@ public class Manager extends Employee { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 17`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 18`] = ` { "key": "org/acme/hr/CompanyEvent.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6716,12 +7245,17 @@ public class CompanyEvent extends Event { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 18`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 19`] = ` { "key": "org/acme/hr/Onboarded.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6742,12 +7276,17 @@ public class Onboarded extends CompanyEvent { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 19`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 20`] = ` { "key": "org/acme/hr/ChangeOfAddress.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6781,9 +7320,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { - "org.acme.hr@1.0.0.State": { + "org.acme.hr.base@1.0.0.State": { "title": "State", - "description": "An instance of org.acme.hr@1.0.0.State", + "description": "An instance of org.acme.hr.base@1.0.0.State", "enum": [ "MA", "NY", @@ -6793,16 +7332,25 @@ exports[`codegen #formats check we can convert all formats from namespace versio "CA" ] }, - "org.acme.hr@1.0.0.Address": { + "org.acme.hr.base@1.0.0.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base@1.0.0.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base@1.0.0.Address": { "title": "Address", - "description": "An instance of org.acme.hr@1.0.0.Address", + "description": "An instance of org.acme.hr.base@1.0.0.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr@1.0.0.Address", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Address$", - "description": "The class identifier for org.acme.hr@1.0.0.Address" + "default": "org.acme.hr.base@1.0.0.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base@1\\\\.0\\\\.0\\\\.Address$", + "description": "The class identifier for org.acme.hr.base@1.0.0.Address" }, "street": { "type": "string" @@ -6811,7 +7359,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "state": { - "$ref": "#/definitions/org.acme.hr@1.0.0.State" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.State" }, "zipCode": { "type": "string" @@ -6909,19 +7457,17 @@ exports[`codegen #formats check we can convert all formats from namespace versio "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr@1.0.0.Time": { + "org.acme.hr.base@1.0.0.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base@1.0.0.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr@1.0.0.Company": { "title": "Company", "description": "An instance of org.acme.hr@1.0.0.Company", @@ -6937,7 +7483,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "headquarters": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -7015,10 +7561,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "serialNumber" ] }, - "org.acme.hr@1.0.0.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr@1.0.0.Person": { "title": "Person", "description": "An instance of org.acme.hr@1.0.0.Person", @@ -7044,7 +7586,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7067,7 +7609,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -7100,7 +7643,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/definitions/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -7133,7 +7676,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7163,7 +7706,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Contractor": { @@ -7198,7 +7742,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7222,7 +7766,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Manager": { @@ -7259,7 +7804,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/definitions/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -7292,7 +7837,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7322,7 +7867,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.CompanyEvent": { @@ -7378,7 +7924,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" }, "newAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -7386,6 +7932,13 @@ exports[`codegen #formats check we can convert all formats from namespace versio "Person", "newAddress" ] + }, + "org.acme.hr@1.0.0.KinName": { + "type": "string" + }, + "org.acme.hr@1.0.0.KinTelephone": { + "format": "date-time", + "type": "string" } } } @@ -7396,16 +7949,16 @@ exports[`codegen #formats check we can convert all formats from namespace versio exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'markdown' 1`] = ` { "key": "models.md", - "value": "# Namespace org.acme.hr@1.0.0 + "value": "# Namespace org.acme.hr.base@1.0.0 ## Overview -- 2 concepts -- 3 enumerations -- 2 assets -- 4 participants -- 1 transactions -- 2 events -- 22 total declarations +- 1 concepts +- 2 enumerations +- 0 assets +- 0 participants +- 0 transactions +- 0 events +- 6 total declarations ## Imports - concerto@1.0.0.Concept @@ -7417,7 +7970,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio ## Diagram \`\`\`mermaid classDiagram -class \`org.acme.hr@1.0.0.State\` { +class \`org.acme.hr.base@1.0.0.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -7427,35 +7980,68 @@ class \`org.acme.hr@1.0.0.State\` { + \`CA\` } -class \`org.acme.hr@1.0.0.Address\` { +class \`org.acme.hr.base@1.0.0.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +class \`org.acme.hr.base@1.0.0.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` +} + +\`org.acme.hr.base@1.0.0.Address\` "1" *-- "1" \`org.acme.hr.base@1.0.0.State\` +\`\`\` + +# Namespace org.acme.hr@1.0.0 + +## Overview +- 1 concepts +- 2 enumerations +- 2 assets +- 4 participants +- 1 transactions +- 2 events +- 20 total declarations + +## Imports +- org.acme.hr.base@1.0.0.Address +- org.acme.hr.base@1.0.0.State +- org.acme.hr.base@1.0.0.SSN +- org.acme.hr.base@1.0.0.Time +- org.acme.hr.base@1.0.0.EmployeeTShirtSizes +- concerto@1.0.0.Concept +- concerto@1.0.0.Asset +- concerto@1.0.0.Transaction +- concerto@1.0.0.Participant +- concerto@1.0.0.Event + +## Diagram +\`\`\`mermaid +classDiagram class \`org.acme.hr@1.0.0.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.CompanyProperties\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeDirectory\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeProfiles\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` class \`org.acme.hr@1.0.0.Department\` { << enumeration>> + \`Sales\` @@ -7494,10 +8080,12 @@ class \`org.acme.hr@1.0.0.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.NextOfKin\` class \`org.acme.hr@1.0.0.Employee\` { << participant>> + \`String\` \`employeeId\` @@ -7511,7 +8099,7 @@ class \`org.acme.hr@1.0.0.Employee\` { } \`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager \`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` @@ -7548,7 +8136,7 @@ class \`org.acme.hr@1.0.0.ChangeOfAddress\` { } \`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`\`\` ", @@ -7559,7 +8147,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "model.mmd", "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { +class \`org.acme.hr.base@1.0.0.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -7569,37 +8157,43 @@ class \`org.acme.hr@1.0.0.State\` { + \`CA\` } -\`org.acme.hr@1.0.0.State\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Address\` { +\`org.acme.hr.base@1.0.0.State\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base@1.0.0.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +\`org.acme.hr.base@1.0.0.TShirtSizeType\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base@1.0.0.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` -\`org.acme.hr@1.0.0.Address\` --|> \`concerto@1.0.0.Concept\` +} + +\`org.acme.hr.base@1.0.0.Address\` "1" *-- "1" \`org.acme.hr.base@1.0.0.State\` +\`org.acme.hr.base@1.0.0.Address\` --|> \`concerto@1.0.0.Concept\` class \`org.acme.hr@1.0.0.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.CompanyProperties\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeDirectory\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeProfiles\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` \`org.acme.hr@1.0.0.Company\` --|> \`concerto@1.0.0.Concept\` class \`org.acme.hr@1.0.0.Department\` { << enumeration>> @@ -7642,10 +8236,12 @@ class \`org.acme.hr@1.0.0.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.NextOfKin\` \`org.acme.hr@1.0.0.Person\` --|> \`concerto@1.0.0.Participant\` class \`org.acme.hr@1.0.0.Employee\` { << participant>> @@ -7660,7 +8256,7 @@ class \`org.acme.hr@1.0.0.Employee\` { } \`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager \`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` @@ -7698,7 +8294,7 @@ class \`org.acme.hr@1.0.0.ChangeOfAddress\` { } \`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --|> \`concerto@1.0.0.Transaction\` ", } @@ -7739,7 +8335,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 2`] = ` { - "key": "org.acme.hr.csdl", + "key": "org.acme.hr.base.csdl", "value": " @@ -7749,7 +8345,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7764,34 +8360,65 @@ exports[`codegen #formats check we can convert all formats from namespace versio + + + + + + + + - + - - - + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 3`] = ` +{ + "key": "org.acme.hr.csdl", + "value": " + + + + + + + + + + + + + + - + - + - + - + - - - + - + @@ -7835,7 +8462,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7843,6 +8470,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio + + @@ -7855,7 +8484,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7881,7 +8510,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7910,9 +8539,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio }, "components": { "schemas": { - "org.acme.hr@1.0.0.State": { + "org.acme.hr.base@1.0.0.State": { "title": "State", - "description": "An instance of org.acme.hr@1.0.0.State", + "description": "An instance of org.acme.hr.base@1.0.0.State", "enum": [ "MA", "NY", @@ -7922,16 +8551,25 @@ exports[`codegen #formats check we can convert all formats from namespace versio "CA" ] }, - "org.acme.hr@1.0.0.Address": { + "org.acme.hr.base@1.0.0.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base@1.0.0.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base@1.0.0.Address": { "title": "Address", - "description": "An instance of org.acme.hr@1.0.0.Address", + "description": "An instance of org.acme.hr.base@1.0.0.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr@1.0.0.Address", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Address$", - "description": "The class identifier for org.acme.hr@1.0.0.Address" + "default": "org.acme.hr.base@1.0.0.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base@1\\\\.0\\\\.0\\\\.Address$", + "description": "The class identifier for org.acme.hr.base@1.0.0.Address" }, "street": { "type": "string" @@ -7940,7 +8578,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "state": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.State" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.State" }, "zipCode": { "type": "string" @@ -8038,19 +8676,17 @@ exports[`codegen #formats check we can convert all formats from namespace versio "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr@1.0.0.Time": { + "org.acme.hr.base@1.0.0.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base@1.0.0.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr@1.0.0.Company": { "title": "Company", "description": "An instance of org.acme.hr@1.0.0.Company", @@ -8066,7 +8702,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "headquarters": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -8144,10 +8780,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "serialNumber" ] }, - "org.acme.hr@1.0.0.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr@1.0.0.Person": { "title": "Person", "description": "An instance of org.acme.hr@1.0.0.Person", @@ -8173,7 +8805,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -8196,7 +8828,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -8229,7 +8862,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -8262,7 +8895,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -8292,7 +8925,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Contractor": { @@ -8327,7 +8961,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -8351,7 +8985,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Manager": { @@ -8388,7 +9023,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -8421,7 +9056,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -8451,7 +9086,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.CompanyEvent": { @@ -8507,7 +9143,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" }, "newAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -8515,6 +9151,13 @@ exports[`codegen #formats check we can convert all formats from namespace versio "Person", "newAddress" ] + }, + "org.acme.hr@1.0.0.KinName": { + "type": "string" + }, + "org.acme.hr@1.0.0.KinTelephone": { + "format": "date-time", + "type": "string" } } }, @@ -8778,7 +9421,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio title Model endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { +class org.acme.hr.base_1_0_0.State << (E,grey) >> { + MA + NY + CO @@ -8786,33 +9429,37 @@ class org.acme.hr_1_0_0.State << (E,grey) >> { + IL + CA } -org.acme.hr_1_0_0.State --|> concerto_1_0_0.Concept -class org.acme.hr_1_0_0.Address { +org.acme.hr.base_1_0_0.State --|> concerto_1_0_0.Concept +class org.acme.hr.base_1_0_0.TShirtSizeType << (E,grey) >> { + + SMALL + + MEDIUM + + LARGE +} +org.acme.hr.base_1_0_0.TShirtSizeType --|> concerto_1_0_0.Concept +class org.acme.hr.base_1_0_0.Address { + String street + String city + State state + String zipCode + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map1 : dictionary1 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map2 : dictionary2 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map3 : dictionary3 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map4 : dictionary4 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map5 : dictionary5 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map6 : dictionary6 -org.acme.hr_1_0_0.Address --|> concerto_1_0_0.Concept +} +org.acme.hr.base_1_0_0.Address "1" *-- "1" org.acme.hr.base_1_0_0.State : state +org.acme.hr.base_1_0_0.Address --|> concerto_1_0_0.Concept class org.acme.hr_1_0_0.Company { + String name + Address headquarters -} -org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters + + CompanyProperties companyProperties + + EmployeeDirectory employeeDirectory + + EmployeeTShirtSizes employeeTShirtSizes + + EmployeeProfiles employeeProfiles + + EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers +} +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.Address : headquarters +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.CompanyProperties : companyProperties +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeDirectory : employeeDirectory +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.EmployeeTShirtSizes : employeeTShirtSizes +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeProfiles : employeeProfiles +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeSocialSecurityNumbers : employeeSocialSecurityNumbers org.acme.hr_1_0_0.Company --|> concerto_1_0_0.Concept class org.acme.hr_1_0_0.Department << (E,grey) >> { + Sales @@ -8846,9 +9493,11 @@ class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + String ssn + Double height + DateTime dob + + NextOfKin nextOfKin } -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.Address : homeAddress -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.Address : homeAddress +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.NextOfKin : nextOfKin org.acme.hr_1_0_0.Person --|> concerto_1_0_0.Participant class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + String employeeId @@ -8861,7 +9510,7 @@ class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + Manager manager } org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Department : department -org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Address : officeAddress +org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr.base_1_0_0.Address : officeAddress org.acme.hr_1_0_0.Employee "1" *-- "*" org.acme.hr_1_0_0.Equipment : companyAssets org.acme.hr_1_0_0.Employee "1" o-- "1" org.acme.hr_1_0_0.Manager : manager org.acme.hr_1_0_0.Employee --|> org.acme.hr_1_0_0.Person @@ -8890,7 +9539,7 @@ class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + Address newAddress } org.acme.hr_1_0_0.ChangeOfAddress "1" o-- "1" org.acme.hr_1_0_0.Person : Person -org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr_1_0_0.Address : newAddress +org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr.base_1_0_0.Address : newAddress org.acme.hr_1_0_0.ChangeOfAddress --|> concerto_1_0_0.Transaction @enduml ", @@ -8899,10 +9548,10 @@ org.acme.hr_1_0_0.ChangeOfAddress --|> concerto_1_0_0.Transaction exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'protobuf' 1`] = ` { - "key": "org.acme.hr.v1_0_0.proto", + "key": "org.acme.hr.base.v1_0_0.proto", "value": "syntax = "proto3"; -package org.acme.hr.v1_0_0; +package org.acme.hr.base.v1_0_0; import "google/protobuf/timestamp.proto"; @@ -8915,23 +9564,42 @@ enum State { State_WA = 5; } +enum TShirtSizeType { + TShirtSizeType_LARGE = 0; + TShirtSizeType_MEDIUM = 1; + TShirtSizeType_SMALL = 2; +} + message Address { string city = 1; string country = 2; - Map1 dictionary1 = 3; - Map2 dictionary2 = 4; - Map3 dictionary3 = 5; - Map4 dictionary4 = 6; - Map5 dictionary5 = 7; - Map6 dictionary6 = 8; - optional State state = 9; - string street = 10; - string zipCode = 11; + optional State state = 3; + string street = 4; + string zipCode = 5; } +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'protobuf' 2`] = ` +{ + "key": "org.acme.hr.v1_0_0.proto", + "value": "syntax = "proto3"; + +package org.acme.hr.v1_0_0; + +import "google/protobuf/timestamp.proto"; +import "org.acme.hr.base.v1_0_0.proto"; + message Company { - Address headquarters = 1; - string name = 2; + optional CompanyProperties companyProperties = 1; + optional EmployeeDirectory employeeDirectory = 2; + optional EmployeeProfiles employeeProfiles = 3; + optional EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers = 4; + optional EmployeeTShirtSizes employeeTShirtSizes = 5; + Address headquarters = 6; + string name = 7; } enum Department { @@ -8979,11 +9647,12 @@ message Employee { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - bool retired = 14; - sint64 salary = 15; - string ssn = 16; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + bool retired = 15; + sint64 salary = 16; + string ssn = 17; } message _Subclasses_of_class_Employee { @@ -9003,7 +9672,8 @@ message Contractor { string lastName = 7; optional string manager = 8; optional string middleNames = 9; - string ssn = 10; + NextOfKin nextOfKin = 10; + string ssn = 11; } message Manager { @@ -9018,12 +9688,13 @@ message Manager { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - repeated string reports = 14; - bool retired = 15; - sint64 salary = 16; - string ssn = 17; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + repeated string reports = 15; + bool retired = 16; + sint64 salary = 17; + string ssn = 18; } message CompanyEvent { @@ -9057,6 +9728,8 @@ pub mod concerto_1_0_0; #[allow(unused_imports)] pub mod concerto; #[allow(unused_imports)] +pub mod org_acme_hr_base_1_0_0; +#[allow(unused_imports)] pub mod org_acme_hr_1_0_0; #[allow(unused_imports)] pub mod utils; @@ -9251,7 +9924,7 @@ pub struct Event { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'rust' 5`] = ` { - "key": "org_acme_hr_1_0_0.rs", + "key": "org_acme_hr_base_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; @@ -9274,6 +9947,16 @@ pub enum State { CA, } +#[derive(Debug, Serialize, Deserialize)] +pub enum TShirtSizeType { + #[allow(non_camel_case_types)] + SMALL, + #[allow(non_camel_case_types)] + MEDIUM, + #[allow(non_camel_case_types)] + LARGE, +} + #[derive(Debug, Serialize, Deserialize)] pub struct Address { #[serde( @@ -9306,54 +9989,68 @@ pub struct Address { rename = "country", )] pub country: String, +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'rust' 6`] = ` +{ + "key": "org_acme_hr_1_0_0.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; - #[serde( - rename = "dictionary1", - )] - pub dictionary1: Map1, +use crate::org_acme_hr_base_1_0_0::*; +use crate::concerto_1_0_0::*; +use crate::utils::*; +#[derive(Debug, Serialize, Deserialize)] +pub struct Company { #[serde( - rename = "dictionary2", + rename = "$class", )] - pub dictionary2: Map2, + pub _class: String, #[serde( - rename = "dictionary3", + rename = "name", )] - pub dictionary3: Map3, + pub name: String, #[serde( - rename = "dictionary4", + rename = "headquarters", )] - pub dictionary4: Map4, + pub headquarters: Address, #[serde( - rename = "dictionary5", + rename = "companyProperties", + skip_serializing_if = "Option::is_none", )] - pub dictionary5: Map5, + pub company_properties: Option, #[serde( - rename = "dictionary6", + rename = "employeeDirectory", + skip_serializing_if = "Option::is_none", )] - pub dictionary6: Map6, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Company { + pub employee_directory: Option, + #[serde( - rename = "$class", + rename = "employeeTShirtSizes", + skip_serializing_if = "Option::is_none", )] - pub _class: String, + pub employee_t_shirt_sizes: Option, #[serde( - rename = "name", + rename = "employeeProfiles", + skip_serializing_if = "Option::is_none", )] - pub name: String, + pub employee_profiles: Option, #[serde( - rename = "headquarters", + rename = "employeeSocialSecurityNumbers", + skip_serializing_if = "Option::is_none", )] - pub headquarters: Address, + pub employee_social_security_numbers: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -9471,6 +10168,11 @@ pub struct Person { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9565,6 +10267,11 @@ pub struct Employee { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9629,6 +10336,11 @@ pub struct Contractor { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9726,6 +10438,11 @@ pub struct Manager { )] pub dob: DateTime, + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9803,7 +10520,10 @@ exports[`codegen #formats check we can convert all formats from namespace versio // Warning: Beware of circular dependencies when modifying these imports import type { State, - IAddress, + TShirtSizeType, + IAddress +} from './org.acme.hr.base@1.0.0'; +import type { ICompany, Department, LaptopMake @@ -9898,20 +10618,12 @@ export interface IEvent extends IConcept { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'typescript' 3`] = ` { - "key": "org.acme.hr@1.0.0.ts", + "key": "org.acme.hr.base@1.0.0.ts", "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: org.acme.hr@1.0.0 +// Generated code for namespace: org.acme.hr.base@1.0.0 // imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports -import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; +import {IConcept} from './concerto@1.0.0'; // interfaces export enum State { @@ -9923,35 +10635,65 @@ export enum State { CA = 'CA', } +export enum TShirtSizeType { + SMALL = 'SMALL', + MEDIUM = 'MEDIUM', + LARGE = 'LARGE', +} + +export type EmployeeTShirtSizes = Map; + export interface IAddress extends IConcept { street: string; city: string; state?: State; zipCode: string; country: string; - dictionary1: Map1; - dictionary2: Map2; - dictionary3: Map3; - dictionary4: Map4; - dictionary5: Map5; - dictionary6: Map6; } -export type Map1 = Map; +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'typescript' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: org.acme.hr@1.0.0 + +// imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports +import {IAddress,IEmployeeTShirtSizes,ISSN} from './org.acme.hr.base@1.0.0'; +import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; -export type Map2 = Map; +// interfaces +export type CompanyProperties = Map; + +export type EmployeeLoginTimes = Map; -export type Map3 = Map; +export type EmployeeSocialSecurityNumbers = Map; -export type Map4 = Map; +export type NextOfKin = Map; -export type Map5 = Map; +export type EmployeeProfiles = Map; -export type Map6 = Map; +export type EmployeeDirectory = Map; export interface ICompany extends IConcept { name: string; headquarters: IAddress; + companyProperties?: CompanyProperties; + employeeDirectory?: EmployeeDirectory; + employeeTShirtSizes?: EmployeeTShirtSizes; + employeeProfiles?: EmployeeProfiles; + employeeSocialSecurityNumbers?: EmployeeSocialSecurityNumbers; } export enum Department { @@ -9987,6 +10729,7 @@ export interface IPerson extends IParticipant { ssn: string; height: number; dob: Date; + nextOfKin: NextOfKin; } export type PersonUnion = IEmployee | @@ -10034,10 +10777,10 @@ export interface IChangeOfAddress extends ITransaction { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'vocabulary' 1`] = ` { - "key": "org.acme.hr@1.0.0_en.voc", - "value": "#Generated vocabulary for namespace: org.acme.hr@1.0.0 + "key": "org.acme.hr.base@1.0.0_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr.base@1.0.0 locale: en -namespace: org.acme.hr@1.0.0 +namespace: org.acme.hr.base@1.0.0 declarations: - State: State properties: @@ -10047,6 +10790,11 @@ declarations: - WA: WA of the State - IL: IL of the State - CA: CA of the State + - TShirtSizeType: TShirt Size Type + properties: + - SMALL: SMALL of the TShirt Size Type + - MEDIUM: MEDIUM of the TShirt Size Type + - LARGE: LARGE of the TShirt Size Type - Address: Address properties: - street: Street of the Address @@ -10054,17 +10802,28 @@ declarations: - state: State of the Address - zipCode: Zip Code of the Address - country: Country of the Address - - dictionary1: Dictionary1 of the Address - - dictionary2: Dictionary2 of the Address - - dictionary3: Dictionary3 of the Address - - dictionary4: Dictionary4 of the Address - - dictionary5: Dictionary5 of the Address - - dictionary6: Dictionary6 of the Address - Time: Time + - SSN: SSN +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'vocabulary' 2`] = ` +{ + "key": "org.acme.hr@1.0.0_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr@1.0.0 +locale: en +namespace: org.acme.hr@1.0.0 +declarations: - Company: Company properties: - name: Name of the Company - headquarters: Headquarters of the Company + - companyProperties: Company Properties of the Company + - employeeDirectory: Employee Directory of the Company + - employeeTShirtSizes: Employee TShirt Sizes of the Company + - employeeProfiles: Employee Profiles of the Company + - employeeSocialSecurityNumbers: Employee Social Security Numbers of the Company - Department: Department properties: - Sales: Sales of the Department @@ -10083,7 +10842,6 @@ declarations: - Laptop: Laptop properties: - make: Make of the Laptop - - SSN: SSN - Person: Person properties: - email: Email of the Person @@ -10094,6 +10852,7 @@ declarations: - ssn: Ssn of the Person - height: Height of the Person - dob: Dob of the Person + - nextOfKin: Next Of Kin of the Person - Employee: Employee properties: - employeeId: Employee Id of the Employee @@ -10119,6 +10878,8 @@ declarations: properties: - Person: Person of the Change Of Address - newAddress: New Address of the Change Of Address + - KinName: Kin Name + - KinTelephone: Kin Telephone ", } `; @@ -10235,9 +10996,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'xmlschema' 3`] = ` { - "key": "org.acme.hr@1.0.0.xsd", + "key": "org.acme.hr.base@1.0.0.xsd", "value": " - @@ -10251,33 +11012,55 @@ xmlns:concerto="concerto" - + + + + + + + + + - + - - - - - - - + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'xmlschema' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.xsd", + "value": " + + + - + + + + + + @@ -10329,10 +11112,11 @@ xmlns:concerto="concerto" - + + @@ -10347,7 +11131,7 @@ xmlns:concerto="concerto" - + @@ -10400,7 +11184,7 @@ xmlns:concerto="concerto" - + diff --git a/test/codegen/codegen.js b/test/codegen/codegen.js index e4933acf..b80204d2 100644 --- a/test/codegen/codegen.js +++ b/test/codegen/codegen.js @@ -37,10 +37,15 @@ describe('codegen', function () { versionedModelManager = new ModelManager(); unversionedModelManager = new ModelManager(); + const base_cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr_base.cto', 'utf-8'); const cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); + + versionedModelManager.addCTOModel(base_cto, 'hr_base.cto'); versionedModelManager.addCTOModel(cto, 'hr.cto'); - const unversionedCto = cto.replace('namespace org.acme.hr@1.0.0', 'namespace org.acme.hr'); + const unversionedBaseCto = base_cto.replace('namespace org.acme.hr.base@1.0.0', 'namespace org.acme.hr.base'); + const unversionedCto = cto.replace('namespace org.acme.hr@1.0.0', 'namespace org.acme.hr').replace('import org.acme.hr.base@1.0.0', 'import org.acme.hr.base'); + unversionedModelManager.addCTOModel(unversionedBaseCto, 'hr_base.cto'); unversionedModelManager.addCTOModel(unversionedCto, 'hr.cto'); }); diff --git a/test/codegen/fromcto/csharp/csharpvisitor.js b/test/codegen/fromcto/csharp/csharpvisitor.js index 91dce556..28c5af63 100644 --- a/test/codegen/fromcto/csharp/csharpvisitor.js +++ b/test/codegen/fromcto/csharp/csharpvisitor.js @@ -1504,18 +1504,16 @@ public class SampleModel : Concept { it('should write a line for field name and type thats a map of ', () => { const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.getModelFile.returns({ getType: getType }); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('String'); mockField.getName.returns('Map1'); @@ -1530,18 +1528,17 @@ public class SampleModel : Concept { it('should write a line for field name and type thats a map of ', () => { const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.getModelFile.returns({ getType: getType }); + let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('Concept'); mockField.getName.returns('Map1'); @@ -1556,18 +1553,16 @@ public class SampleModel : Concept { it('should write a line for field name and type thats a map of ', () => { const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.getModelFile.returns({ getType: getType }); let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('DateTime'); mockField.getName.returns('Map1'); diff --git a/test/codegen/fromcto/data/model/hr.cto b/test/codegen/fromcto/data/model/hr.cto index 21c53218..cabf4d71 100644 --- a/test/codegen/fromcto/data/model/hr.cto +++ b/test/codegen/fromcto/data/model/hr.cto @@ -1,55 +1,33 @@ namespace org.acme.hr@1.0.0 -enum State { - o MA - o NY - o CO - o WA - o IL - o CA -} - -concept Address { - o String street - o String city - o State state optional - o String zipCode - o String country - o Map1 dictionary1 - o Map2 dictionary2 - o Map3 dictionary3 - o Map4 dictionary4 - o Map5 dictionary5 - o Map6 dictionary6 -} -scalar Time extends DateTime - -map Map1 { +import org.acme.hr.base@1.0.0.{Address, State, SSN, Time, EmployeeTShirtSizes} + +map CompanyProperties { o String o String } -map Map2 { +map EmployeeLoginTimes { o String - o DateTime + o Time } -map Map3 { +map EmployeeSocialSecurityNumbers { o String o SSN } -map Map4 { - o String - o Concept +map NextOfKin { + o KinName + o KinTelephone } -map Map5 { - o SSN +map EmployeeProfiles { o String + o Concept } -map Map6 { +map EmployeeDirectory { o SSN o Employee } @@ -57,6 +35,11 @@ map Map6 { concept Company { o String name o Address headquarters + o CompanyProperties companyProperties optional + o EmployeeDirectory employeeDirectory optional + o EmployeeTShirtSizes employeeTShirtSizes optional + o EmployeeProfiles employeeProfiles optional + o EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers optional } enum Department { @@ -82,8 +65,6 @@ asset Laptop extends Equipment { o LaptopMake make } -scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\{4}+/ - @resource abstract participant Person identified by email { o String email @@ -94,6 +75,7 @@ abstract participant Person identified by email { o SSN ssn o Double height o DateTime dob + o NextOfKin nextOfKin } participant Employee extends Person { @@ -107,9 +89,6 @@ participant Employee extends Person { --> Manager manager optional } - - - participant Contractor extends Person { o Company company --> Manager manager optional @@ -130,3 +109,6 @@ transaction ChangeOfAddress { --> Person Person o Address newAddress } + +scalar KinName extends String +scalar KinTelephone extends DateTime diff --git a/test/codegen/fromcto/data/model/hr_base.cto b/test/codegen/fromcto/data/model/hr_base.cto new file mode 100644 index 00000000..9a7fc935 --- /dev/null +++ b/test/codegen/fromcto/data/model/hr_base.cto @@ -0,0 +1,32 @@ +namespace org.acme.hr.base@1.0.0 + +enum State { + o MA + o NY + o CO + o WA + o IL + o CA +} + +enum TShirtSizeType { + o SMALL + o MEDIUM + o LARGE +} + +map EmployeeTShirtSizes { + o SSN + o TShirtSizeType +} + +concept Address { + o String street + o String city + o State state optional + o String zipCode + o String country +} + +scalar Time extends DateTime +scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\{4}+/ \ No newline at end of file diff --git a/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto b/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto index 42b43a87..7039a281 100644 --- a/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto +++ b/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto @@ -45,7 +45,7 @@ message Code { message Function { Code code = 1; - string emittedTypes = 2; + repeated string emittedTypes = 2; string name = 3; string requestType = 4; string responseType = 5; diff --git a/test/common/graph.js b/test/common/graph.js index 08a9f112..65fd5742 100644 --- a/test/common/graph.js +++ b/test/common/graph.js @@ -35,8 +35,10 @@ describe('graph', function () { beforeEach(function() { modelManager = new ModelManager(); - const cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); - modelManager.addCTOModel(cto, 'hr.cto'); + const hrBase = fs.readFileSync('./test/codegen/fromcto/data/model/hr_base.cto', 'utf-8'); + modelManager.addCTOModel(hrBase, 'hr_base.cto'); + const hr = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); + modelManager.addCTOModel(hr, 'hr.cto'); }); @@ -53,38 +55,43 @@ describe('graph', function () { graph.print(writer); writer.closeFile(); expect(writer.data.get('graph.mmd')).toEqual(`flowchart LR - \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.State\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Time\` - \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Map1\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Map2\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` --> \`DateTime\` - \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Map3\` --> \`String\` - \`org.acme.hr@1.0.0.Map3\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Map4\` --> \`String\` - \`org.acme.hr@1.0.0.Map4\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Map5\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map5\` --> \`String\` - \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.Employee\` + \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.State\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.TShirtSizeType\` + \`org.acme.hr.base@1.0.0.TShirtSizeType\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` + \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` --> \`org.acme.hr.base@1.0.0.TShirtSizeType\` + \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr.base@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.Address\` --> \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.Time\` + \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.CompanyProperties\` + \`org.acme.hr@1.0.0.CompanyProperties\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeLoginTimes\` + \`org.acme.hr@1.0.0.EmployeeLoginTimes\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeLoginTimes\` --> \`org.acme.hr.base@1.0.0.Time\` + \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` + \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.NextOfKin\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinTelephone\` + \`org.acme.hr@1.0.0.EmployeeProfiles\` + \`org.acme.hr@1.0.0.EmployeeProfiles\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeProfiles\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr@1.0.0.EmployeeDirectory\` + \`org.acme.hr@1.0.0.EmployeeDirectory\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.EmployeeDirectory\` --> \`org.acme.hr@1.0.0.Employee\` \`org.acme.hr@1.0.0.Company\` \`org.acme.hr@1.0.0.Company\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.CompanyProperties\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.EmployeeDirectory\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.EmployeeProfiles\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` \`org.acme.hr@1.0.0.Department\` \`org.acme.hr@1.0.0.Department\` --> \`concerto@1.0.0.Concept\` \`org.acme.hr@1.0.0.Equipment\` @@ -94,15 +101,15 @@ describe('graph', function () { \`org.acme.hr@1.0.0.Laptop\` \`org.acme.hr@1.0.0.Laptop\` --> \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Laptop\` --> \`org.acme.hr@1.0.0.LaptopMake\` - \`org.acme.hr@1.0.0.SSN\` \`org.acme.hr@1.0.0.Person\` \`org.acme.hr@1.0.0.Person\` --> \`concerto@1.0.0.Participant\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.SSN\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.NextOfKin\` \`org.acme.hr@1.0.0.Employee\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Person\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Department\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Manager\` \`org.acme.hr@1.0.0.Contractor\` @@ -120,10 +127,13 @@ describe('graph', function () { \`org.acme.hr@1.0.0.ChangeOfAddress\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`concerto@1.0.0.Transaction\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Person\` - \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.KinTelephone\` `); }); + it('should visit find a connected subgraph', function () { const visitor = new ConcertoGraphVisitor(); visitor.should.not.be.null; @@ -138,63 +148,33 @@ describe('graph', function () { const filteredModelManager = modelManager .filter(declaration => connectedGraph.hasVertex(declaration.getFullyQualifiedName())); - expect(filteredModelManager.getModelFiles()).toHaveLength(1); - expect(filteredModelManager.getModelFiles()[0].getAllDeclarations()).toHaveLength(15); + expect(filteredModelManager.getModelFiles()).toHaveLength(2); + expect(filteredModelManager.getModelFiles()[0].getAllDeclarations()).toHaveLength(3); writer.openFile('graph.mmd'); connectedGraph.print(writer); writer.closeFile(); expect(writer.data.get('graph.mmd')).toEqual(`flowchart LR - \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.State\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Map1\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Map2\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` --> \`DateTime\` - \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Map3\` --> \`String\` - \`org.acme.hr@1.0.0.Map3\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Map4\` --> \`String\` - \`org.acme.hr@1.0.0.Map4\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Map5\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map5\` --> \`String\` - \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.Employee\` - \`org.acme.hr@1.0.0.Department\` - \`org.acme.hr@1.0.0.Department\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Equipment\` - \`org.acme.hr@1.0.0.Equipment\` --> \`concerto@1.0.0.Asset\` - \`org.acme.hr@1.0.0.SSN\` + \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.State\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr.base@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.Address\` --> \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.NextOfKin\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinTelephone\` \`org.acme.hr@1.0.0.Person\` \`org.acme.hr@1.0.0.Person\` --> \`concerto@1.0.0.Participant\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Employee\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Person\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Department\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Equipment\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Manager\` - \`org.acme.hr@1.0.0.Manager\` - \`org.acme.hr@1.0.0.Manager\` --> \`org.acme.hr@1.0.0.Employee\` - \`org.acme.hr@1.0.0.Manager\` --> \`org.acme.hr@1.0.0.Person\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.NextOfKin\` \`org.acme.hr@1.0.0.ChangeOfAddress\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`concerto@1.0.0.Transaction\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Person\` - \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.KinTelephone\` `); }); }); diff --git a/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts b/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts index b4aa57cc..6deecc6c 100644 --- a/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts +++ b/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts @@ -66,6 +66,14 @@ declare class GraphQLVisitor { private visitEnumValueDeclaration; /** * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + private visitMapDeclaration; + /** + * Visitor design pattern * @param {Relationship} relationship - the object being visited * @param {Object} parameters - the parameter * @return {Object} the result of visiting or null From d98f071cbd18be70d097f7c7a74294682aa3c89e Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 6 Nov 2023 10:54:33 +0000 Subject: [PATCH 11/17] test(*): snapshot update Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 736 +++++++++++++-------- 1 file changed, 452 insertions(+), 284 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 98efae51..210dfb53 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1650,26 +1650,46 @@ exports[`codegen #formats check we can convert all formats from namespace unvers }, "country": { "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country" + ] + }, + "org.acme.hr.base.Time": { + "format": "date-time", + "type": "string" + }, + "org.acme.hr.base.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "org.acme.hr.Company": { + "title": "Company", + "description": "An instance of org.acme.hr.Company", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Company", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", + "description": "The class identifier for org.acme.hr.Company" }, - "dictionary1": { - "$id": "org.acme.hr.Address.dictionary1", - "schema": { - "title": "Map1", - "description": "An instance of org.acme.hr.Map1", - "type": "object", - "propertyNames": { - "type": "string" - }, - "additionalProperties": { - "type": "string" - } - } + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/definitions/org.acme.hr.base.Address" }, - "dictionary2": { - "$id": "org.acme.hr.Address.dictionary2", + "companyProperties": { + "$id": "org.acme.hr.Company.companyProperties", "schema": { - "title": "Map2", - "description": "An instance of org.acme.hr.Map2", + "title": "CompanyProperties", + "description": "An instance of org.acme.hr.CompanyProperties", "type": "object", "propertyNames": { "type": "string" @@ -1679,97 +1699,63 @@ exports[`codegen #formats check we can convert all formats from namespace unvers } } }, - "dictionary3": { - "$id": "org.acme.hr.Address.dictionary3", + "employeeDirectory": { + "$id": "org.acme.hr.Company.employeeDirectory", "schema": { - "title": "Map3", - "description": "An instance of org.acme.hr.Map3", + "title": "EmployeeDirectory", + "description": "An instance of org.acme.hr.EmployeeDirectory", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "SSN" + "$ref": "#/definitions/org.acme.hr.Employee" } } }, - "dictionary4": { - "$id": "org.acme.hr.Address.dictionary4", + "employeeTShirtSizes": { + "$id": "org.acme.hr.Company.employeeTShirtSizes", "schema": { - "title": "Map4", - "description": "An instance of org.acme.hr.Map4", + "title": "EmployeeTShirtSizes", + "description": "An instance of org.acme.hr.base.EmployeeTShirtSizes", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr.TShirtSizeType" } } }, - "dictionary5": { - "$id": "org.acme.hr.Address.dictionary5", + "employeeProfiles": { + "$id": "org.acme.hr.Company.employeeProfiles", "schema": { - "title": "Map5", - "description": "An instance of org.acme.hr.Map5", + "title": "EmployeeProfiles", + "description": "An instance of org.acme.hr.EmployeeProfiles", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "string" + "type": "Concept" } } }, - "dictionary6": { - "$id": "org.acme.hr.Address.dictionary6", + "employeeSocialSecurityNumbers": { + "$id": "org.acme.hr.Company.employeeSocialSecurityNumbers", "schema": { - "title": "Map6", - "description": "An instance of org.acme.hr.Map6", + "title": "EmployeeSocialSecurityNumbers", + "description": "An instance of org.acme.hr.EmployeeSocialSecurityNumbers", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "$ref": "#/definitions/org.acme.hr.Employee" + "type": "SSN" } } } }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country" - ] - }, - "org.acme.hr.base.Time": { - "format": "date-time", - "type": "string" - }, - "org.acme.hr.base.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "org.acme.hr.Company": { - "title": "Company", - "description": "An instance of org.acme.hr.Company", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Company", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", - "description": "The class identifier for org.acme.hr.Company" - }, - "name": { - "type": "string" - }, - "headquarters": { - "$ref": "#/definitions/org.acme.hr.base.Address" - } - }, "required": [ "$class", "name", @@ -1883,6 +1869,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -1973,6 +1973,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -2039,6 +2053,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -2134,6 +2162,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -2853,26 +2895,46 @@ exports[`codegen #formats check we can convert all formats from namespace unvers }, "country": { "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country" + ] + }, + "org.acme.hr.base.Time": { + "format": "date-time", + "type": "string" + }, + "org.acme.hr.base.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "org.acme.hr.Company": { + "title": "Company", + "description": "An instance of org.acme.hr.Company", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr.Company", + "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", + "description": "The class identifier for org.acme.hr.Company" }, - "dictionary1": { - "$id": "org.acme.hr.Address.dictionary1", - "schema": { - "title": "Map1", - "description": "An instance of org.acme.hr.Map1", - "type": "object", - "propertyNames": { - "type": "string" - }, - "additionalProperties": { - "type": "string" - } - } + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, - "dictionary2": { - "$id": "org.acme.hr.Address.dictionary2", + "companyProperties": { + "$id": "org.acme.hr.Company.companyProperties", "schema": { - "title": "Map2", - "description": "An instance of org.acme.hr.Map2", + "title": "CompanyProperties", + "description": "An instance of org.acme.hr.CompanyProperties", "type": "object", "propertyNames": { "type": "string" @@ -2882,97 +2944,63 @@ exports[`codegen #formats check we can convert all formats from namespace unvers } } }, - "dictionary3": { - "$id": "org.acme.hr.Address.dictionary3", + "employeeDirectory": { + "$id": "org.acme.hr.Company.employeeDirectory", "schema": { - "title": "Map3", - "description": "An instance of org.acme.hr.Map3", + "title": "EmployeeDirectory", + "description": "An instance of org.acme.hr.EmployeeDirectory", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "SSN" + "$ref": "#/definitions/org.acme.hr.Employee" } } }, - "dictionary4": { - "$id": "org.acme.hr.Address.dictionary4", + "employeeTShirtSizes": { + "$id": "org.acme.hr.Company.employeeTShirtSizes", "schema": { - "title": "Map4", - "description": "An instance of org.acme.hr.Map4", + "title": "EmployeeTShirtSizes", + "description": "An instance of org.acme.hr.base.EmployeeTShirtSizes", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr.TShirtSizeType" } } }, - "dictionary5": { - "$id": "org.acme.hr.Address.dictionary5", + "employeeProfiles": { + "$id": "org.acme.hr.Company.employeeProfiles", "schema": { - "title": "Map5", - "description": "An instance of org.acme.hr.Map5", + "title": "EmployeeProfiles", + "description": "An instance of org.acme.hr.EmployeeProfiles", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "string" + "type": "Concept" } } }, - "dictionary6": { - "$id": "org.acme.hr.Address.dictionary6", + "employeeSocialSecurityNumbers": { + "$id": "org.acme.hr.Company.employeeSocialSecurityNumbers", "schema": { - "title": "Map6", - "description": "An instance of org.acme.hr.Map6", + "title": "EmployeeSocialSecurityNumbers", + "description": "An instance of org.acme.hr.EmployeeSocialSecurityNumbers", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "$ref": "#/definitions/org.acme.hr.Employee" + "type": "SSN" } } } }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country" - ] - }, - "org.acme.hr.base.Time": { - "format": "date-time", - "type": "string" - }, - "org.acme.hr.base.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "org.acme.hr.Company": { - "title": "Company", - "description": "An instance of org.acme.hr.Company", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr.Company", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Company$", - "description": "The class identifier for org.acme.hr.Company" - }, - "name": { - "type": "string" - }, - "headquarters": { - "$ref": "#/components/schemas/org.acme.hr.base.Address" - } - }, "required": [ "$class", "name", @@ -3086,6 +3114,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -3176,6 +3218,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -3242,6 +3298,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -3337,6 +3407,20 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -7366,26 +7450,46 @@ exports[`codegen #formats check we can convert all formats from namespace versio }, "country": { "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country" + ] + }, + "org.acme.hr.base@1.0.0.Time": { + "format": "date-time", + "type": "string" + }, + "org.acme.hr.base@1.0.0.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "org.acme.hr@1.0.0.Company": { + "title": "Company", + "description": "An instance of org.acme.hr@1.0.0.Company", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Company", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Company$", + "description": "The class identifier for org.acme.hr@1.0.0.Company" }, - "dictionary1": { - "$id": "org.acme.hr@1.0.0.Address.dictionary1", - "schema": { - "title": "Map1", - "description": "An instance of org.acme.hr@1.0.0.Map1", - "type": "object", - "propertyNames": { - "type": "string" - }, - "additionalProperties": { - "type": "string" - } - } + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, - "dictionary2": { - "$id": "org.acme.hr@1.0.0.Address.dictionary2", + "companyProperties": { + "$id": "org.acme.hr@1.0.0.Company.companyProperties", "schema": { - "title": "Map2", - "description": "An instance of org.acme.hr@1.0.0.Map2", + "title": "CompanyProperties", + "description": "An instance of org.acme.hr@1.0.0.CompanyProperties", "type": "object", "propertyNames": { "type": "string" @@ -7395,97 +7499,63 @@ exports[`codegen #formats check we can convert all formats from namespace versio } } }, - "dictionary3": { - "$id": "org.acme.hr@1.0.0.Address.dictionary3", + "employeeDirectory": { + "$id": "org.acme.hr@1.0.0.Company.employeeDirectory", "schema": { - "title": "Map3", - "description": "An instance of org.acme.hr@1.0.0.Map3", + "title": "EmployeeDirectory", + "description": "An instance of org.acme.hr@1.0.0.EmployeeDirectory", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "SSN" + "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" } } }, - "dictionary4": { - "$id": "org.acme.hr@1.0.0.Address.dictionary4", + "employeeTShirtSizes": { + "$id": "org.acme.hr@1.0.0.Company.employeeTShirtSizes", "schema": { - "title": "Map4", - "description": "An instance of org.acme.hr@1.0.0.Map4", + "title": "EmployeeTShirtSizes", + "description": "An instance of org.acme.hr.base@1.0.0.EmployeeTShirtSizes", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr@1.0.0.TShirtSizeType" } } }, - "dictionary5": { - "$id": "org.acme.hr@1.0.0.Address.dictionary5", + "employeeProfiles": { + "$id": "org.acme.hr@1.0.0.Company.employeeProfiles", "schema": { - "title": "Map5", - "description": "An instance of org.acme.hr@1.0.0.Map5", + "title": "EmployeeProfiles", + "description": "An instance of org.acme.hr@1.0.0.EmployeeProfiles", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "string" + "type": "Concept" } } }, - "dictionary6": { - "$id": "org.acme.hr@1.0.0.Address.dictionary6", + "employeeSocialSecurityNumbers": { + "$id": "org.acme.hr@1.0.0.Company.employeeSocialSecurityNumbers", "schema": { - "title": "Map6", - "description": "An instance of org.acme.hr@1.0.0.Map6", + "title": "EmployeeSocialSecurityNumbers", + "description": "An instance of org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" + "type": "SSN" } } } }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country" - ] - }, - "org.acme.hr.base@1.0.0.Time": { - "format": "date-time", - "type": "string" - }, - "org.acme.hr.base@1.0.0.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "org.acme.hr@1.0.0.Company": { - "title": "Company", - "description": "An instance of org.acme.hr@1.0.0.Company", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Company", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Company$", - "description": "The class identifier for org.acme.hr@1.0.0.Company" - }, - "name": { - "type": "string" - }, - "headquarters": { - "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" - } - }, "required": [ "$class", "name", @@ -7599,6 +7669,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -7689,6 +7773,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -7755,6 +7853,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -7850,6 +7962,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -8585,26 +8711,46 @@ exports[`codegen #formats check we can convert all formats from namespace versio }, "country": { "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country" + ] + }, + "org.acme.hr.base@1.0.0.Time": { + "format": "date-time", + "type": "string" + }, + "org.acme.hr.base@1.0.0.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "org.acme.hr@1.0.0.Company": { + "title": "Company", + "description": "An instance of org.acme.hr@1.0.0.Company", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Company", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Company$", + "description": "The class identifier for org.acme.hr@1.0.0.Company" }, - "dictionary1": { - "$id": "org.acme.hr@1.0.0.Address.dictionary1", - "schema": { - "title": "Map1", - "description": "An instance of org.acme.hr@1.0.0.Map1", - "type": "object", - "propertyNames": { - "type": "string" - }, - "additionalProperties": { - "type": "string" - } - } + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, - "dictionary2": { - "$id": "org.acme.hr@1.0.0.Address.dictionary2", + "companyProperties": { + "$id": "org.acme.hr@1.0.0.Company.companyProperties", "schema": { - "title": "Map2", - "description": "An instance of org.acme.hr@1.0.0.Map2", + "title": "CompanyProperties", + "description": "An instance of org.acme.hr@1.0.0.CompanyProperties", "type": "object", "propertyNames": { "type": "string" @@ -8614,97 +8760,63 @@ exports[`codegen #formats check we can convert all formats from namespace versio } } }, - "dictionary3": { - "$id": "org.acme.hr@1.0.0.Address.dictionary3", + "employeeDirectory": { + "$id": "org.acme.hr@1.0.0.Company.employeeDirectory", "schema": { - "title": "Map3", - "description": "An instance of org.acme.hr@1.0.0.Map3", + "title": "EmployeeDirectory", + "description": "An instance of org.acme.hr@1.0.0.EmployeeDirectory", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "SSN" + "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" } } }, - "dictionary4": { - "$id": "org.acme.hr@1.0.0.Address.dictionary4", + "employeeTShirtSizes": { + "$id": "org.acme.hr@1.0.0.Company.employeeTShirtSizes", "schema": { - "title": "Map4", - "description": "An instance of org.acme.hr@1.0.0.Map4", + "title": "EmployeeTShirtSizes", + "description": "An instance of org.acme.hr.base@1.0.0.EmployeeTShirtSizes", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr@1.0.0.TShirtSizeType" } } }, - "dictionary5": { - "$id": "org.acme.hr@1.0.0.Address.dictionary5", + "employeeProfiles": { + "$id": "org.acme.hr@1.0.0.Company.employeeProfiles", "schema": { - "title": "Map5", - "description": "An instance of org.acme.hr@1.0.0.Map5", + "title": "EmployeeProfiles", + "description": "An instance of org.acme.hr@1.0.0.EmployeeProfiles", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "type": "string" + "type": "Concept" } } }, - "dictionary6": { - "$id": "org.acme.hr@1.0.0.Address.dictionary6", + "employeeSocialSecurityNumbers": { + "$id": "org.acme.hr@1.0.0.Company.employeeSocialSecurityNumbers", "schema": { - "title": "Map6", - "description": "An instance of org.acme.hr@1.0.0.Map6", + "title": "EmployeeSocialSecurityNumbers", + "description": "An instance of org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers", "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" + "type": "SSN" } } } }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country" - ] - }, - "org.acme.hr.base@1.0.0.Time": { - "format": "date-time", - "type": "string" - }, - "org.acme.hr.base@1.0.0.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "org.acme.hr@1.0.0.Company": { - "title": "Company", - "description": "An instance of org.acme.hr@1.0.0.Company", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Company", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Company$", - "description": "The class identifier for org.acme.hr@1.0.0.Company" - }, - "name": { - "type": "string" - }, - "headquarters": { - "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" - } - }, "required": [ "$class", "name", @@ -8818,6 +8930,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -8908,6 +9034,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -8974,6 +9114,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ @@ -9069,6 +9223,20 @@ exports[`codegen #formats check we can convert all formats from namespace versio "dob": { "format": "date-time", "type": "string" + }, + "nextOfKin": { + "$id": "org.acme.hr@1.0.0.Person.nextOfKin", + "schema": { + "title": "NextOfKin", + "description": "An instance of org.acme.hr@1.0.0.NextOfKin", + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "type": "KinTelephone" + } + } } }, "required": [ From 7331418b39a706cbb474546cd6a1e4b05f6150de Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 6 Nov 2023 11:34:26 +0000 Subject: [PATCH 12/17] feat(*): gets type from model file Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/jsonschema/jsonschemavisitor.js | 6 ++---- test/codegen/__snapshots__/codegen.js.snap | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js index 693ba8b7..c1b73139 100644 --- a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -411,9 +411,7 @@ class JSONSchemaVisitor { } else if (ModelUtil.isMap?.(field)) { const mapDeclaration = field.getParent().getModelFile().getModelManager().getType(field.getFullyQualifiedTypeName()); - let valueDeclaration = mapDeclaration.getModelFile() - .getAllDeclarations() - .find(decl => decl.name === mapDeclaration.getValue().getType()); + let valueDeclaration = mapDeclaration.getModelFile().getType(mapDeclaration.getValue().getType()); const jsonSchema = { $id: field.getFullyQualifiedName(), @@ -431,7 +429,7 @@ class JSONSchemaVisitor { }; // if its a ClassDeclaration, add reference to its schema. - if (valueDeclaration?.isClassDeclaration()) { + if (valueDeclaration?.isClassDeclaration?.()) { jsonSchema.schema.additionalProperties = {$ref: `#/definitions/${field.getParent().getModelFile().getNamespace().concat(`.${mapDeclaration.getValue().getType()}`)}`}; } diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 210dfb53..67cee6bc 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1737,7 +1737,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr.Concept" } } }, @@ -2982,7 +2982,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr.Concept" } } }, @@ -7537,7 +7537,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr@1.0.0.Concept" } } }, @@ -8798,7 +8798,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "additionalProperties": { - "type": "Concept" + "$ref": "#/definitions/org.acme.hr@1.0.0.Concept" } } }, From 5f410ab23ffcbc9552ca570fe7d22a3efec2b54a Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 6 Nov 2023 11:43:18 +0000 Subject: [PATCH 13/17] test(*): snapshot update Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 480 ++++++++++----------- 1 file changed, 240 insertions(+), 240 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 04ddf57c..67cee6bc 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -6,7 +6,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -39,7 +39,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -69,7 +69,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -106,7 +106,7 @@ protocol MyProtocol { import idl "org.acme.hr.base.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -494,7 +494,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -522,7 +522,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -549,7 +549,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package org_acme_hr_base contains domain objects and was generated from Concerto namespace org.acme.hr.base. package org_acme_hr_base import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -585,7 +585,7 @@ package org_acme_hr import "time" import "org_acme_hr_base"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -870,7 +870,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -909,7 +909,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -1164,7 +1164,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1219,7 +1219,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1258,7 +1258,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1353,7 +1353,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1441,7 +1441,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1487,7 +1487,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -4078,7 +4078,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -4108,7 +4108,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -4125,9 +4125,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -4142,7 +4142,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4155,7 +4155,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4168,7 +4168,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4183,7 +4183,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4201,9 +4201,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -4218,7 +4218,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4231,7 +4231,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4263,10 +4263,10 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr_base.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -4299,28 +4299,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -4336,52 +4336,52 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -4411,12 +4411,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4437,17 +4437,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4460,55 +4460,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4521,93 +4521,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4620,63 +4620,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4689,96 +4689,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4791,7 +4791,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4806,10 +4806,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4824,15 +4824,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4890,7 +4890,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -5068,7 +5068,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -5224,7 +5224,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto@1.0.0.xsd", "value": " - @@ -5280,7 +5280,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto.xsd", "value": " - @@ -5334,7 +5334,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.base.xsd", "value": " - @@ -5380,7 +5380,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.xsd", "value": " - @@ -5806,7 +5806,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -5839,7 +5839,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -5869,7 +5869,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -5906,7 +5906,7 @@ protocol MyProtocol { import idl "org.acme.hr.base@1.0.0.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -6294,7 +6294,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -6322,7 +6322,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -6349,7 +6349,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package org_acme_hr_base_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr.base@1.0.0. package org_acme_hr_base_1_0_0 import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -6385,7 +6385,7 @@ package org_acme_hr_1_0_0 import "time" import "org_acme_hr_base_1_0_0"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -6670,7 +6670,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6709,7 +6709,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6964,7 +6964,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -7019,7 +7019,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -7058,7 +7058,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7153,7 +7153,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7241,7 +7241,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7287,7 +7287,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -9910,7 +9910,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -9940,7 +9940,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -9957,9 +9957,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9974,7 +9974,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9987,7 +9987,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -10000,7 +10000,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10015,7 +10015,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10033,9 +10033,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -10050,7 +10050,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -10063,7 +10063,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -10095,10 +10095,10 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_base_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -10131,28 +10131,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -10168,52 +10168,52 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base_1_0_0::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -10243,12 +10243,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -10269,17 +10269,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -10292,55 +10292,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10353,93 +10353,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10452,63 +10452,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10521,96 +10521,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10623,7 +10623,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10638,10 +10638,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10656,15 +10656,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10722,7 +10722,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -10900,7 +10900,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -11056,7 +11056,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto@1.0.0.xsd", "value": " - @@ -11112,7 +11112,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto.xsd", "value": " - @@ -11166,7 +11166,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr.base@1.0.0.xsd", "value": " - @@ -11212,7 +11212,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr@1.0.0.xsd", "value": " - From a458152fd67b77596d45cfad341990f6a4b8f9c1 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 6 Nov 2023 15:12:40 +0000 Subject: [PATCH 14/17] feat(*): use scalar validator regex as pattern value Signed-off-by: Jonathan Casey --- .../fromcto/jsonschema/jsonschemavisitor.js | 14 ++++++-- test/codegen/__snapshots__/codegen.js.snap | 36 ++++++++++++------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js index c1b73139..71718733 100644 --- a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -411,7 +411,8 @@ class JSONSchemaVisitor { } else if (ModelUtil.isMap?.(field)) { const mapDeclaration = field.getParent().getModelFile().getModelManager().getType(field.getFullyQualifiedTypeName()); - let valueDeclaration = mapDeclaration.getModelFile().getType(mapDeclaration.getValue().getType()); + let mapKey = mapDeclaration.getModelFile().getType(mapDeclaration.getKey().getType()); + let mapValue = mapDeclaration.getModelFile().getType(mapDeclaration.getValue().getType()); const jsonSchema = { $id: field.getFullyQualifiedName(), @@ -428,8 +429,17 @@ class JSONSchemaVisitor { } }; + if (mapKey.isScalarDeclaration?.() && mapKey.getValidator()?.getRegex()) { + jsonSchema.schema.propertyNames.pattern = String(mapKey.getValidator().getRegex()); + + } + + if (mapValue.isScalarDeclaration?.() && mapValue.getValidator()?.getRegex()) { + jsonSchema.schema.additionalProperties.pattern = String(mapValue.getValidator().getRegex()); + } + // if its a ClassDeclaration, add reference to its schema. - if (valueDeclaration?.isClassDeclaration?.()) { + if (mapValue?.isClassDeclaration?.()) { jsonSchema.schema.additionalProperties = {$ref: `#/definitions/${field.getParent().getModelFile().getNamespace().concat(`.${mapDeclaration.getValue().getType()}`)}`}; } diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 67cee6bc..21d4bd1b 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1706,7 +1706,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "An instance of org.acme.hr.EmployeeDirectory", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr.Employee" @@ -1720,7 +1721,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "An instance of org.acme.hr.base.EmployeeTShirtSizes", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr.TShirtSizeType" @@ -1751,7 +1753,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "additionalProperties": { - "type": "SSN" + "type": "SSN", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" } } } @@ -2951,7 +2954,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "An instance of org.acme.hr.EmployeeDirectory", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr.Employee" @@ -2965,7 +2969,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "An instance of org.acme.hr.base.EmployeeTShirtSizes", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr.TShirtSizeType" @@ -2996,7 +3001,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "additionalProperties": { - "type": "SSN" + "type": "SSN", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" } } } @@ -7506,7 +7512,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "An instance of org.acme.hr@1.0.0.EmployeeDirectory", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" @@ -7520,7 +7527,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "An instance of org.acme.hr.base@1.0.0.EmployeeTShirtSizes", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr@1.0.0.TShirtSizeType" @@ -7551,7 +7559,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "additionalProperties": { - "type": "SSN" + "type": "SSN", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" } } } @@ -8767,7 +8776,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "An instance of org.acme.hr@1.0.0.EmployeeDirectory", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr@1.0.0.Employee" @@ -8781,7 +8791,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "An instance of org.acme.hr.base@1.0.0.EmployeeTShirtSizes", "type": "object", "propertyNames": { - "type": "string" + "type": "string", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" }, "additionalProperties": { "$ref": "#/definitions/org.acme.hr@1.0.0.TShirtSizeType" @@ -8812,7 +8823,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "additionalProperties": { - "type": "SSN" + "type": "SSN", + "pattern": "/\\\\d{3}-\\\\d{2}-\\\\{4}+/" } } } From d4e7b58894dada54e5001b527b4aa3b1c7c3b849 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 10 Nov 2023 15:34:16 +0000 Subject: [PATCH 15/17] test(*): add regex to property Signed-off-by: Jonathan Casey --- test/codegen/fromcto/data/model/hr.cto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/codegen/fromcto/data/model/hr.cto b/test/codegen/fromcto/data/model/hr.cto index cabf4d71..94e62483 100644 --- a/test/codegen/fromcto/data/model/hr.cto +++ b/test/codegen/fromcto/data/model/hr.cto @@ -33,7 +33,7 @@ map EmployeeDirectory { } concept Company { - o String name + o String name regex=/abc.*/ o Address headquarters o CompanyProperties companyProperties optional o EmployeeDirectory employeeDirectory optional From 2f5b9206afa8d350ba92b0f764e9f8bde2a718b8 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 10 Nov 2023 15:34:35 +0000 Subject: [PATCH 16/17] test(*): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index af92cbac..068de440 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -376,6 +376,7 @@ using AccordProject.Concerto; public class Company : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr.Company"; + [System.ComponentModel.DataAnnotations.RegularExpression(@"abc.*", ErrorMessage = "Invalid characters")] public string name { get; set; } public org.acme.hr.base.Address headquarters { get; set; } public Dictionary companyProperties { get; set; } @@ -1684,7 +1685,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "The class identifier for org.acme.hr.Company" }, "name": { - "type": "string" + "type": "string", + "pattern": "abc.*" }, "headquarters": { "$ref": "#/definitions/org.acme.hr.base.Address" @@ -2932,7 +2934,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "The class identifier for org.acme.hr.Company" }, "name": { - "type": "string" + "type": "string", + "pattern": "abc.*" }, "headquarters": { "$ref": "#/components/schemas/org.acme.hr.base.Address" @@ -6186,6 +6189,7 @@ using AccordProject.Concerto; public class Company : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr@1.0.0.Company"; + [System.ComponentModel.DataAnnotations.RegularExpression(@"abc.*", ErrorMessage = "Invalid characters")] public string name { get; set; } public org.acme.hr.base.Address headquarters { get; set; } public Dictionary companyProperties { get; set; } @@ -7494,7 +7498,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "The class identifier for org.acme.hr@1.0.0.Company" }, "name": { - "type": "string" + "type": "string", + "pattern": "abc.*" }, "headquarters": { "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" @@ -8758,7 +8763,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "The class identifier for org.acme.hr@1.0.0.Company" }, "name": { - "type": "string" + "type": "string", + "pattern": "abc.*" }, "headquarters": { "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" From f184fe386fc1c321342ca4aef1ca1a3a69471ba0 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 10 Nov 2023 15:44:35 +0000 Subject: [PATCH 17/17] test(*): update jsdoc and typedef Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/jsonschema/jsonschemavisitor.js | 2 +- types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js index 71718733..7ec27950 100644 --- a/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js +++ b/lib/codegen/fromcto/jsonschema/jsonschemavisitor.js @@ -60,7 +60,7 @@ class JSONSchemaVisitor { /** * Get the validators for a field or a scalar definition in JSON schema form. - * @param {Object} type - the scalar declaration being visited + * @param {String} type - the field type * @param {bool} [isScalarUUID] - flag to indicate given field type is scalar uuid * @param {bool} [validator] - the field validator * @return {Object} the result of visiting or null diff --git a/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts b/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts index ab763b43..d7b3b146 100644 --- a/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts +++ b/types/lib/codegen/fromcto/jsonschema/jsonschemavisitor.d.ts @@ -30,7 +30,7 @@ declare class JSONSchemaVisitor { getDecorators(decorated: object): object; /** * Get the validators for a field or a scalar definition in JSON schema form. - * @param {Object} type - the scalar declaration being visited + * @param {String} type - the field type * @param {bool} [isScalarUUID] - flag to indicate given field type is scalar uuid * @param {bool} [validator] - the field validator * @return {Object} the result of visiting or null