From 1200c2c56c257283150d32f7127b14d51b658cc2 Mon Sep 17 00:00:00 2001 From: Dan Selman Date: Tue, 6 Jun 2023 11:43:57 -0700 Subject: [PATCH] fix(typescript) do not create unions for enums and fix imports (#33) Signed-off-by: Dan Selman --- .../fromcto/typescript/typescriptvisitor.js | 4 +- test/codegen/__snapshots__/codegen.js.snap | 9168 ++++++++--------- 2 files changed, 4583 insertions(+), 4589 deletions(-) diff --git a/lib/codegen/fromcto/typescript/typescriptvisitor.js b/lib/codegen/fromcto/typescript/typescriptvisitor.js index 62cb63ae..ff9d1799 100644 --- a/lib/codegen/fromcto/typescript/typescriptvisitor.js +++ b/lib/codegen/fromcto/typescript/typescriptvisitor.js @@ -111,7 +111,7 @@ class TypescriptVisitor { if (!properties.has(typeNamespace)) { properties.set(typeNamespace, new Set()); } - properties.get(typeNamespace).add(`I${typeName}`); + properties.get(typeNamespace).add(property.isTypeEnum?.() ? typeName : `I${typeName}`); } }); @@ -208,7 +208,7 @@ class TypescriptVisitor { const subclasses = classDeclaration.getDirectSubclasses(); if (subclasses && subclasses.length > 0) { parameters.fileWriter.writeLine(0, 'export type ' + classDeclaration.getName() + - 'Union = ' + subclasses.map(subclass => `I${subclass.getName()}`).join(' | \n') + ';\n'); + 'Union = ' + subclasses.filter(declaration => !declaration.isEnum()).map(subclass => `I${subclass.getName()}`).join(' | \n') + ';\n'); } return null; } diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 97fbc49b..65f90b84 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -3377,3875 +3377,3337 @@ message ChangeOfAddress { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 1`] = ` { - "key": "concerto@1.0.0.ts", - "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: concerto@1.0.0 - -// imports - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IState, - IAddress, - ICompany, - IDepartment, - ILaptopMake -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IEquipment -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IPerson -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - IChangeOfAddress -} from './org.acme.hr'; - -// Warning: Beware of circular dependencies when modifying these imports -import type { - ICompanyEvent -} from './org.acme.hr'; - -// interfaces -export interface IConcept { - $class: string; + "key": "mod.rs", + "value": "#[allow(unused_imports)] +pub mod concerto_1_0_0; +#[allow(unused_imports)] +pub mod concerto; +#[allow(unused_imports)] +pub mod org_acme_hr; +#[allow(unused_imports)] +pub mod utils; +", } +`; -export type ConceptUnion = IState | -IAddress | -ICompany | -IDepartment | -ILaptopMake; - -export interface IAsset extends IConcept { - $identifier: string; +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 2`] = ` +{ + "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, +{ + match datetime { + Some(dt) => { + serialize_datetime(&dt, serializer) + }, + _ => unreachable!(), + } } -export type AssetUnion = IEquipment; - -export interface IParticipant extends IConcept { - $identifier: string; +pub fn deserialize_datetime_option<'de, D>(deserializer: D) -> Result>, D::Error> +where + D: Deserializer<'de>, +{ + match deserialize_datetime(deserializer) { + Ok(result)=>Ok(Some(result)), + Err(error) => Err(error), + } } -export type ParticipantUnion = IPerson; - -export interface ITransaction extends IConcept { - $timestamp: Date; +pub fn deserialize_datetime<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + 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) } - -export type TransactionUnion = IChangeOfAddress; - -export interface IEvent extends IConcept { - $timestamp: Date; + +pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result +where + S: Serializer, +{ + let datetime_str = datetime.format("%+").to_string(); + serializer.serialize_str(&datetime_str) } - -export type EventUnion = ICompanyEvent; - ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 2`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 3`] = ` { - "key": "concerto.ts", - "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: concerto - -// imports - -// interfaces -export interface IConcept { - $class: string; + "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( + rename = "$class", + )] + pub _class: String, } -export interface IAsset extends IConcept { - $identifier: string; +#[derive(Debug, Serialize, Deserialize)] +pub struct Asset { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, } -export interface IParticipant extends IConcept { - $identifier: string; +#[derive(Debug, Serialize, Deserialize)] +pub struct Participant { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, } -export interface ITransaction extends IConcept { +#[derive(Debug, Serialize, Deserialize)] +pub struct Transaction { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, } -export interface IEvent extends IConcept { +#[derive(Debug, Serialize, Deserialize)] +pub struct Event { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 3`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 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 {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; - -// interfaces -export enum State { - MA = 'MA', - NY = 'NY', - CO = 'CO', - WA = 'WA', - IL = 'IL', - CA = 'CA', + "key": "concerto.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Concept { + #[serde( + rename = "$class", + )] + pub _class: String, } -export interface IAddress extends IConcept { - street: string; - city: string; - state?: State; - zipCode: string; - country: string; +#[derive(Debug, Serialize, Deserialize)] +pub struct Asset { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, } -export interface ICompany extends IConcept { - name: string; - headquarters: IAddress; +#[derive(Debug, Serialize, Deserialize)] +pub struct Participant { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, } -export enum Department { - Sales = 'Sales', - Marketing = 'Marketing', - Finance = 'Finance', - HR = 'HR', - Engineering = 'Engineering', - Design = 'Design', -} - -export interface IEquipment extends IAsset { - serialNumber: string; +#[derive(Debug, Serialize, Deserialize)] +pub struct Transaction { + #[serde( + rename = "$class", + )] + pub _class: String, } -export type EquipmentUnion = ILaptop; - -export enum LaptopMake { - Apple = 'Apple', - Microsoft = 'Microsoft', +#[derive(Debug, Serialize, Deserialize)] +pub struct Event { + #[serde( + rename = "$class", + )] + pub _class: String, } -export interface ILaptop extends IEquipment { - make: LaptopMake; +", } +`; -export interface IPerson extends IParticipant { - email: string; - firstName: string; - lastName: string; - middleNames?: string; - homeAddress: IAddress; - ssn: string; - height: number; - dob: Date; +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 5`] = ` +{ + "key": "org_acme_hr.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)] + MA, + #[allow(non_camel_case_types)] + NY, + #[allow(non_camel_case_types)] + CO, + #[allow(non_camel_case_types)] + WA, + #[allow(non_camel_case_types)] + IL, + #[allow(non_camel_case_types)] + CA, } -export type PersonUnion = IEmployee | -IContractor; - -export interface IEmployee extends IPerson { - employeeId: string; - salary: number; - numDependents: number; - retired: boolean; - department: Department; - officeAddress: IAddress; - companyAssets: IEquipment[]; - manager?: IManager; +#[derive(Debug, Serialize, Deserialize)] +pub struct Address { + #[serde( + 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", + )] + pub country: String, } -export type EmployeeUnion = IManager; - -export interface IContractor extends IPerson { - company: ICompany; - manager?: IManager; +#[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, } -export interface IManager extends IEmployee { - reports?: IPerson[]; +#[derive(Debug, Serialize, Deserialize)] +pub enum Department { + #[allow(non_camel_case_types)] + Sales, + #[allow(non_camel_case_types)] + Marketing, + #[allow(non_camel_case_types)] + Finance, + #[allow(non_camel_case_types)] + HR, + #[allow(non_camel_case_types)] + Engineering, + #[allow(non_camel_case_types)] + Design, } -export interface ICompanyEvent extends IEvent { +#[derive(Debug, Serialize, Deserialize)] +pub struct Equipment { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "serialNumber", + )] + pub serial_number: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, } -export type CompanyEventUnion = IOnboarded; - -export interface IOnboarded extends ICompanyEvent { - employee: IEmployee; +#[derive(Debug, Serialize, Deserialize)] +pub enum LaptopMake { + #[allow(non_camel_case_types)] + Apple, + #[allow(non_camel_case_types)] + Microsoft, } -export interface IChangeOfAddress extends ITransaction { - Person: IPerson; - newAddress: IAddress; +#[derive(Debug, Serialize, Deserialize)] +pub struct Laptop { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "make", + )] + pub make: LaptopMake, + + #[serde( + rename = "serialNumber", + )] + pub serial_number: String, + + #[serde( + rename = "$identifier", + )] + pub _identifier: String, } -", +#[derive(Debug, Serialize, Deserialize)] +pub struct Person { + #[serde( + 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 = "$identifier", + )] + pub _identifier: String, } -`; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 1`] = ` -{ - "key": "concerto@1.0.0.xsd", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", +#[derive(Debug, Serialize, Deserialize)] +pub struct Employee { + #[serde( + 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 = "$identifier", + )] + pub _identifier: String, } -`; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 2`] = ` -{ - "key": "concerto.xsd", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", +#[derive(Debug, Serialize, Deserialize)] +pub struct Contractor { + #[serde( + 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 = "$identifier", + )] + pub _identifier: String, } -`; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 3`] = ` -{ - "key": "org.acme.hr.xsd", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'mermaid' 1`] = ` -{ - "key": "model.mmd", - "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { -<< enumeration>> - + \`MA\` - + \`NY\` - + \`CO\` - + \`WA\` - + \`IL\` - + \`CA\` -} - -class \`org.acme.hr@1.0.0.Address\` { -<< concept>> - + \`String\` \`street\` - + \`String\` \`city\` - + \`State\` \`state\` - + \`String\` \`zipCode\` - + \`String\` \`country\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@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\` -class \`org.acme.hr@1.0.0.Department\` { -<< enumeration>> - + \`Sales\` - + \`Marketing\` - + \`Finance\` - + \`HR\` - + \`Engineering\` - + \`Design\` -} - -class \`org.acme.hr@1.0.0.Equipment\` { -<< asset>> - + \`String\` \`serialNumber\` -} - -class \`org.acme.hr@1.0.0.LaptopMake\` { -<< enumeration>> - + \`Apple\` - + \`Microsoft\` -} - -class \`org.acme.hr@1.0.0.Laptop\` { -<< asset>> - + \`LaptopMake\` \`make\` -} - -\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` -\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` -class \`org.acme.hr@1.0.0.Person\` { -<< participant>> - + \`String\` \`email\` - + \`String\` \`firstName\` - + \`String\` \`lastName\` - + \`String\` \`middleNames\` - + \`Address\` \`homeAddress\` - + \`String\` \`ssn\` - + \`Double\` \`height\` - + \`DateTime\` \`dob\` -} - -\`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\` -class \`org.acme.hr@1.0.0.Employee\` { -<< participant>> - + \`String\` \`employeeId\` - + \`Long\` \`salary\` - + \`Integer\` \`numDependents\` - + \`Boolean\` \`retired\` - + \`Department\` \`department\` - + \`Address\` \`officeAddress\` - + \`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\` "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" *-- "*" \`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\` -class \`org.acme.hr@1.0.0.Contractor\` { -<< participant>> - + \`Company\` \`company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -} - -\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` -class \`org.acme.hr@1.0.0.Manager\` { -<< participant>> -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports -} - -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports -\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` -class \`org.acme.hr@1.0.0.CompanyEvent\` -<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` - -class \`org.acme.hr@1.0.0.Onboarded\` { -<< event>> -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee -} - -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee -\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` -class \`org.acme.hr@1.0.0.ChangeOfAddress\` { -<< transaction>> -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person - + \`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\` -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'plantuml' 1`] = ` -{ - "key": "model.puml", - "value": "@startuml -title -Model -endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { - + MA - + NY - + CO - + WA - + IL - + CA -} -class org.acme.hr_1_0_0.Address { - + String street - + String city - + State state - + String zipCode - + String country -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_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 -class org.acme.hr_1_0_0.Department << (E,grey) >> { - + Sales - + Marketing - + Finance - + HR - + Engineering - + Design -} -class org.acme.hr_1_0_0.Equipment << (A,green) >> { - + String serialNumber -} -class org.acme.hr_1_0_0.LaptopMake << (E,grey) >> { - + Apple - + Microsoft -} -class org.acme.hr_1_0_0.Laptop << (A,green) >> { - + LaptopMake make -} -org.acme.hr_1_0_0.Laptop "1" *-- "1" org.acme.hr_1_0_0.LaptopMake : make -org.acme.hr_1_0_0.Laptop --|> org.acme.hr_1_0_0.Equipment -class org.acme.hr_1_0_0.Person << (P,lightblue) >> { - + String email - + String firstName - + String lastName - + String middleNames - + Address homeAddress - + String ssn - + Double height - + DateTime dob -} -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 -class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { - + String employeeId - + Long salary - + Integer numDependents - + Boolean retired - + Department department - + Address officeAddress - + Equipment[] companyAssets - + 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" *-- "*" 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 -class org.acme.hr_1_0_0.Contractor << (P,lightblue) >> { - + Company company - + Manager manager -} -org.acme.hr_1_0_0.Contractor "1" *-- "1" org.acme.hr_1_0_0.Company : company -org.acme.hr_1_0_0.Contractor "1" o-- "1" org.acme.hr_1_0_0.Manager : manager -org.acme.hr_1_0_0.Contractor --|> org.acme.hr_1_0_0.Person -class org.acme.hr_1_0_0.Manager << (P,lightblue) >> { - + Person[] reports -} -org.acme.hr_1_0_0.Manager "1" o-- "*" org.acme.hr_1_0_0.Person : reports -org.acme.hr_1_0_0.Manager --|> org.acme.hr_1_0_0.Employee -class org.acme.hr_1_0_0.CompanyEvent { -} -class org.acme.hr_1_0_0.Onboarded { - + Employee employee -} -org.acme.hr_1_0_0.Onboarded "1" o-- "1" org.acme.hr_1_0_0.Employee : employee -org.acme.hr_1_0_0.Onboarded --|> org.acme.hr_1_0_0.CompanyEvent -class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { - + Person Person - + 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 -@enduml -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 1`] = ` -{ - "key": "concerto@1.0.0.avdl", - "value": "@namespace("concerto@1.0.0") -protocol MyProtocol { - - - record Concept { - } - - record Asset { - string _identifier; - } - - record Participant { - string _identifier; - } - - record Transaction { - @logicalType("timestamp-micros") - long _timestamp; - } - - record Event { - @logicalType("timestamp-micros") - long _timestamp; - } - -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 2`] = ` -{ - "key": "concerto.avdl", - "value": "@namespace("concerto") -protocol MyProtocol { - - - record Concept { - } - - record Asset { - string _identifier; - } - - record Participant { - string _identifier; - } - - record Transaction { - } - - record Event { - } - -} -", -} -`; - -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") -protocol MyProtocol { - - import idl "concerto@1.0.0.avdl"; - - enum State { - MA, - NY, - CO, - WA, - IL, - CA - } - - record Address { - string street; - string city; - union { null, State } state; - string zipCode; - string country; - } - - record Company { - string name; - Address headquarters; - } - - enum Department { - Sales, - Marketing, - Finance, - HR, - Engineering, - Design - } - - record Equipment { - string serialNumber; - } - - enum LaptopMake { - Apple, - Microsoft - } - - record Laptop { - LaptopMake make; - string serialNumber; - } - - record Person { - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record Employee { - string employeeId; - long salary; - int numDependents; - boolean retired; - Department department; - Address officeAddress; - array companyAssets; - union { null, string } manager; - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record Contractor { - Company company; - union { null, string } manager; - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record Manager { - union { null, array } reports; - string employeeId; - long salary; - int numDependents; - boolean retired; - Department department; - Address officeAddress; - array companyAssets; - union { null, string } manager; - string email; - string firstName; - string lastName; - union { null, string } middleNames; - Address homeAddress; - string ssn; - double height; - @logicalType("timestamp-micros") - long dob; - } - - record CompanyEvent { - @logicalType("timestamp-micros") - long _timestamp; - } - - record Onboarded { - string employee; - @logicalType("timestamp-micros") - long _timestamp; - } - - record ChangeOfAddress { - string Person; - Address newAddress; - @logicalType("timestamp-micros") - long _timestamp; - } - -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 1`] = ` -{ - "key": "concerto@1.0.0.cs", - "value": "namespace AccordProject.Concerto; -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Concept")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public virtual string _class { get; } = "concerto@1.0.0.Concept"; -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Asset")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Asset : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Asset"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Participant")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Participant : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Participant"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Transaction")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Transaction : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Transaction"; - [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] - public System.DateTime _timestamp { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Event")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Event : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto@1.0.0.Event"; - [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] - public System.DateTime _timestamp { get; set; } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 2`] = ` -{ - "key": "concerto.cs", - "value": "namespace AccordProject.Concerto; -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Concept")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public virtual string _class { get; } = "concerto.Concept"; -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Asset")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Asset : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Asset"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Participant")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Participant : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Participant"; - [AccordProject.Concerto.Identifier()] - [System.Text.Json.Serialization.JsonPropertyName("$identifier")] - public string _identifier { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Transaction")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Transaction : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Transaction"; -} -[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Event")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Event : Concept { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "concerto.Event"; -} -", -} -`; - -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; -using AccordProject.Concerto; -[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] -public enum State { - MA, - NY, - CO, - WA, - IL, - CA, -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", 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 string street { get; set; } - public string city { get; set; } - public State? state { get; set; } - public string zipCode { get; set; } - public string country { get; set; } -} -[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; } -} -[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] -public enum Department { - Sales, - Marketing, - Finance, - HR, - Engineering, - Design, -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Equipment")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public abstract class Equipment : Asset { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Equipment"; - [AccordProject.Concerto.Identifier()] - public string serialNumber { get; set; } -} -[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] -public enum LaptopMake { - Apple, - Microsoft, -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Laptop")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Laptop : Equipment { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - 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 { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Person"; - [AccordProject.Concerto.Identifier()] - public string email { get; set; } - public string firstName { get; set; } - public string lastName { get; set; } - public string? middleNames { get; set; } - public 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; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Employee")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Employee : Person { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Employee"; - public string employeeId { get; set; } - public long salary { get; set; } - public int numDependents { get; set; } - public bool retired { get; set; } - public Department department { get; set; } - public Address officeAddress { get; set; } - public Equipment[] companyAssets { get; set; } - public Manager manager { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Contractor")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Contractor : Person { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Contractor"; - public Company company { get; set; } - public Manager manager { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Manager")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Manager : Employee { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Manager"; - public Person[] reports { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "CompanyEvent")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class CompanyEvent : Event { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.CompanyEvent"; -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Onboarded")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -public class Onboarded : CompanyEvent { - [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Onboarded"; - public Employee employee { get; set; } -} -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "ChangeOfAddress")] -[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] -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; } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 1`] = ` -{ - "key": "concerto@1.0.0.go", - "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 { - Concept - Identifier string \`json:"$identifier"\` -} -type Participant struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Transaction struct { - Concept - Timestamp time.Time \`json:"$timestamp"\` -} -type Event struct { - Concept - Timestamp time.Time \`json:"$timestamp"\` -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 2`] = ` -{ - "key": "concerto.go", - "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. -package concerto - -type Concept struct { -} -type Asset struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Participant struct { - Concept - Identifier string \`json:"$identifier"\` -} -type Transaction struct { - Concept -} -type Event struct { - Concept -} -", -} -`; - -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" -import "concerto_1_0_0"; - -type State int -const ( - MA State = 1 + iota - NY - CO - WA - IL - CA -) -type Address struct { - concerto_1_0_0.Concept - Street string \`json:"street"\` - City string \`json:"city"\` - State State \`json:"state"\` - ZipCode string \`json:"zipCode"\` - Country string \`json:"country"\` -} -type Company struct { - concerto_1_0_0.Concept - Name string \`json:"name"\` - Headquarters Address \`json:"headquarters"\` -} -type Department int -const ( - Sales Department = 1 + iota - Marketing - Finance - HR - Engineering - Design -) -type Equipment struct { - concerto_1_0_0.Asset - SerialNumber string \`json:"serialNumber"\` -} -type LaptopMake int -const ( - Apple LaptopMake = 1 + iota - Microsoft -) -type Laptop struct { - Equipment - Make LaptopMake \`json:"make"\` -} -type Person struct { - concerto_1_0_0.Participant - Email string \`json:"email"\` - FirstName string \`json:"firstName"\` - LastName string \`json:"lastName"\` - MiddleNames string \`json:"middleNames"\` - HomeAddress Address \`json:"homeAddress"\` - Ssn string \`json:"ssn"\` - Height float64 \`json:"height"\` - Dob time.Time \`json:"dob"\` -} -type Employee struct { - Person - EmployeeId string \`json:"employeeId"\` - Salary int64 \`json:"salary"\` - NumDependents int32 \`json:"numDependents"\` - Retired bool \`json:"retired"\` - Department Department \`json:"department"\` - OfficeAddress Address \`json:"officeAddress"\` - CompanyAssets []Equipment \`json:"companyAssets"\` - Manager *Manager \`json:"manager"\` -} -type Contractor struct { - Person - Company Company \`json:"company"\` - Manager *Manager \`json:"manager"\` -} -type Manager struct { - Employee - Reports []*Person \`json:"reports"\` -} -type CompanyEvent struct { - concerto_1_0_0.Event -} -type Onboarded struct { - CompanyEvent - Employee *Employee \`json:"employee"\` -} -type ChangeOfAddress struct { - concerto_1_0_0.Transaction - Person *Person \`json:"Person"\` - NewAddress Address \`json:"newAddress"\` -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'graphql' 1`] = ` -{ - "key": "model.gql", - "value": "directive @resource on OBJECT | FIELD_DEFINITION -scalar DateTime -# namespace org.acme.hr@1.0.0 -enum State { - MA - NY - CO - WA - IL - CA -} -type Address { - street: String! - city: String! - state: State - zipCode: String! - country: String! -} -type Company { - name: String! - headquarters: Address! -} -enum Department { - Sales - Marketing - Finance - HR - Engineering - Design -} -type Equipment @resource { - serialNumber: String! - _identifier: String! -} -enum LaptopMake { - Apple - Microsoft -} -type Laptop { - make: LaptopMake! - serialNumber: String! - _identifier: String! -} -type Person @resource { - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type Employee { - employeeId: String! - salary: Int! - numDependents: Int! - retired: Boolean! - department: Department! - officeAddress: Address! - companyAssets: [Equipment]! - manager: ID # Manager - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type Contractor { - company: Company! - manager: ID # Manager - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type Manager { - reports: [ID] # Person - employeeId: String! - salary: Int! - numDependents: Int! - retired: Boolean! - department: Department! - officeAddress: Address! - companyAssets: [Equipment]! - manager: ID # Manager - email: String! - firstName: String! - lastName: String! - middleNames: String - homeAddress: Address! - ssn: String! - height: Float! - dob: DateTime! - _identifier: String! -} -type CompanyEvent { - _timestamp: DateTime! -} -type Onboarded { - employee: ID! # Employee - _timestamp: DateTime! -} -type ChangeOfAddress { - Person: ID! # Person - newAddress: Address! - _timestamp: DateTime! -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 1`] = ` -{ - "key": "concerto/Concept.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public abstract class Concept { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 2`] = ` -{ - "key": "concerto/Asset.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") -public abstract class Asset extends Concept { - private String $id; - @JsonProperty("$id") - public String get$id() { - return $id; - } - @JsonProperty("$id") - public void set$id(String i) { - $id = i; - } - - // the accessor for the identifying field - public String getID() { - return this.get$identifier(); - } - - private String $identifier; - public String get$identifier() { - return this.$identifier; - } - public void set$identifier(String $identifier) { - this.$identifier = $identifier; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 3`] = ` -{ - "key": "concerto/Participant.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -@JsonIgnoreProperties({"id"}) -@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") -public abstract class Participant extends Concept { - private String $id; - @JsonProperty("$id") - public String get$id() { - return $id; - } - @JsonProperty("$id") - public void set$id(String i) { - $id = i; - } - - // the accessor for the identifying field - public String getID() { - return this.get$identifier(); - } - - private String $identifier; - public String get$identifier() { - return this.$identifier; - } - public void set$identifier(String $identifier) { - this.$identifier = $identifier; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 4`] = ` -{ - "key": "concerto/Transaction.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public abstract class Transaction extends Concept { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 5`] = ` -{ - "key": "concerto/Event.java", - "value": "// this code is generated and should not be modified -package concerto; - -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -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", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import com.fasterxml.jackson.annotation.*; -@JsonIgnoreProperties({"$class"}) -public enum State { - MA, - NY, - CO, - WA, - IL, - CA, -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 7`] = ` -{ - "key": "org/acme/hr/Address.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public class Address extends Concept { - private String street; - private String city; - private State state; - private String zipCode; - private String country; - public String getStreet() { - return this.street; - } - public String getCity() { - return this.city; - } - public State getState() { - return this.state; - } - public String getZipCode() { - return this.zipCode; - } - public String getCountry() { - return this.country; - } - public void setStreet(String street) { - this.street = street; - } - public void setCity(String city) { - this.city = city; - } - public void setState(State state) { - this.state = state; - } - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - public void setCountry(String country) { - this.country = country; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 8`] = ` -{ - "key": "org/acme/hr/Company.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") -public class Company extends Concept { - private String name; - private Address headquarters; - public String getName() { - return this.name; - } - public Address getHeadquarters() { - return this.headquarters; - } - public void setName(String name) { - this.name = name; - } - public void setHeadquarters(Address headquarters) { - this.headquarters = headquarters; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 9`] = ` -{ - "key": "org/acme/hr/Department.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import com.fasterxml.jackson.annotation.*; -@JsonIgnoreProperties({"$class"}) -public enum Department { - Sales, - Marketing, - Finance, - HR, - Engineering, - Design, -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 10`] = ` -{ - "key": "org/acme/hr/Equipment.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -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(); - } - - private String serialNumber; - public String getSerialNumber() { - return this.serialNumber; - } - public void setSerialNumber(String serialNumber) { - this.serialNumber = serialNumber; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 11`] = ` -{ - "key": "org/acme/hr/LaptopMake.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import com.fasterxml.jackson.annotation.*; -@JsonIgnoreProperties({"$class"}) -public enum LaptopMake { - Apple, - Microsoft, -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 12`] = ` -{ - "key": "org/acme/hr/Laptop.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -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(); - } - - private LaptopMake make; - public LaptopMake getMake() { - return this.make; - } - public void setMake(LaptopMake make) { - this.make = make; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 13`] = ` -{ - "key": "org/acme/hr/Person.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -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(); - } - - private String email; - private String firstName; - private String lastName; - private String middleNames; - private Address homeAddress; - private String ssn; - private double height; - private java.util.Date dob; - public String getEmail() { - return this.email; - } - public String getFirstName() { - return this.firstName; - } - public String getLastName() { - return this.lastName; - } - public String getMiddleNames() { - return this.middleNames; - } - public Address getHomeAddress() { - return this.homeAddress; - } - public String getSsn() { - return this.ssn; - } - public double getHeight() { - return this.height; - } - public java.util.Date getDob() { - return this.dob; - } - public void setEmail(String email) { - this.email = email; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - public void setMiddleNames(String middleNames) { - this.middleNames = middleNames; - } - public void setHomeAddress(Address homeAddress) { - this.homeAddress = homeAddress; - } - public void setSsn(String ssn) { - this.ssn = ssn; - } - public void setHeight(double height) { - this.height = height; - } - public void setDob(java.util.Date dob) { - this.dob = dob; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 14`] = ` -{ - "key": "org/acme/hr/Employee.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -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(); - } - - private String employeeId; - private long salary; - private int numDependents; - private boolean retired; - private Department department; - private Address officeAddress; - private Equipment[] companyAssets; - private Manager manager; - public String getEmployeeId() { - return this.employeeId; - } - public long getSalary() { - return this.salary; - } - public int getNumDependents() { - return this.numDependents; - } - public boolean getRetired() { - return this.retired; - } - public Department getDepartment() { - return this.department; - } - public Address getOfficeAddress() { - return this.officeAddress; - } - public Equipment[] getCompanyAssets() { - return this.companyAssets; - } - public Manager getManager() { - return this.manager; - } - public void setEmployeeId(String employeeId) { - this.employeeId = employeeId; - } - public void setSalary(long salary) { - this.salary = salary; - } - public void setNumDependents(int numDependents) { - this.numDependents = numDependents; - } - public void setRetired(boolean retired) { - this.retired = retired; - } - public void setDepartment(Department department) { - this.department = department; - } - public void setOfficeAddress(Address officeAddress) { - this.officeAddress = officeAddress; - } - public void setCompanyAssets(Equipment[] companyAssets) { - this.companyAssets = companyAssets; - } - public void setManager(Manager manager) { - this.manager = manager; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 15`] = ` -{ - "key": "org/acme/hr/Contractor.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -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(); - } - - private Company company; - private Manager manager; - public Company getCompany() { - return this.company; - } - public Manager getManager() { - return this.manager; - } - public void setCompany(Company company) { - this.company = company; - } - public void setManager(Manager manager) { - this.manager = manager; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 16`] = ` -{ - "key": "org/acme/hr/Manager.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -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(); - } - - private Person[] reports; - public Person[] getReports() { - return this.reports; - } - public void setReports(Person[] reports) { - this.reports = reports; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 17`] = ` -{ - "key": "org/acme/hr/CompanyEvent.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -public class CompanyEvent extends Event { -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 18`] = ` -{ - "key": "org/acme/hr/Onboarded.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -public class Onboarded extends CompanyEvent { - private Employee employee; - public Employee getEmployee() { - return this.employee; - } - public void setEmployee(Employee employee) { - this.employee = employee; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 19`] = ` -{ - "key": "org/acme/hr/ChangeOfAddress.java", - "value": "// this code is generated and should not be modified -package org.acme.hr; - -import concerto.Concept; -import concerto.Asset; -import concerto.Transaction; -import concerto.Participant; -import concerto.Event; -import com.fasterxml.jackson.annotation.*; - -public class ChangeOfAddress extends Transaction { - private Person Person; - private Address newAddress; - public Person getPerson() { - return this.Person; - } - public Address getNewAddress() { - return this.newAddress; - } - public void setPerson(Person Person) { - this.Person = Person; - } - public void setNewAddress(Address newAddress) { - this.newAddress = newAddress; - } -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'jsonschema' 1`] = ` -{ - "key": "schema.json", - "value": "{ - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "org.acme.hr@1.0.0.State": { - "title": "State", - "description": "An instance of org.acme.hr@1.0.0.State", - "enum": [ - "MA", - "NY", - "CO", - "WA", - "IL", - "CA" - ] - }, - "org.acme.hr@1.0.0.Address": { - "title": "Address", - "description": "An instance of org.acme.hr@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" - }, - "street": { - "type": "string" - }, - "city": { - "type": "string" - }, - "state": { - "$ref": "#/definitions/org.acme.hr@1.0.0.State" - }, - "zipCode": { - "type": "string" - }, - "country": { - "type": "string" - } - }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country" - ] - }, - "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@1.0.0.Address" - } - }, - "required": [ - "$class", - "name", - "headquarters" - ] - }, - "org.acme.hr@1.0.0.Department": { - "title": "Department", - "description": "An instance of org.acme.hr@1.0.0.Department", - "enum": [ - "Sales", - "Marketing", - "Finance", - "HR", - "Engineering", - "Design" - ] - }, - "org.acme.hr@1.0.0.Equipment": { - "title": "Equipment", - "description": "An instance of org.acme.hr@1.0.0.Equipment", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Equipment", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Equipment$", - "description": "The class identifier for org.acme.hr@1.0.0.Equipment" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "serialNumber" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr@1.0.0.LaptopMake": { - "title": "LaptopMake", - "description": "An instance of org.acme.hr@1.0.0.LaptopMake", - "enum": [ - "Apple", - "Microsoft" - ] - }, - "org.acme.hr@1.0.0.Laptop": { - "title": "Laptop", - "description": "An instance of org.acme.hr@1.0.0.Laptop", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Laptop", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Laptop$", - "description": "The class identifier for org.acme.hr@1.0.0.Laptop" - }, - "make": { - "$ref": "#/definitions/org.acme.hr@1.0.0.LaptopMake" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "make", - "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", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Person", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Person$", - "description": "The class identifier for org.acme.hr@1.0.0.Person" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr@1.0.0.Employee": { - "title": "Employee", - "description": "An instance of org.acme.hr@1.0.0.Employee", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Employee", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Employee$", - "description": "The class identifier for org.acme.hr@1.0.0.Employee" - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Department" - }, - "officeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/org.acme.hr@1.0.0.Equipment" - }, - { - "$ref": "#/definitions/org.acme.hr@1.0.0.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr@1.0.0.Contractor": { - "title": "Contractor", - "description": "An instance of org.acme.hr@1.0.0.Contractor", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Contractor", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Contractor$", - "description": "The class identifier for org.acme.hr@1.0.0.Contractor" - }, - "company": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Company" - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "company", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr@1.0.0.Manager": { - "title": "Manager", - "description": "An instance of org.acme.hr@1.0.0.Manager", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Manager", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Manager$", - "description": "The class identifier for org.acme.hr@1.0.0.Manager" - }, - "reports": { - "type": "array", - "items": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" - } - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Department" - }, - "officeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/org.acme.hr@1.0.0.Equipment" - }, - { - "$ref": "#/definitions/org.acme.hr@1.0.0.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } - }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] - }, - "org.acme.hr@1.0.0.CompanyEvent": { - "title": "CompanyEvent", - "description": "An instance of org.acme.hr@1.0.0.CompanyEvent", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.CompanyEvent", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.CompanyEvent$", - "description": "The class identifier for org.acme.hr@1.0.0.CompanyEvent" - } - }, - "required": [ - "$class" - ] - }, - "org.acme.hr@1.0.0.Onboarded": { - "title": "Onboarded", - "description": "An instance of org.acme.hr@1.0.0.Onboarded", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Onboarded", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Onboarded$", - "description": "The class identifier for org.acme.hr@1.0.0.Onboarded" - }, - "employee": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Employee" - } - }, - "required": [ - "$class", - "employee" - ] - }, - "org.acme.hr@1.0.0.ChangeOfAddress": { - "title": "ChangeOfAddress", - "description": "An instance of org.acme.hr@1.0.0.ChangeOfAddress", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.ChangeOfAddress", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.ChangeOfAddress$", - "description": "The class identifier for org.acme.hr@1.0.0.ChangeOfAddress" - }, - "Person": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" - }, - "newAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" - } - }, - "required": [ - "$class", - "Person", - "newAddress" - ] - } - } +#[derive(Debug, Serialize, Deserialize)] +pub struct Manager { + #[serde( + 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 = "$identifier", + )] + pub _identifier: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct CompanyEvent { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Onboarded { + #[serde( + rename = "$class", + )] + pub _class: String, + + #[serde(rename = "employee")] + pub employee: Employee, + + #[serde( + rename = "$timestamp", + serialize_with = "serialize_datetime", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct ChangeOfAddress { + #[serde( + 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", + deserialize_with = "deserialize_datetime", + )] + pub _timestamp: DateTime, +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 1`] = ` +{ + "key": "concerto@1.0.0.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: concerto@1.0.0 + +// imports + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IState, + IAddress, + ICompany, + IDepartment, + ILaptopMake +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IEquipment +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IPerson +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + IChangeOfAddress +} from './org.acme.hr'; + +// Warning: Beware of circular dependencies when modifying these imports +import type { + ICompanyEvent +} from './org.acme.hr'; + +// interfaces +export interface IConcept { + $class: string; +} + +export type ConceptUnion = IAddress | +ICompany; + +export interface IAsset extends IConcept { + $identifier: string; +} + +export type AssetUnion = IEquipment; + +export interface IParticipant extends IConcept { + $identifier: string; +} + +export type ParticipantUnion = IPerson; + +export interface ITransaction extends IConcept { + $timestamp: Date; +} + +export type TransactionUnion = IChangeOfAddress; + +export interface IEvent extends IConcept { + $timestamp: Date; +} + +export type EventUnion = ICompanyEvent; + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 2`] = ` +{ + "key": "concerto.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: concerto + +// imports + +// interfaces +export interface IConcept { + $class: string; +} + +export interface IAsset extends IConcept { + $identifier: string; +} + +export interface IParticipant extends IConcept { + $identifier: string; +} + +export interface ITransaction extends IConcept { +} + +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", + "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 {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; + +// interfaces +export enum State { + MA = 'MA', + NY = 'NY', + CO = 'CO', + WA = 'WA', + IL = 'IL', + CA = 'CA', +} + +export interface IAddress extends IConcept { + street: string; + city: string; + state?: State; + zipCode: string; + country: string; +} + +export interface ICompany extends IConcept { + name: string; + headquarters: IAddress; +} + +export enum Department { + Sales = 'Sales', + Marketing = 'Marketing', + Finance = 'Finance', + HR = 'HR', + Engineering = 'Engineering', + Design = 'Design', +} + +export interface IEquipment extends IAsset { + serialNumber: string; +} + +export type EquipmentUnion = ILaptop; + +export enum LaptopMake { + Apple = 'Apple', + Microsoft = 'Microsoft', +} + +export interface ILaptop extends IEquipment { + make: LaptopMake; +} + +export interface IPerson extends IParticipant { + email: string; + firstName: string; + lastName: string; + middleNames?: string; + homeAddress: IAddress; + ssn: string; + height: number; + dob: Date; +} + +export type PersonUnion = IEmployee | +IContractor; + +export interface IEmployee extends IPerson { + employeeId: string; + salary: number; + numDependents: number; + retired: boolean; + department: Department; + officeAddress: IAddress; + companyAssets: IEquipment[]; + manager?: IManager; +} + +export type EmployeeUnion = IManager; + +export interface IContractor extends IPerson { + company: ICompany; + manager?: IManager; +} + +export interface IManager extends IEmployee { + reports?: IPerson[]; +} + +export interface ICompanyEvent extends IEvent { +} + +export type CompanyEventUnion = IOnboarded; + +export interface IOnboarded extends ICompanyEvent { + employee: IEmployee; +} + +export interface IChangeOfAddress extends ITransaction { + Person: IPerson; + newAddress: IAddress; +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 1`] = ` +{ + "key": "concerto@1.0.0.xsd", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 2`] = ` +{ + "key": "concerto.xsd", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 3`] = ` +{ + "key": "org.acme.hr.xsd", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'mermaid' 1`] = ` +{ + "key": "model.mmd", + "value": "classDiagram +class \`org.acme.hr@1.0.0.State\` { +<< enumeration>> + + \`MA\` + + \`NY\` + + \`CO\` + + \`WA\` + + \`IL\` + + \`CA\` +} + +class \`org.acme.hr@1.0.0.Address\` { +<< concept>> + + \`String\` \`street\` + + \`String\` \`city\` + + \`State\` \`state\` + + \`String\` \`zipCode\` + + \`String\` \`country\` +} + +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@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\` +class \`org.acme.hr@1.0.0.Department\` { +<< enumeration>> + + \`Sales\` + + \`Marketing\` + + \`Finance\` + + \`HR\` + + \`Engineering\` + + \`Design\` +} + +class \`org.acme.hr@1.0.0.Equipment\` { +<< asset>> + + \`String\` \`serialNumber\` +} + +class \`org.acme.hr@1.0.0.LaptopMake\` { +<< enumeration>> + + \`Apple\` + + \`Microsoft\` +} + +class \`org.acme.hr@1.0.0.Laptop\` { +<< asset>> + + \`LaptopMake\` \`make\` +} + +\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` +\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` +class \`org.acme.hr@1.0.0.Person\` { +<< participant>> + + \`String\` \`email\` + + \`String\` \`firstName\` + + \`String\` \`lastName\` + + \`String\` \`middleNames\` + + \`Address\` \`homeAddress\` + + \`String\` \`ssn\` + + \`Double\` \`height\` + + \`DateTime\` \`dob\` +} + +\`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\` +class \`org.acme.hr@1.0.0.Employee\` { +<< participant>> + + \`String\` \`employeeId\` + + \`Long\` \`salary\` + + \`Integer\` \`numDependents\` + + \`Boolean\` \`retired\` + + \`Department\` \`department\` + + \`Address\` \`officeAddress\` + + \`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\` "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" *-- "*" \`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\` +class \`org.acme.hr@1.0.0.Contractor\` { +<< participant>> + + \`Company\` \`company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +} + +\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` +class \`org.acme.hr@1.0.0.Manager\` { +<< participant>> +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +} + +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` +class \`org.acme.hr@1.0.0.CompanyEvent\` +<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` + +class \`org.acme.hr@1.0.0.Onboarded\` { +<< event>> +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee +} + +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee +\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` +class \`org.acme.hr@1.0.0.ChangeOfAddress\` { +<< transaction>> +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person + + \`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\` +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO without the base model, format 'plantuml' 1`] = ` +{ + "key": "model.puml", + "value": "@startuml +title +Model +endtitle +class org.acme.hr_1_0_0.State << (E,grey) >> { + + MA + + NY + + CO + + WA + + IL + + CA +} +class org.acme.hr_1_0_0.Address { + + String street + + String city + + State state + + String zipCode + + String country +} +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_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 +class org.acme.hr_1_0_0.Department << (E,grey) >> { + + Sales + + Marketing + + Finance + + HR + + Engineering + + Design +} +class org.acme.hr_1_0_0.Equipment << (A,green) >> { + + String serialNumber +} +class org.acme.hr_1_0_0.LaptopMake << (E,grey) >> { + + Apple + + Microsoft +} +class org.acme.hr_1_0_0.Laptop << (A,green) >> { + + LaptopMake make +} +org.acme.hr_1_0_0.Laptop "1" *-- "1" org.acme.hr_1_0_0.LaptopMake : make +org.acme.hr_1_0_0.Laptop --|> org.acme.hr_1_0_0.Equipment +class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + + String email + + String firstName + + String lastName + + String middleNames + + Address homeAddress + + String ssn + + Double height + + DateTime dob +} +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 +class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + + String employeeId + + Long salary + + Integer numDependents + + Boolean retired + + Department department + + Address officeAddress + + Equipment[] companyAssets + + 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" *-- "*" 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 +class org.acme.hr_1_0_0.Contractor << (P,lightblue) >> { + + Company company + + Manager manager +} +org.acme.hr_1_0_0.Contractor "1" *-- "1" org.acme.hr_1_0_0.Company : company +org.acme.hr_1_0_0.Contractor "1" o-- "1" org.acme.hr_1_0_0.Manager : manager +org.acme.hr_1_0_0.Contractor --|> org.acme.hr_1_0_0.Person +class org.acme.hr_1_0_0.Manager << (P,lightblue) >> { + + Person[] reports +} +org.acme.hr_1_0_0.Manager "1" o-- "*" org.acme.hr_1_0_0.Person : reports +org.acme.hr_1_0_0.Manager --|> org.acme.hr_1_0_0.Employee +class org.acme.hr_1_0_0.CompanyEvent { +} +class org.acme.hr_1_0_0.Onboarded { + + Employee employee +} +org.acme.hr_1_0_0.Onboarded "1" o-- "1" org.acme.hr_1_0_0.Employee : employee +org.acme.hr_1_0_0.Onboarded --|> org.acme.hr_1_0_0.CompanyEvent +class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + + Person Person + + 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 +@enduml +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 1`] = ` +{ + "key": "concerto@1.0.0.avdl", + "value": "@namespace("concerto@1.0.0") +protocol MyProtocol { + + + record Concept { + } + + record Asset { + string _identifier; + } + + record Participant { + string _identifier; + } + + record Transaction { + @logicalType("timestamp-micros") + long _timestamp; + } + + record Event { + @logicalType("timestamp-micros") + long _timestamp; + } + +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 2`] = ` +{ + "key": "concerto.avdl", + "value": "@namespace("concerto") +protocol MyProtocol { + + + record Concept { + } + + record Asset { + string _identifier; + } + + record Participant { + string _identifier; + } + + record Transaction { + } + + record Event { + } + +} +", +} +`; + +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") +protocol MyProtocol { + + import idl "concerto@1.0.0.avdl"; + + enum State { + MA, + NY, + CO, + WA, + IL, + CA + } + + record Address { + string street; + string city; + union { null, State } state; + string zipCode; + string country; + } + + record Company { + string name; + Address headquarters; + } + + enum Department { + Sales, + Marketing, + Finance, + HR, + Engineering, + Design + } + + record Equipment { + string serialNumber; + } + + enum LaptopMake { + Apple, + Microsoft + } + + record Laptop { + LaptopMake make; + string serialNumber; + } + + record Person { + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record Employee { + string employeeId; + long salary; + int numDependents; + boolean retired; + Department department; + Address officeAddress; + array companyAssets; + union { null, string } manager; + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record Contractor { + Company company; + union { null, string } manager; + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record Manager { + union { null, array } reports; + string employeeId; + long salary; + int numDependents; + boolean retired; + Department department; + Address officeAddress; + array companyAssets; + union { null, string } manager; + string email; + string firstName; + string lastName; + union { null, string } middleNames; + Address homeAddress; + string ssn; + double height; + @logicalType("timestamp-micros") + long dob; + } + + record CompanyEvent { + @logicalType("timestamp-micros") + long _timestamp; + } + + record Onboarded { + string employee; + @logicalType("timestamp-micros") + long _timestamp; + } + + record ChangeOfAddress { + string Person; + Address newAddress; + @logicalType("timestamp-micros") + long _timestamp; + } + +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 1`] = ` +{ + "key": "concerto@1.0.0.cs", + "value": "namespace AccordProject.Concerto; +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Concept")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public virtual string _class { get; } = "concerto@1.0.0.Concept"; +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Asset")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Asset : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Asset"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Participant")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Participant : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Participant"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Transaction")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Transaction : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Transaction"; + [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] + public System.DateTime _timestamp { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Event")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Event : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto@1.0.0.Event"; + [System.Text.Json.Serialization.JsonPropertyName("$timestamp")] + public System.DateTime _timestamp { get; set; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 2`] = ` +{ + "key": "concerto.cs", + "value": "namespace AccordProject.Concerto; +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Concept")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public virtual string _class { get; } = "concerto.Concept"; +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Asset")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Asset : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Asset"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Participant")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Participant : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Participant"; + [AccordProject.Concerto.Identifier()] + [System.Text.Json.Serialization.JsonPropertyName("$identifier")] + public string _identifier { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Transaction")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Transaction : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Transaction"; +} +[AccordProject.Concerto.Type(Namespace = "concerto", Version = null, Name = "Event")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Event : Concept { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "concerto.Event"; +} +", +} +`; + +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; +using AccordProject.Concerto; +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum State { + MA, + NY, + CO, + WA, + IL, + CA, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", 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 string street { get; set; } + public string city { get; set; } + public State? state { get; set; } + public string zipCode { get; set; } + public string country { get; set; } +} +[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; } +} +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum Department { + Sales, + Marketing, + Finance, + HR, + Engineering, + Design, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Equipment")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public abstract class Equipment : Asset { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.Equipment"; + [AccordProject.Concerto.Identifier()] + public string serialNumber { get; set; } +} +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum LaptopMake { + Apple, + Microsoft, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Laptop")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Laptop : Equipment { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + 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 { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.Person"; + [AccordProject.Concerto.Identifier()] + public string email { get; set; } + public string firstName { get; set; } + public string lastName { get; set; } + public string? middleNames { get; set; } + public 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; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Employee")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Employee : Person { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.Employee"; + public string employeeId { get; set; } + public long salary { get; set; } + public int numDependents { get; set; } + public bool retired { get; set; } + public Department department { get; set; } + public Address officeAddress { get; set; } + public Equipment[] companyAssets { get; set; } + public Manager manager { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Contractor")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Contractor : Person { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.Contractor"; + public Company company { get; set; } + public Manager manager { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Manager")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Manager : Employee { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.Manager"; + public Person[] reports { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "CompanyEvent")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class CompanyEvent : Event { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.CompanyEvent"; +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Onboarded")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +public class Onboarded : CompanyEvent { + [System.Text.Json.Serialization.JsonPropertyName("$class")] + public override string _class { get; } = "org.acme.hr@1.0.0.Onboarded"; + public Employee employee { get; set; } +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "ChangeOfAddress")] +[System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] +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; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 1`] = ` +{ + "key": "concerto@1.0.0.go", + "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 { + Concept + Identifier string \`json:"$identifier"\` +} +type Participant struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Transaction struct { + Concept + Timestamp time.Time \`json:"$timestamp"\` +} +type Event struct { + Concept + Timestamp time.Time \`json:"$timestamp"\` +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 2`] = ` +{ + "key": "concerto.go", + "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. +package concerto + +type Concept struct { +} +type Asset struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Participant struct { + Concept + Identifier string \`json:"$identifier"\` +} +type Transaction struct { + Concept +} +type Event struct { + Concept +} +", +} +`; + +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" +import "concerto_1_0_0"; + +type State int +const ( + MA State = 1 + iota + NY + CO + WA + IL + CA +) +type Address struct { + concerto_1_0_0.Concept + Street string \`json:"street"\` + City string \`json:"city"\` + State State \`json:"state"\` + ZipCode string \`json:"zipCode"\` + Country string \`json:"country"\` +} +type Company struct { + concerto_1_0_0.Concept + Name string \`json:"name"\` + Headquarters Address \`json:"headquarters"\` +} +type Department int +const ( + Sales Department = 1 + iota + Marketing + Finance + HR + Engineering + Design +) +type Equipment struct { + concerto_1_0_0.Asset + SerialNumber string \`json:"serialNumber"\` +} +type LaptopMake int +const ( + Apple LaptopMake = 1 + iota + Microsoft +) +type Laptop struct { + Equipment + Make LaptopMake \`json:"make"\` +} +type Person struct { + concerto_1_0_0.Participant + Email string \`json:"email"\` + FirstName string \`json:"firstName"\` + LastName string \`json:"lastName"\` + MiddleNames string \`json:"middleNames"\` + HomeAddress Address \`json:"homeAddress"\` + Ssn string \`json:"ssn"\` + Height float64 \`json:"height"\` + Dob time.Time \`json:"dob"\` +} +type Employee struct { + Person + EmployeeId string \`json:"employeeId"\` + Salary int64 \`json:"salary"\` + NumDependents int32 \`json:"numDependents"\` + Retired bool \`json:"retired"\` + Department Department \`json:"department"\` + OfficeAddress Address \`json:"officeAddress"\` + CompanyAssets []Equipment \`json:"companyAssets"\` + Manager *Manager \`json:"manager"\` +} +type Contractor struct { + Person + Company Company \`json:"company"\` + Manager *Manager \`json:"manager"\` +} +type Manager struct { + Employee + Reports []*Person \`json:"reports"\` +} +type CompanyEvent struct { + concerto_1_0_0.Event +} +type Onboarded struct { + CompanyEvent + Employee *Employee \`json:"employee"\` +} +type ChangeOfAddress struct { + concerto_1_0_0.Transaction + Person *Person \`json:"Person"\` + NewAddress Address \`json:"newAddress"\` +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'graphql' 1`] = ` +{ + "key": "model.gql", + "value": "directive @resource on OBJECT | FIELD_DEFINITION +scalar DateTime +# namespace org.acme.hr@1.0.0 +enum State { + MA + NY + CO + WA + IL + CA +} +type Address { + street: String! + city: String! + state: State + zipCode: String! + country: String! +} +type Company { + name: String! + headquarters: Address! +} +enum Department { + Sales + Marketing + Finance + HR + Engineering + Design +} +type Equipment @resource { + serialNumber: String! + _identifier: String! +} +enum LaptopMake { + Apple + Microsoft +} +type Laptop { + make: LaptopMake! + serialNumber: String! + _identifier: String! +} +type Person @resource { + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type Employee { + employeeId: String! + salary: Int! + numDependents: Int! + retired: Boolean! + department: Department! + officeAddress: Address! + companyAssets: [Equipment]! + manager: ID # Manager + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type Contractor { + company: Company! + manager: ID # Manager + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type Manager { + reports: [ID] # Person + employeeId: String! + salary: Int! + numDependents: Int! + retired: Boolean! + department: Department! + officeAddress: Address! + companyAssets: [Equipment]! + manager: ID # Manager + email: String! + firstName: String! + lastName: String! + middleNames: String + homeAddress: Address! + ssn: String! + height: Float! + dob: DateTime! + _identifier: String! +} +type CompanyEvent { + _timestamp: DateTime! +} +type Onboarded { + employee: ID! # Employee + _timestamp: DateTime! +} +type ChangeOfAddress { + Person: ID! # Person + newAddress: Address! + _timestamp: DateTime! +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 1`] = ` +{ + "key": "concerto/Concept.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public abstract class Concept { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 2`] = ` +{ + "key": "concerto/Asset.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") +public abstract class Asset extends Concept { + private String $id; + @JsonProperty("$id") + public String get$id() { + return $id; + } + @JsonProperty("$id") + public void set$id(String i) { + $id = i; + } + + // the accessor for the identifying field + public String getID() { + return this.get$identifier(); + } + + private String $identifier; + public String get$identifier() { + return this.$identifier; + } + public void set$identifier(String $identifier) { + this.$identifier = $identifier; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 3`] = ` +{ + "key": "concerto/Participant.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +@JsonIgnoreProperties({"id"}) +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "$identifier") +public abstract class Participant extends Concept { + private String $id; + @JsonProperty("$id") + public String get$id() { + return $id; + } + @JsonProperty("$id") + public void set$id(String i) { + $id = i; + } + + // the accessor for the identifying field + public String getID() { + return this.get$identifier(); + } + + private String $identifier; + public String get$identifier() { + return this.$identifier; + } + public void set$identifier(String $identifier) { + this.$identifier = $identifier; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 4`] = ` +{ + "key": "concerto/Transaction.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public abstract class Transaction extends Concept { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 5`] = ` +{ + "key": "concerto/Event.java", + "value": "// this code is generated and should not be modified +package concerto; + +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +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", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum State { + MA, + NY, + CO, + WA, + IL, + CA, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 7`] = ` +{ + "key": "org/acme/hr/Address.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public class Address extends Concept { + private String street; + private String city; + private State state; + private String zipCode; + private String country; + public String getStreet() { + return this.street; + } + public String getCity() { + return this.city; + } + public State getState() { + return this.state; + } + public String getZipCode() { + return this.zipCode; + } + public String getCountry() { + return this.country; + } + public void setStreet(String street) { + this.street = street; + } + public void setCity(String city) { + this.city = city; + } + public void setState(State state) { + this.state = state; + } + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + public void setCountry(String country) { + this.country = country; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'markdown' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 8`] = ` { - "key": "models.md", - "value": "# Namespace org.acme.hr@1.0.0 - -## Overview -- 2 concepts -- 3 enumerations -- 2 assets -- 4 participants -- 1 transactions -- 2 events -- 15 total declarations - -## Imports -- 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 + "key": "org/acme/hr/Company.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -## Diagram -\`\`\`mermaid -classDiagram -class \`org.acme.hr@1.0.0.State\` { -<< enumeration>> - + \`MA\` - + \`NY\` - + \`CO\` - + \`WA\` - + \`IL\` - + \`CA\` -} +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; -class \`org.acme.hr@1.0.0.Address\` { -<< concept>> - + \`String\` \`street\` - + \`String\` \`city\` - + \`State\` \`state\` - + \`String\` \`zipCode\` - + \`String\` \`country\` +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") +public class Company extends Concept { + private String name; + private Address headquarters; + public String getName() { + return this.name; + } + public Address getHeadquarters() { + return this.headquarters; + } + public void setName(String name) { + this.name = name; + } + public void setHeadquarters(Address headquarters) { + this.headquarters = headquarters; + } } - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@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\` -class \`org.acme.hr@1.0.0.Department\` { -<< enumeration>> - + \`Sales\` - + \`Marketing\` - + \`Finance\` - + \`HR\` - + \`Engineering\` - + \`Design\` -} +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 9`] = ` +{ + "key": "org/acme/hr/Department.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -class \`org.acme.hr@1.0.0.Equipment\` { -<< asset>> - + \`String\` \`serialNumber\` +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum Department { + Sales, + Marketing, + Finance, + HR, + Engineering, + Design, } - -class \`org.acme.hr@1.0.0.LaptopMake\` { -<< enumeration>> - + \`Apple\` - + \`Microsoft\` +", } +`; -class \`org.acme.hr@1.0.0.Laptop\` { -<< asset>> - + \`LaptopMake\` \`make\` -} +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 10`] = ` +{ + "key": "org/acme/hr/Equipment.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` -\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` -class \`org.acme.hr@1.0.0.Person\` { -<< participant>> - + \`String\` \`email\` - + \`String\` \`firstName\` - + \`String\` \`lastName\` - + \`String\` \`middleNames\` - + \`Address\` \`homeAddress\` - + \`String\` \`ssn\` - + \`Double\` \`height\` - + \`DateTime\` \`dob\` -} +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; -\`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\` -class \`org.acme.hr@1.0.0.Employee\` { -<< participant>> - + \`String\` \`employeeId\` - + \`Long\` \`salary\` - + \`Integer\` \`numDependents\` - + \`Boolean\` \`retired\` - + \`Department\` \`department\` - + \`Address\` \`officeAddress\` - + \`Equipment[]\` \`companyAssets\` -\`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -} +@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(); + } -\`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" *-- "*" \`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\` -class \`org.acme.hr@1.0.0.Contractor\` { -<< participant>> - + \`Company\` \`company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager + private String serialNumber; + public String getSerialNumber() { + return this.serialNumber; + } + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } } - -\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` -class \`org.acme.hr@1.0.0.Manager\` { -<< participant>> -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +", } +`; -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports -\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` -class \`org.acme.hr@1.0.0.CompanyEvent\` -<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 11`] = ` +{ + "key": "org/acme/hr/LaptopMake.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -class \`org.acme.hr@1.0.0.Onboarded\` { -<< event>> -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum LaptopMake { + Apple, + Microsoft, } - -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee -\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` -class \`org.acme.hr@1.0.0.ChangeOfAddress\` { -<< transaction>> -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person - + \`Address\` \`newAddress\` +", } +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 12`] = ` +{ + "key": "org/acme/hr/Laptop.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -\`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\` -\`\`\` +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +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(); + } + private LaptopMake make; + public LaptopMake getMake() { + return this.make; + } + public void setMake(LaptopMake make) { + this.make = make; + } +} ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'mermaid' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 13`] = ` { - "key": "model.mmd", - "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { -<< enumeration>> - + \`MA\` - + \`NY\` - + \`CO\` - + \`WA\` - + \`IL\` - + \`CA\` -} + "key": "org/acme/hr/Person.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -\`org.acme.hr@1.0.0.State\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Address\` { -<< concept>> - + \`String\` \`street\` - + \`String\` \`city\` - + \`State\` \`state\` - + \`String\` \`zipCode\` - + \`String\` \`country\` -} +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Company\` { -<< concept>> - + \`String\` \`name\` - + \`Address\` \`headquarters\` -} +@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(); + } -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Company\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Department\` { -<< enumeration>> - + \`Sales\` - + \`Marketing\` - + \`Finance\` - + \`HR\` - + \`Engineering\` - + \`Design\` + private String email; + private String firstName; + private String lastName; + private String middleNames; + private Address homeAddress; + private String ssn; + private double height; + private java.util.Date dob; + public String getEmail() { + return this.email; + } + public String getFirstName() { + return this.firstName; + } + public String getLastName() { + return this.lastName; + } + public String getMiddleNames() { + return this.middleNames; + } + public Address getHomeAddress() { + return this.homeAddress; + } + public String getSsn() { + return this.ssn; + } + public double getHeight() { + return this.height; + } + public java.util.Date getDob() { + return this.dob; + } + public void setEmail(String email) { + this.email = email; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public void setMiddleNames(String middleNames) { + this.middleNames = middleNames; + } + public void setHomeAddress(Address homeAddress) { + this.homeAddress = homeAddress; + } + public void setSsn(String ssn) { + this.ssn = ssn; + } + public void setHeight(double height) { + this.height = height; + } + public void setDob(java.util.Date dob) { + this.dob = dob; + } } - -\`org.acme.hr@1.0.0.Department\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Equipment\` { -<< asset>> - + \`String\` \`serialNumber\` +", } +`; -\`org.acme.hr@1.0.0.Equipment\` --|> \`concerto@1.0.0.Asset\` -class \`org.acme.hr@1.0.0.LaptopMake\` { -<< enumeration>> - + \`Apple\` - + \`Microsoft\` -} +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 14`] = ` +{ + "key": "org/acme/hr/Employee.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -\`org.acme.hr@1.0.0.LaptopMake\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Laptop\` { -<< asset>> - + \`LaptopMake\` \`make\` -} +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; -\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` -\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` -class \`org.acme.hr@1.0.0.Person\` { -<< participant>> - + \`String\` \`email\` - + \`String\` \`firstName\` - + \`String\` \`lastName\` - + \`String\` \`middleNames\` - + \`Address\` \`homeAddress\` - + \`String\` \`ssn\` - + \`Double\` \`height\` - + \`DateTime\` \`dob\` -} +@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(); + } -\`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\` --|> \`concerto@1.0.0.Participant\` -class \`org.acme.hr@1.0.0.Employee\` { -<< participant>> - + \`String\` \`employeeId\` - + \`Long\` \`salary\` - + \`Integer\` \`numDependents\` - + \`Boolean\` \`retired\` - + \`Department\` \`department\` - + \`Address\` \`officeAddress\` - + \`Equipment[]\` \`companyAssets\` -\`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager + private String employeeId; + private long salary; + private int numDependents; + private boolean retired; + private Department department; + private Address officeAddress; + private Equipment[] companyAssets; + private Manager manager; + public String getEmployeeId() { + return this.employeeId; + } + public long getSalary() { + return this.salary; + } + public int getNumDependents() { + return this.numDependents; + } + public boolean getRetired() { + return this.retired; + } + public Department getDepartment() { + return this.department; + } + public Address getOfficeAddress() { + return this.officeAddress; + } + public Equipment[] getCompanyAssets() { + return this.companyAssets; + } + public Manager getManager() { + return this.manager; + } + public void setEmployeeId(String employeeId) { + this.employeeId = employeeId; + } + public void setSalary(long salary) { + this.salary = salary; + } + public void setNumDependents(int numDependents) { + this.numDependents = numDependents; + } + public void setRetired(boolean retired) { + this.retired = retired; + } + public void setDepartment(Department department) { + this.department = department; + } + public void setOfficeAddress(Address officeAddress) { + this.officeAddress = officeAddress; + } + public void setCompanyAssets(Equipment[] companyAssets) { + this.companyAssets = companyAssets; + } + public void setManager(Manager manager) { + this.manager = manager; + } } - -\`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" *-- "*" \`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\` -class \`org.acme.hr@1.0.0.Contractor\` { -<< participant>> - + \`Company\` \`company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +", } +`; -\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` -\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager -\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` -class \`org.acme.hr@1.0.0.Manager\` { -<< participant>> -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports -} +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 15`] = ` +{ + "key": "org/acme/hr/Contractor.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports -\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` -class \`org.acme.hr@1.0.0.CompanyEvent\` -<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; -\`org.acme.hr@1.0.0.CompanyEvent\` --|> \`concerto@1.0.0.Event\` -class \`org.acme.hr@1.0.0.Onboarded\` { -<< event>> -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee -} +@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(); + } -\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee -\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` -class \`org.acme.hr@1.0.0.ChangeOfAddress\` { -<< transaction>> -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person - + \`Address\` \`newAddress\` + private Company company; + private Manager manager; + public Company getCompany() { + return this.company; + } + public Manager getManager() { + return this.manager; + } + public void setCompany(Company company) { + this.company = company; + } + public void setManager(Manager manager) { + this.manager = manager; + } } - -\`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\` --|> \`concerto@1.0.0.Transaction\` ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 16`] = ` { - "key": "concerto.csdl", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - -", -} -`; + "key": "org/acme/hr/Manager.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 2`] = ` -{ - "key": "org.acme.hr.csdl", - "value": " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +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(); + } + + private Person[] reports; + public Person[] getReports() { + return this.reports; + } + public void setReports(Person[] reports) { + this.reports = reports; + } +} ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'openapi' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 17`] = ` { - "key": "openapi.json", + "key": "org/acme/hr/CompanyEvent.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +public class CompanyEvent extends Event { +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 18`] = ` +{ + "key": "org/acme/hr/Onboarded.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +public class Onboarded extends CompanyEvent { + private Employee employee; + public Employee getEmployee() { + return this.employee; + } + public void setEmployee(Employee employee) { + this.employee = employee; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 19`] = ` +{ + "key": "org/acme/hr/ChangeOfAddress.java", + "value": "// this code is generated and should not be modified +package org.acme.hr; + +import concerto.Concept; +import concerto.Asset; +import concerto.Transaction; +import concerto.Participant; +import concerto.Event; +import com.fasterxml.jackson.annotation.*; + +public class ChangeOfAddress extends Transaction { + private Person Person; + private Address newAddress; + public Person getPerson() { + return this.Person; + } + public Address getNewAddress() { + return this.newAddress; + } + public void setPerson(Person Person) { + this.Person = Person; + } + public void setNewAddress(Address newAddress) { + this.newAddress = newAddress; + } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'jsonschema' 1`] = ` +{ + "key": "schema.json", "value": "{ - "openapi": "3.0.2", - "servers": [], - "info": { - "title": "Generated Open API from Concerto Models", - "version": "1.0.0", - "description": "Create, read, update and delete entities" - }, - "components": { - "schemas": { - "org.acme.hr@1.0.0.State": { - "title": "State", - "description": "An instance of org.acme.hr@1.0.0.State", - "enum": [ - "MA", - "NY", - "CO", - "WA", - "IL", - "CA" - ] - }, - "org.acme.hr@1.0.0.Address": { - "title": "Address", - "description": "An instance of org.acme.hr@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" - }, - "street": { - "type": "string" - }, - "city": { - "type": "string" - }, - "state": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.State" - }, - "zipCode": { - "type": "string" - }, - "country": { - "type": "string" - } - }, - "required": [ - "$class", - "street", - "city", - "zipCode", - "country" - ] - }, - "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@1.0.0.Address" - } - }, - "required": [ - "$class", - "name", - "headquarters" - ] - }, - "org.acme.hr@1.0.0.Department": { - "title": "Department", - "description": "An instance of org.acme.hr@1.0.0.Department", - "enum": [ - "Sales", - "Marketing", - "Finance", - "HR", - "Engineering", - "Design" - ] - }, - "org.acme.hr@1.0.0.Equipment": { - "title": "Equipment", - "description": "An instance of org.acme.hr@1.0.0.Equipment", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Equipment", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Equipment$", - "description": "The class identifier for org.acme.hr@1.0.0.Equipment" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } - }, - "required": [ - "$class", - "serialNumber" - ], - "$decorators": { - "resource": [] - } - }, - "org.acme.hr@1.0.0.LaptopMake": { - "title": "LaptopMake", - "description": "An instance of org.acme.hr@1.0.0.LaptopMake", - "enum": [ - "Apple", - "Microsoft" - ] - }, - "org.acme.hr@1.0.0.Laptop": { - "title": "Laptop", - "description": "An instance of org.acme.hr@1.0.0.Laptop", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Laptop", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Laptop$", - "description": "The class identifier for org.acme.hr@1.0.0.Laptop" - }, - "make": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.LaptopMake" - }, - "serialNumber": { - "type": "string", - "description": "The instance identifier for this type" - } + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "org.acme.hr@1.0.0.State": { + "title": "State", + "description": "An instance of org.acme.hr@1.0.0.State", + "enum": [ + "MA", + "NY", + "CO", + "WA", + "IL", + "CA" + ] + }, + "org.acme.hr@1.0.0.Address": { + "title": "Address", + "description": "An instance of org.acme.hr@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" }, - "required": [ - "$class", - "make", - "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", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Person", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Person$", - "description": "The class identifier for org.acme.hr@1.0.0.Person" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } + "street": { + "type": "string" }, - "required": [ - "$class", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ], - "$decorators": { - "resource": [] + "city": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/org.acme.hr@1.0.0.State" + }, + "zipCode": { + "type": "string" + }, + "country": { + "type": "string" } }, - "org.acme.hr@1.0.0.Employee": { - "title": "Employee", - "description": "An instance of org.acme.hr@1.0.0.Employee", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Employee", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Employee$", - "description": "The class identifier for org.acme.hr@1.0.0.Employee" - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" - }, - "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" - }, - { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } + "required": [ + "$class", + "street", + "city", + "zipCode", + "country" + ] + }, + "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" }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] + "name": { + "type": "string" + }, + "headquarters": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + } }, - "org.acme.hr@1.0.0.Contractor": { - "title": "Contractor", - "description": "An instance of org.acme.hr@1.0.0.Contractor", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Contractor", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Contractor$", - "description": "The class identifier for org.acme.hr@1.0.0.Contractor" - }, - "company": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Company" - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } + "required": [ + "$class", + "name", + "headquarters" + ] + }, + "org.acme.hr@1.0.0.Department": { + "title": "Department", + "description": "An instance of org.acme.hr@1.0.0.Department", + "enum": [ + "Sales", + "Marketing", + "Finance", + "HR", + "Engineering", + "Design" + ] + }, + "org.acme.hr@1.0.0.Equipment": { + "title": "Equipment", + "description": "An instance of org.acme.hr@1.0.0.Equipment", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Equipment", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Equipment$", + "description": "The class identifier for org.acme.hr@1.0.0.Equipment" }, - "required": [ - "$class", - "company", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } }, - "org.acme.hr@1.0.0.Manager": { - "title": "Manager", - "description": "An instance of org.acme.hr@1.0.0.Manager", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Manager", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Manager$", - "description": "The class identifier for org.acme.hr@1.0.0.Manager" - }, - "reports": { - "type": "array", - "items": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" - } - }, - "employeeId": { - "type": "string" - }, - "salary": { - "type": "integer" - }, - "numDependents": { - "type": "integer" - }, - "retired": { - "type": "boolean" - }, - "department": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" - }, - "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" - }, - "companyAssets": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" - }, - { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Laptop" - } - ] - } - }, - "manager": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" - }, - "email": { - "type": "string", - "description": "The instance identifier for this type" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "middleNames": { - "type": "string" - }, - "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" - }, - "ssn": { - "default": "000-00-0000", - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, - "height": { - "type": "number" - }, - "dob": { - "format": "date-time", - "type": "string" - } + "required": [ + "$class", + "serialNumber" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr@1.0.0.LaptopMake": { + "title": "LaptopMake", + "description": "An instance of org.acme.hr@1.0.0.LaptopMake", + "enum": [ + "Apple", + "Microsoft" + ] + }, + "org.acme.hr@1.0.0.Laptop": { + "title": "Laptop", + "description": "An instance of org.acme.hr@1.0.0.Laptop", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Laptop", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Laptop$", + "description": "The class identifier for org.acme.hr@1.0.0.Laptop" }, - "required": [ - "$class", - "employeeId", - "salary", - "numDependents", - "retired", - "department", - "officeAddress", - "companyAssets", - "email", - "firstName", - "lastName", - "homeAddress", - "ssn", - "height", - "dob" - ] + "make": { + "$ref": "#/definitions/org.acme.hr@1.0.0.LaptopMake" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } }, - "org.acme.hr@1.0.0.CompanyEvent": { - "title": "CompanyEvent", - "description": "An instance of org.acme.hr@1.0.0.CompanyEvent", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.CompanyEvent", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.CompanyEvent$", - "description": "The class identifier for org.acme.hr@1.0.0.CompanyEvent" - } + "required": [ + "$class", + "make", + "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", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Person", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Person$", + "description": "The class identifier for org.acme.hr@1.0.0.Person" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr@1.0.0.Employee": { + "title": "Employee", + "description": "An instance of org.acme.hr@1.0.0.Employee", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Employee", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Employee$", + "description": "The class identifier for org.acme.hr@1.0.0.Employee" + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" }, - "required": [ - "$class" - ] - }, - "org.acme.hr@1.0.0.Onboarded": { - "title": "Onboarded", - "description": "An instance of org.acme.hr@1.0.0.Onboarded", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.Onboarded", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Onboarded$", - "description": "The class identifier for org.acme.hr@1.0.0.Onboarded" - }, - "employee": { - "type": "string", - "description": "The identifier of an instance of org.acme.hr@1.0.0.Employee" - } + "numDependents": { + "type": "integer" }, - "required": [ - "$class", - "employee" - ] - }, - "org.acme.hr@1.0.0.ChangeOfAddress": { - "title": "ChangeOfAddress", - "description": "An instance of org.acme.hr@1.0.0.ChangeOfAddress", - "type": "object", - "properties": { - "$class": { - "type": "string", - "default": "org.acme.hr@1.0.0.ChangeOfAddress", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.ChangeOfAddress$", - "description": "The class identifier for org.acme.hr@1.0.0.ChangeOfAddress" - }, - "Person": { - "type": "string", - "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" - } + "retired": { + "type": "boolean" }, - "required": [ - "$class", - "Person", - "newAddress" - ] - } - } - }, - "paths": { - "/equipment": { - "summary": "Path used to manage the list of equipment.", - "description": "The REST endpoint/path used to list and create zero or more \`equipment\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" - } - } + "department": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Department" + }, + "officeAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/org.acme.hr@1.0.0.Equipment" + }, + { + "$ref": "#/definitions/org.acme.hr@1.0.0.Laptop" } - }, - "description": "Successful response - returns an array of \`equipment\` entities." + ] } }, - "operationId": "listEquipment", - "summary": "List All Equipment", - "description": "Gets a list of all \`equipment\` entities.", - "tags": [ - "equipment" - ] - }, - "post": { - "requestBody": { - "description": "A new \`equipment\` to be created.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" - } - } - }, - "required": true + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" }, - "responses": { - "201": { - "description": "Successful response." - } + "email": { + "type": "string", + "description": "The instance identifier for this type" }, - "operationId": "createEquipment", - "summary": "Create a Equipment", - "description": "Creates a new instance of a \`equipment\`.", - "tags": [ - "equipment" - ] - } - }, - "/equipment/{serialNumber}": { - "summary": "Path used to manage a single equipment.", - "description": "The REST endpoint/path used to get, update, and delete single instances of a \`equipment\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" - } - } - }, - "description": "Successful response - returns a single \`equipment\`." - } + "firstName": { + "type": "string" }, - "operationId": "getEquipment", - "summary": "Get a equipment", - "description": "Gets the details of a single instance of a \`equipment\`.", - "tags": [ - "equipment" - ] - }, - "put": { - "requestBody": { - "description": "Updated \`equipment\` information.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" - } - } - }, - "required": true + "lastName": { + "type": "string" }, - "responses": { - "202": { - "description": "Successful response." - } + "middleNames": { + "type": "string" }, - "operationId": "replaceEquipment", - "summary": "Update a equipment", - "description": "Updates an existing \`equipment\`.", - "tags": [ - "equipment" - ] - }, - "delete": { - "responses": { - "204": { - "description": "Successful response." - } + "homeAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" }, - "operationId": "deleteEquipment", - "summary": "Delete a equipment", - "description": "Deletes an existing \`equipment\`.", - "tags": [ - "equipment" - ] + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } }, - "parameters": [ - { - "name": "serialNumber", - "description": "A unique identifier for a \`Equipment\`.", - "schema": { - "type": "string" - }, - "in": "path", - "required": true + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr@1.0.0.Contractor": { + "title": "Contractor", + "description": "An instance of org.acme.hr@1.0.0.Contractor", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Contractor", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Contractor$", + "description": "The class identifier for org.acme.hr@1.0.0.Contractor" + }, + "company": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Company" + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" } + }, + "required": [ + "$class", + "company", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" ] }, - "/people": { - "summary": "Path used to manage the list of people.", - "description": "The REST endpoint/path used to list and create zero or more \`person\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" - } - } - } - }, - "description": "Successful response - returns an array of \`person\` entities." + "org.acme.hr@1.0.0.Manager": { + "title": "Manager", + "description": "An instance of org.acme.hr@1.0.0.Manager", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Manager", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Manager$", + "description": "The class identifier for org.acme.hr@1.0.0.Manager" + }, + "reports": { + "type": "array", + "items": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" } }, - "operationId": "listPeople", - "summary": "List All People", - "description": "Gets a list of all \`person\` entities.", - "tags": [ - "people" - ] - }, - "post": { - "requestBody": { - "description": "A new \`person\` to be created.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" - } - } - }, - "required": true + "employeeId": { + "type": "string" }, - "responses": { - "201": { - "description": "Successful response." - } + "salary": { + "type": "integer" }, - "operationId": "createPerson", - "summary": "Create a Person", - "description": "Creates a new instance of a \`person\`.", - "tags": [ - "people" - ] - } - }, - "/people/{email}": { - "summary": "Path used to manage a single person.", - "description": "The REST endpoint/path used to get, update, and delete single instances of a \`person\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", - "get": { - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" - } + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Department" + }, + "officeAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/org.acme.hr@1.0.0.Equipment" + }, + { + "$ref": "#/definitions/org.acme.hr@1.0.0.Laptop" } - }, - "description": "Successful response - returns a single \`person\`." + ] } }, - "operationId": "getPerson", - "summary": "Get a person", - "description": "Gets the details of a single instance of a \`person\`.", - "tags": [ - "people" - ] - }, - "put": { - "requestBody": { - "description": "Updated \`person\` information.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" - } - } - }, - "required": true + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" }, - "responses": { - "202": { - "description": "Successful response." - } + "email": { + "type": "string", + "description": "The instance identifier for this type" }, - "operationId": "replacePerson", - "summary": "Update a person", - "description": "Updates an existing \`person\`.", - "tags": [ - "people" - ] + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } }, - "delete": { - "responses": { - "204": { - "description": "Successful response." - } + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr@1.0.0.CompanyEvent": { + "title": "CompanyEvent", + "description": "An instance of org.acme.hr@1.0.0.CompanyEvent", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.CompanyEvent", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.CompanyEvent$", + "description": "The class identifier for org.acme.hr@1.0.0.CompanyEvent" + } + }, + "required": [ + "$class" + ] + }, + "org.acme.hr@1.0.0.Onboarded": { + "title": "Onboarded", + "description": "An instance of org.acme.hr@1.0.0.Onboarded", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Onboarded", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Onboarded$", + "description": "The class identifier for org.acme.hr@1.0.0.Onboarded" + }, + "employee": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Employee" + } + }, + "required": [ + "$class", + "employee" + ] + }, + "org.acme.hr@1.0.0.ChangeOfAddress": { + "title": "ChangeOfAddress", + "description": "An instance of org.acme.hr@1.0.0.ChangeOfAddress", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.ChangeOfAddress", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.ChangeOfAddress$", + "description": "The class identifier for org.acme.hr@1.0.0.ChangeOfAddress" }, - "operationId": "deletePerson", - "summary": "Delete a person", - "description": "Deletes an existing \`person\`.", - "tags": [ - "people" - ] - }, - "parameters": [ - { - "name": "email", - "description": "A unique identifier for a \`Person\`.", - "schema": { - "type": "string" - }, - "in": "path", - "required": true + "Person": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" + }, + "newAddress": { + "$ref": "#/definitions/org.acme.hr@1.0.0.Address" } + }, + "required": [ + "$class", + "Person", + "newAddress" ] } } @@ -7254,973 +6716,1508 @@ 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 'plantuml' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'markdown' 1`] = ` { - "key": "model.puml", - "value": "@startuml -title -Model -endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { - + MA - + NY - + CO - + WA - + IL - + CA -} -org.acme.hr_1_0_0.State --|> concerto_1_0_0.Concept -class org.acme.hr_1_0_0.Address { - + String street - + String city - + State state - + String zipCode - + String country -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state -org.acme.hr_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 -org.acme.hr_1_0_0.Company --|> concerto_1_0_0.Concept -class org.acme.hr_1_0_0.Department << (E,grey) >> { - + Sales - + Marketing - + Finance - + HR - + Engineering - + Design -} -org.acme.hr_1_0_0.Department --|> concerto_1_0_0.Concept -class org.acme.hr_1_0_0.Equipment << (A,green) >> { - + String serialNumber -} -org.acme.hr_1_0_0.Equipment --|> concerto_1_0_0.Asset -class org.acme.hr_1_0_0.LaptopMake << (E,grey) >> { - + Apple - + Microsoft -} -org.acme.hr_1_0_0.LaptopMake --|> concerto_1_0_0.Concept -class org.acme.hr_1_0_0.Laptop << (A,green) >> { - + LaptopMake make -} -org.acme.hr_1_0_0.Laptop "1" *-- "1" org.acme.hr_1_0_0.LaptopMake : make -org.acme.hr_1_0_0.Laptop --|> org.acme.hr_1_0_0.Equipment -class org.acme.hr_1_0_0.Person << (P,lightblue) >> { - + String email - + String firstName - + String lastName - + String middleNames - + Address homeAddress - + String ssn - + Double height - + DateTime dob -} -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 --|> concerto_1_0_0.Participant -class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { - + String employeeId - + Long salary - + Integer numDependents - + Boolean retired - + Department department - + Address officeAddress - + Equipment[] companyAssets - + Manager manager + "key": "models.md", + "value": "# Namespace org.acme.hr@1.0.0 + +## Overview +- 2 concepts +- 3 enumerations +- 2 assets +- 4 participants +- 1 transactions +- 2 events +- 15 total declarations + +## Imports +- 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.State\` { +<< enumeration>> + + \`MA\` + + \`NY\` + + \`CO\` + + \`WA\` + + \`IL\` + + \`CA\` } -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" *-- "*" 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 -class org.acme.hr_1_0_0.Contractor << (P,lightblue) >> { - + Company company - + Manager manager + +class \`org.acme.hr@1.0.0.Address\` { +<< concept>> + + \`String\` \`street\` + + \`String\` \`city\` + + \`State\` \`state\` + + \`String\` \`zipCode\` + + \`String\` \`country\` } -org.acme.hr_1_0_0.Contractor "1" *-- "1" org.acme.hr_1_0_0.Company : company -org.acme.hr_1_0_0.Contractor "1" o-- "1" org.acme.hr_1_0_0.Manager : manager -org.acme.hr_1_0_0.Contractor --|> org.acme.hr_1_0_0.Person -class org.acme.hr_1_0_0.Manager << (P,lightblue) >> { - + Person[] reports + +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` +class \`org.acme.hr@1.0.0.Company\` { +<< concept>> + + \`String\` \`name\` + + \`Address\` \`headquarters\` } -org.acme.hr_1_0_0.Manager "1" o-- "*" org.acme.hr_1_0_0.Person : reports -org.acme.hr_1_0_0.Manager --|> org.acme.hr_1_0_0.Employee -class org.acme.hr_1_0_0.CompanyEvent { + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +class \`org.acme.hr@1.0.0.Department\` { +<< enumeration>> + + \`Sales\` + + \`Marketing\` + + \`Finance\` + + \`HR\` + + \`Engineering\` + + \`Design\` } -org.acme.hr_1_0_0.CompanyEvent --|> concerto_1_0_0.Event -class org.acme.hr_1_0_0.Onboarded { - + Employee employee + +class \`org.acme.hr@1.0.0.Equipment\` { +<< asset>> + + \`String\` \`serialNumber\` } -org.acme.hr_1_0_0.Onboarded "1" o-- "1" org.acme.hr_1_0_0.Employee : employee -org.acme.hr_1_0_0.Onboarded --|> org.acme.hr_1_0_0.CompanyEvent -class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { - + Person Person - + Address newAddress + +class \`org.acme.hr@1.0.0.LaptopMake\` { +<< enumeration>> + + \`Apple\` + + \`Microsoft\` } -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 --|> concerto_1_0_0.Transaction -@enduml -", + +class \`org.acme.hr@1.0.0.Laptop\` { +<< asset>> + + \`LaptopMake\` \`make\` } -`; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'protobuf' 1`] = ` -{ - "key": "org.acme.hr.v1_0_0.proto", - "value": "syntax = "proto3"; +\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` +\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` +class \`org.acme.hr@1.0.0.Person\` { +<< participant>> + + \`String\` \`email\` + + \`String\` \`firstName\` + + \`String\` \`lastName\` + + \`String\` \`middleNames\` + + \`Address\` \`homeAddress\` + + \`String\` \`ssn\` + + \`Double\` \`height\` + + \`DateTime\` \`dob\` +} -package org.acme.hr.v1_0_0; +\`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\` +class \`org.acme.hr@1.0.0.Employee\` { +<< participant>> + + \`String\` \`employeeId\` + + \`Long\` \`salary\` + + \`Integer\` \`numDependents\` + + \`Boolean\` \`retired\` + + \`Department\` \`department\` + + \`Address\` \`officeAddress\` + + \`Equipment[]\` \`companyAssets\` +\`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +} -import "google/protobuf/timestamp.proto"; +\`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" *-- "*" \`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\` +class \`org.acme.hr@1.0.0.Contractor\` { +<< participant>> + + \`Company\` \`company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +} -enum State { - State_CA = 0; - State_CO = 1; - State_IL = 2; - State_MA = 3; - State_NY = 4; - State_WA = 5; +\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` +class \`org.acme.hr@1.0.0.Manager\` { +<< participant>> +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +} + +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` +class \`org.acme.hr@1.0.0.CompanyEvent\` +<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` + +class \`org.acme.hr@1.0.0.Onboarded\` { +<< event>> +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee } -message Address { - string city = 1; - string country = 2; - optional State state = 3; - string street = 4; - string zipCode = 5; +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee +\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` +class \`org.acme.hr@1.0.0.ChangeOfAddress\` { +<< transaction>> +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person + + \`Address\` \`newAddress\` } -message Company { - Address headquarters = 1; - string name = 2; +\`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\` +\`\`\` + +", } +`; -enum Department { - Department_Design = 0; - Department_Engineering = 1; - Department_Finance = 2; - Department_HR = 3; - Department_Marketing = 4; - Department_Sales = 5; +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'mermaid' 1`] = ` +{ + "key": "model.mmd", + "value": "classDiagram +class \`org.acme.hr@1.0.0.State\` { +<< enumeration>> + + \`MA\` + + \`NY\` + + \`CO\` + + \`WA\` + + \`IL\` + + \`CA\` } -message _Subclasses_of_class_Equipment { - oneof _class_oneof_Equipment { - Laptop _subclass_of_class_Equipment_Laptop = 1; - } +\`org.acme.hr@1.0.0.State\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr@1.0.0.Address\` { +<< concept>> + + \`String\` \`street\` + + \`String\` \`city\` + + \`State\` \`state\` + + \`String\` \`zipCode\` + + \`String\` \`country\` } -enum LaptopMake { - LaptopMake_Apple = 0; - LaptopMake_Microsoft = 1; +\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` +\`org.acme.hr@1.0.0.Address\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr@1.0.0.Company\` { +<< concept>> + + \`String\` \`name\` + + \`Address\` \`headquarters\` } -message Laptop { - LaptopMake make = 1; - string serialNumber = 2; +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr@1.0.0.Department\` { +<< enumeration>> + + \`Sales\` + + \`Marketing\` + + \`Finance\` + + \`HR\` + + \`Engineering\` + + \`Design\` } -message _Subclasses_of_class_Person { - oneof _class_oneof_Person { - Contractor _subclass_of_class_Person_Contractor = 1; - Employee _subclass_of_class_Person_Employee = 2; - Manager _subclass_of_class_Person_Manager = 3; - } +\`org.acme.hr@1.0.0.Department\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr@1.0.0.Equipment\` { +<< asset>> + + \`String\` \`serialNumber\` } -message Employee { - repeated _Subclasses_of_class_Equipment companyAssets = 1; - Department department = 2; - google.protobuf.Timestamp dob = 3; - string email = 4; - string employeeId = 5; - string firstName = 6; - double height = 7; - Address homeAddress = 8; - 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; +\`org.acme.hr@1.0.0.Equipment\` --|> \`concerto@1.0.0.Asset\` +class \`org.acme.hr@1.0.0.LaptopMake\` { +<< enumeration>> + + \`Apple\` + + \`Microsoft\` } -message _Subclasses_of_class_Employee { - oneof _class_oneof_Employee { - Employee _subclass_of_class_Employee_Employee = 1; - Manager _subclass_of_class_Employee_Manager = 2; - } +\`org.acme.hr@1.0.0.LaptopMake\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr@1.0.0.Laptop\` { +<< asset>> + + \`LaptopMake\` \`make\` } -message Contractor { - Company company = 1; - google.protobuf.Timestamp dob = 2; - string email = 3; - string firstName = 4; - double height = 5; - Address homeAddress = 6; - string lastName = 7; - optional string manager = 8; - optional string middleNames = 9; - string ssn = 10; +\`org.acme.hr@1.0.0.Laptop\` "1" *-- "1" \`org.acme.hr@1.0.0.LaptopMake\` +\`org.acme.hr@1.0.0.Laptop\` --|> \`org.acme.hr@1.0.0.Equipment\` +class \`org.acme.hr@1.0.0.Person\` { +<< participant>> + + \`String\` \`email\` + + \`String\` \`firstName\` + + \`String\` \`lastName\` + + \`String\` \`middleNames\` + + \`Address\` \`homeAddress\` + + \`String\` \`ssn\` + + \`Double\` \`height\` + + \`DateTime\` \`dob\` } -message Manager { - repeated _Subclasses_of_class_Equipment companyAssets = 1; - Department department = 2; - google.protobuf.Timestamp dob = 3; - string email = 4; - string employeeId = 5; - string firstName = 6; - double height = 7; - Address homeAddress = 8; - 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; +\`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\` --|> \`concerto@1.0.0.Participant\` +class \`org.acme.hr@1.0.0.Employee\` { +<< participant>> + + \`String\` \`employeeId\` + + \`Long\` \`salary\` + + \`Integer\` \`numDependents\` + + \`Boolean\` \`retired\` + + \`Department\` \`department\` + + \`Address\` \`officeAddress\` + + \`Equipment[]\` \`companyAssets\` +\`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager } -message CompanyEvent { +\`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" *-- "*" \`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\` +class \`org.acme.hr@1.0.0.Contractor\` { +<< participant>> + + \`Company\` \`company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager } -message _Subclasses_of_class_CompanyEvent { - oneof _class_oneof_CompanyEvent { - CompanyEvent _subclass_of_class_CompanyEvent_CompanyEvent = 1; - Onboarded _subclass_of_class_CompanyEvent_Onboarded = 2; - } +\`org.acme.hr@1.0.0.Contractor\` "1" *-- "1" \`org.acme.hr@1.0.0.Company\` +\`org.acme.hr@1.0.0.Contractor\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager +\`org.acme.hr@1.0.0.Contractor\` --|> \`org.acme.hr@1.0.0.Person\` +class \`org.acme.hr@1.0.0.Manager\` { +<< participant>> +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports } -message Onboarded { - string employee = 1; +\`org.acme.hr@1.0.0.Manager\` "1" o-- "*" \`org.acme.hr@1.0.0.Person\` : reports +\`org.acme.hr@1.0.0.Manager\` --|> \`org.acme.hr@1.0.0.Employee\` +class \`org.acme.hr@1.0.0.CompanyEvent\` +<< event>> \`org.acme.hr@1.0.0.CompanyEvent\` + +\`org.acme.hr@1.0.0.CompanyEvent\` --|> \`concerto@1.0.0.Event\` +class \`org.acme.hr@1.0.0.Onboarded\` { +<< event>> +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee } -message ChangeOfAddress { - Address newAddress = 1; - string Person = 2; +\`org.acme.hr@1.0.0.Onboarded\` "1" o-- "1" \`org.acme.hr@1.0.0.Employee\` : employee +\`org.acme.hr@1.0.0.Onboarded\` --|> \`org.acme.hr@1.0.0.CompanyEvent\` +class \`org.acme.hr@1.0.0.ChangeOfAddress\` { +<< transaction>> +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person + + \`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\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` --|> \`concerto@1.0.0.Transaction\` ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 1`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 1`] = ` { - "key": "mod.rs", - "value": "#[allow(unused_imports)] -pub mod concerto_1_0_0; -#[allow(unused_imports)] -pub mod concerto; -#[allow(unused_imports)] -pub mod org_acme_hr; -#[allow(unused_imports)] -pub mod utils; + "key": "concerto.csdl", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 2`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 2`] = ` { - "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, + "key": "org.acme.hr.csdl", + "value": " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'openapi' 1`] = ` { - match datetime { - Some(dt) => { - serialize_datetime(&dt, serializer) + "key": "openapi.json", + "value": "{ + "openapi": "3.0.2", + "servers": [], + "info": { + "title": "Generated Open API from Concerto Models", + "version": "1.0.0", + "description": "Create, read, update and delete entities" + }, + "components": { + "schemas": { + "org.acme.hr@1.0.0.State": { + "title": "State", + "description": "An instance of org.acme.hr@1.0.0.State", + "enum": [ + "MA", + "NY", + "CO", + "WA", + "IL", + "CA" + ] + }, + "org.acme.hr@1.0.0.Address": { + "title": "Address", + "description": "An instance of org.acme.hr@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" + }, + "street": { + "type": "string" + }, + "city": { + "type": "string" + }, + "state": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.State" + }, + "zipCode": { + "type": "string" + }, + "country": { + "type": "string" + } + }, + "required": [ + "$class", + "street", + "city", + "zipCode", + "country" + ] + }, + "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@1.0.0.Address" + } + }, + "required": [ + "$class", + "name", + "headquarters" + ] + }, + "org.acme.hr@1.0.0.Department": { + "title": "Department", + "description": "An instance of org.acme.hr@1.0.0.Department", + "enum": [ + "Sales", + "Marketing", + "Finance", + "HR", + "Engineering", + "Design" + ] + }, + "org.acme.hr@1.0.0.Equipment": { + "title": "Equipment", + "description": "An instance of org.acme.hr@1.0.0.Equipment", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Equipment", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Equipment$", + "description": "The class identifier for org.acme.hr@1.0.0.Equipment" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } + }, + "required": [ + "$class", + "serialNumber" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr@1.0.0.LaptopMake": { + "title": "LaptopMake", + "description": "An instance of org.acme.hr@1.0.0.LaptopMake", + "enum": [ + "Apple", + "Microsoft" + ] + }, + "org.acme.hr@1.0.0.Laptop": { + "title": "Laptop", + "description": "An instance of org.acme.hr@1.0.0.Laptop", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Laptop", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Laptop$", + "description": "The class identifier for org.acme.hr@1.0.0.Laptop" + }, + "make": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.LaptopMake" + }, + "serialNumber": { + "type": "string", + "description": "The instance identifier for this type" + } + }, + "required": [ + "$class", + "make", + "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", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Person", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Person$", + "description": "The class identifier for org.acme.hr@1.0.0.Person" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ], + "$decorators": { + "resource": [] + } + }, + "org.acme.hr@1.0.0.Employee": { + "title": "Employee", + "description": "An instance of org.acme.hr@1.0.0.Employee", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Employee", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Employee$", + "description": "The class identifier for org.acme.hr@1.0.0.Employee" + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" + }, + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" + }, + "officeAddress": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" + }, + { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Laptop" + } + ] + } + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr@1.0.0.Contractor": { + "title": "Contractor", + "description": "An instance of org.acme.hr@1.0.0.Contractor", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Contractor", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Contractor$", + "description": "The class identifier for org.acme.hr@1.0.0.Contractor" + }, + "company": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Company" + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "company", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr@1.0.0.Manager": { + "title": "Manager", + "description": "An instance of org.acme.hr@1.0.0.Manager", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Manager", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Manager$", + "description": "The class identifier for org.acme.hr@1.0.0.Manager" + }, + "reports": { + "type": "array", + "items": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" + } + }, + "employeeId": { + "type": "string" + }, + "salary": { + "type": "integer" + }, + "numDependents": { + "type": "integer" + }, + "retired": { + "type": "boolean" + }, + "department": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" + }, + "officeAddress": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + }, + "companyAssets": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" + }, + { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Laptop" + } + ] + } + }, + "manager": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Manager" + }, + "email": { + "type": "string", + "description": "The instance identifier for this type" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "middleNames": { + "type": "string" + }, + "homeAddress": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + }, + "ssn": { + "default": "000-00-0000", + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, + "height": { + "type": "number" + }, + "dob": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "$class", + "employeeId", + "salary", + "numDependents", + "retired", + "department", + "officeAddress", + "companyAssets", + "email", + "firstName", + "lastName", + "homeAddress", + "ssn", + "height", + "dob" + ] + }, + "org.acme.hr@1.0.0.CompanyEvent": { + "title": "CompanyEvent", + "description": "An instance of org.acme.hr@1.0.0.CompanyEvent", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.CompanyEvent", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.CompanyEvent$", + "description": "The class identifier for org.acme.hr@1.0.0.CompanyEvent" + } + }, + "required": [ + "$class" + ] + }, + "org.acme.hr@1.0.0.Onboarded": { + "title": "Onboarded", + "description": "An instance of org.acme.hr@1.0.0.Onboarded", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.Onboarded", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Onboarded$", + "description": "The class identifier for org.acme.hr@1.0.0.Onboarded" + }, + "employee": { + "type": "string", + "description": "The identifier of an instance of org.acme.hr@1.0.0.Employee" + } + }, + "required": [ + "$class", + "employee" + ] + }, + "org.acme.hr@1.0.0.ChangeOfAddress": { + "title": "ChangeOfAddress", + "description": "An instance of org.acme.hr@1.0.0.ChangeOfAddress", + "type": "object", + "properties": { + "$class": { + "type": "string", + "default": "org.acme.hr@1.0.0.ChangeOfAddress", + "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.ChangeOfAddress$", + "description": "The class identifier for org.acme.hr@1.0.0.ChangeOfAddress" + }, + "Person": { + "type": "string", + "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" + } + }, + "required": [ + "$class", + "Person", + "newAddress" + ] + } + } + }, + "paths": { + "/equipment": { + "summary": "Path used to manage the list of equipment.", + "description": "The REST endpoint/path used to list and create zero or more \`equipment\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" + } + } + } + }, + "description": "Successful response - returns an array of \`equipment\` entities." + } + }, + "operationId": "listEquipment", + "summary": "List All Equipment", + "description": "Gets a list of all \`equipment\` entities.", + "tags": [ + "equipment" + ] + }, + "post": { + "requestBody": { + "description": "A new \`equipment\` to be created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful response." + } + }, + "operationId": "createEquipment", + "summary": "Create a Equipment", + "description": "Creates a new instance of a \`equipment\`.", + "tags": [ + "equipment" + ] + } + }, + "/equipment/{serialNumber}": { + "summary": "Path used to manage a single equipment.", + "description": "The REST endpoint/path used to get, update, and delete single instances of a \`equipment\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" + } + } + }, + "description": "Successful response - returns a single \`equipment\`." + } + }, + "operationId": "getEquipment", + "summary": "Get a equipment", + "description": "Gets the details of a single instance of a \`equipment\`.", + "tags": [ + "equipment" + ] + }, + "put": { + "requestBody": { + "description": "Updated \`equipment\` information.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Equipment" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "Successful response." + } + }, + "operationId": "replaceEquipment", + "summary": "Update a equipment", + "description": "Updates an existing \`equipment\`.", + "tags": [ + "equipment" + ] }, - _ => unreachable!(), - } -} - -pub fn deserialize_datetime_option<'de, D>(deserializer: D) -> Result>, D::Error> -where - D: Deserializer<'de>, -{ - match deserialize_datetime(deserializer) { - Ok(result)=>Ok(Some(result)), - Err(error) => Err(error), - } -} - -pub fn deserialize_datetime<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - 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, -{ - let datetime_str = datetime.format("%+").to_string(); - serializer.serialize_str(&datetime_str) -} -", -} -`; - -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 3`] = ` -{ - "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( - rename = "$class", - )] - pub _class: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Asset { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Participant { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Transaction { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Event { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, + "delete": { + "responses": { + "204": { + "description": "Successful response." + } + }, + "operationId": "deleteEquipment", + "summary": "Delete a equipment", + "description": "Deletes an existing \`equipment\`.", + "tags": [ + "equipment" + ] + }, + "parameters": [ + { + "name": "serialNumber", + "description": "A unique identifier for a \`Equipment\`.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/people": { + "summary": "Path used to manage the list of people.", + "description": "The REST endpoint/path used to list and create zero or more \`person\` entities. This path contains a \`GET\` and \`POST\` operation to perform the list and create tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" + } + } + } + }, + "description": "Successful response - returns an array of \`person\` entities." + } + }, + "operationId": "listPeople", + "summary": "List All People", + "description": "Gets a list of all \`person\` entities.", + "tags": [ + "people" + ] + }, + "post": { + "requestBody": { + "description": "A new \`person\` to be created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Successful response." + } + }, + "operationId": "createPerson", + "summary": "Create a Person", + "description": "Creates a new instance of a \`person\`.", + "tags": [ + "people" + ] + } + }, + "/people/{email}": { + "summary": "Path used to manage a single person.", + "description": "The REST endpoint/path used to get, update, and delete single instances of a \`person\`. This path contains \`GET\`, \`PUT\`, and \`DELETE\` operations used to perform the get, update, and delete tasks, respectively.", + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" + } + } + }, + "description": "Successful response - returns a single \`person\`." + } + }, + "operationId": "getPerson", + "summary": "Get a person", + "description": "Gets the details of a single instance of a \`person\`.", + "tags": [ + "people" + ] + }, + "put": { + "requestBody": { + "description": "Updated \`person\` information.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/org.acme.hr@1.0.0.Person" + } + } + }, + "required": true + }, + "responses": { + "202": { + "description": "Successful response." + } + }, + "operationId": "replacePerson", + "summary": "Update a person", + "description": "Updates an existing \`person\`.", + "tags": [ + "people" + ] + }, + "delete": { + "responses": { + "204": { + "description": "Successful response." + } + }, + "operationId": "deletePerson", + "summary": "Delete a person", + "description": "Deletes an existing \`person\`.", + "tags": [ + "people" + ] + }, + "parameters": [ + { + "name": "email", + "description": "A unique identifier for a \`Person\`.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + } + } } - ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 4`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'plantuml' 1`] = ` { - "key": "concerto.rs", - "value": "use serde::{ Deserialize, Serialize }; -use chrono::{ DateTime, TimeZone, Utc }; - -use crate::utils::*; - -#[derive(Debug, Serialize, Deserialize)] -pub struct Concept { - #[serde( - rename = "$class", - )] - pub _class: String, + "key": "model.puml", + "value": "@startuml +title +Model +endtitle +class org.acme.hr_1_0_0.State << (E,grey) >> { + + MA + + NY + + CO + + WA + + IL + + CA } - -#[derive(Debug, Serialize, Deserialize)] -pub struct Asset { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, +org.acme.hr_1_0_0.State --|> concerto_1_0_0.Concept +class org.acme.hr_1_0_0.Address { + + String street + + String city + + State state + + String zipCode + + String country } - -#[derive(Debug, Serialize, Deserialize)] -pub struct Participant { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, +org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state +org.acme.hr_1_0_0.Address --|> concerto_1_0_0.Concept +class org.acme.hr_1_0_0.Company { + + String name + + Address headquarters } - -#[derive(Debug, Serialize, Deserialize)] -pub struct Transaction { - #[serde( - rename = "$class", - )] - pub _class: String, +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters +org.acme.hr_1_0_0.Company --|> concerto_1_0_0.Concept +class org.acme.hr_1_0_0.Department << (E,grey) >> { + + Sales + + Marketing + + Finance + + HR + + Engineering + + Design } - -#[derive(Debug, Serialize, Deserialize)] -pub struct Event { - #[serde( - rename = "$class", - )] - pub _class: String, +org.acme.hr_1_0_0.Department --|> concerto_1_0_0.Concept +class org.acme.hr_1_0_0.Equipment << (A,green) >> { + + String serialNumber } - +org.acme.hr_1_0_0.Equipment --|> concerto_1_0_0.Asset +class org.acme.hr_1_0_0.LaptopMake << (E,grey) >> { + + Apple + + Microsoft +} +org.acme.hr_1_0_0.LaptopMake --|> concerto_1_0_0.Concept +class org.acme.hr_1_0_0.Laptop << (A,green) >> { + + LaptopMake make +} +org.acme.hr_1_0_0.Laptop "1" *-- "1" org.acme.hr_1_0_0.LaptopMake : make +org.acme.hr_1_0_0.Laptop --|> org.acme.hr_1_0_0.Equipment +class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + + String email + + String firstName + + String lastName + + String middleNames + + Address homeAddress + + String ssn + + Double height + + DateTime dob +} +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 --|> concerto_1_0_0.Participant +class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + + String employeeId + + Long salary + + Integer numDependents + + Boolean retired + + Department department + + Address officeAddress + + Equipment[] companyAssets + + 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" *-- "*" 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 +class org.acme.hr_1_0_0.Contractor << (P,lightblue) >> { + + Company company + + Manager manager +} +org.acme.hr_1_0_0.Contractor "1" *-- "1" org.acme.hr_1_0_0.Company : company +org.acme.hr_1_0_0.Contractor "1" o-- "1" org.acme.hr_1_0_0.Manager : manager +org.acme.hr_1_0_0.Contractor --|> org.acme.hr_1_0_0.Person +class org.acme.hr_1_0_0.Manager << (P,lightblue) >> { + + Person[] reports +} +org.acme.hr_1_0_0.Manager "1" o-- "*" org.acme.hr_1_0_0.Person : reports +org.acme.hr_1_0_0.Manager --|> org.acme.hr_1_0_0.Employee +class org.acme.hr_1_0_0.CompanyEvent { +} +org.acme.hr_1_0_0.CompanyEvent --|> concerto_1_0_0.Event +class org.acme.hr_1_0_0.Onboarded { + + Employee employee +} +org.acme.hr_1_0_0.Onboarded "1" o-- "1" org.acme.hr_1_0_0.Employee : employee +org.acme.hr_1_0_0.Onboarded --|> org.acme.hr_1_0_0.CompanyEvent +class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + + Person Person + + 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 --|> concerto_1_0_0.Transaction +@enduml ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 5`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'protobuf' 1`] = ` { - "key": "org_acme_hr.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)] - MA, - #[allow(non_camel_case_types)] - NY, - #[allow(non_camel_case_types)] - CO, - #[allow(non_camel_case_types)] - WA, - #[allow(non_camel_case_types)] - IL, - #[allow(non_camel_case_types)] - CA, -} + "key": "org.acme.hr.v1_0_0.proto", + "value": "syntax = "proto3"; -#[derive(Debug, Serialize, Deserialize)] -pub struct Address { - #[serde( - 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", - )] - pub country: String, -} +package org.acme.hr.v1_0_0; -#[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, +import "google/protobuf/timestamp.proto"; + +enum State { + State_CA = 0; + State_CO = 1; + State_IL = 2; + State_MA = 3; + State_NY = 4; + State_WA = 5; } -#[derive(Debug, Serialize, Deserialize)] -pub enum Department { - #[allow(non_camel_case_types)] - Sales, - #[allow(non_camel_case_types)] - Marketing, - #[allow(non_camel_case_types)] - Finance, - #[allow(non_camel_case_types)] - HR, - #[allow(non_camel_case_types)] - Engineering, - #[allow(non_camel_case_types)] - Design, +message Address { + string city = 1; + string country = 2; + optional State state = 3; + string street = 4; + string zipCode = 5; } -#[derive(Debug, Serialize, Deserialize)] -pub struct Equipment { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "serialNumber", - )] - pub serial_number: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, +message Company { + Address headquarters = 1; + string name = 2; } -#[derive(Debug, Serialize, Deserialize)] -pub enum LaptopMake { - #[allow(non_camel_case_types)] - Apple, - #[allow(non_camel_case_types)] - Microsoft, +enum Department { + Department_Design = 0; + Department_Engineering = 1; + Department_Finance = 2; + Department_HR = 3; + Department_Marketing = 4; + Department_Sales = 5; } -#[derive(Debug, Serialize, Deserialize)] -pub struct Laptop { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "make", - )] - pub make: LaptopMake, - - #[serde( - rename = "serialNumber", - )] - pub serial_number: String, - - #[serde( - rename = "$identifier", - )] - pub _identifier: String, +message _Subclasses_of_class_Equipment { + oneof _class_oneof_Equipment { + Laptop _subclass_of_class_Equipment_Laptop = 1; + } } -#[derive(Debug, Serialize, Deserialize)] -pub struct Person { - #[serde( - 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 = "$identifier", - )] - pub _identifier: String, +enum LaptopMake { + LaptopMake_Apple = 0; + LaptopMake_Microsoft = 1; } -#[derive(Debug, Serialize, Deserialize)] -pub struct Employee { - #[serde( - 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 = "$identifier", - )] - pub _identifier: String, +message Laptop { + LaptopMake make = 1; + string serialNumber = 2; +} + +message _Subclasses_of_class_Person { + oneof _class_oneof_Person { + Contractor _subclass_of_class_Person_Contractor = 1; + Employee _subclass_of_class_Person_Employee = 2; + Manager _subclass_of_class_Person_Manager = 3; + } +} + +message Employee { + repeated _Subclasses_of_class_Equipment companyAssets = 1; + Department department = 2; + google.protobuf.Timestamp dob = 3; + string email = 4; + string employeeId = 5; + string firstName = 6; + double height = 7; + Address homeAddress = 8; + 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; } -#[derive(Debug, Serialize, Deserialize)] -pub struct Contractor { - #[serde( - 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 = "$identifier", - )] - pub _identifier: String, +message _Subclasses_of_class_Employee { + oneof _class_oneof_Employee { + Employee _subclass_of_class_Employee_Employee = 1; + Manager _subclass_of_class_Employee_Manager = 2; + } } -#[derive(Debug, Serialize, Deserialize)] -pub struct Manager { - #[serde( - 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 = "$identifier", - )] - pub _identifier: String, +message Contractor { + Company company = 1; + google.protobuf.Timestamp dob = 2; + string email = 3; + string firstName = 4; + double height = 5; + Address homeAddress = 6; + string lastName = 7; + optional string manager = 8; + optional string middleNames = 9; + string ssn = 10; } -#[derive(Debug, Serialize, Deserialize)] -pub struct CompanyEvent { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, +message Manager { + repeated _Subclasses_of_class_Equipment companyAssets = 1; + Department department = 2; + google.protobuf.Timestamp dob = 3; + string email = 4; + string employeeId = 5; + string firstName = 6; + double height = 7; + Address homeAddress = 8; + 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; } -#[derive(Debug, Serialize, Deserialize)] -pub struct Onboarded { - #[serde( - rename = "$class", - )] - pub _class: String, - - #[serde(rename = "employee")] - pub employee: Employee, - - #[serde( - rename = "$timestamp", - serialize_with = "serialize_datetime", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, +message CompanyEvent { } -#[derive(Debug, Serialize, Deserialize)] -pub struct ChangeOfAddress { - #[serde( - 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", - deserialize_with = "deserialize_datetime", - )] - pub _timestamp: DateTime, +message _Subclasses_of_class_CompanyEvent { + oneof _class_oneof_CompanyEvent { + CompanyEvent _subclass_of_class_CompanyEvent_CompanyEvent = 1; + Onboarded _subclass_of_class_CompanyEvent_Onboarded = 2; + } +} + +message Onboarded { + string employee = 1; +} + +message ChangeOfAddress { + Address newAddress = 1; + string Person = 2; } ", @@ -8982,11 +8979,8 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IState | -IAddress | -ICompany | -IDepartment | -ILaptopMake; +export type ConceptUnion = IAddress | +ICompany; export interface IAsset extends IConcept { $identifier: string;