Integration mapping examples
How JSON schemas relate to integration mappings is easiest to see if you view them next to one
another. In the following example are a simple schema named contact-1.0
and the integration mapping that corresponds to it:
|
|
The pieces match up as follows:
- The
schemaNameproperty of the mapping file references the fully-qualified name of the JSON schema file. TheschemaDefinitionproperty within the Address and Contact mappers references definitions within the schema. - The properties on each mapper exactly match the set of schema properties on the associated schema definitions.
- The Address mapper has a root type of
entity.Address. Consequently, all
pathandpredicateexpressions on properties for the Address mapper have the symbol Address available with a type of entity.Address. Similarly, the Contact mapping properties all have the Contact symbol available to their Gosu expressions. - For scalar properties, the
pathexpressions all evaluate to an object type that is compatible with the data type implied by the type/format/x-gw-type on the schema property. The ramifications include the following:Address.addressLine1is aStringAddress.cityis aStringAddress.stateis atypekey.StateContact.displayNameis aStringContact.firstNameis aStringContact.lastNameis aStringContact.subtypeis a typekey.Contact
- For object or object array properties, the path expression returns something that matches the
root type of the referenced mapper, which means the following:
Contact.allAddressesreturns an entity.Address[]Contact.primaryAddressreturns an entity.Address
- The
Contact.firstNameandContact.lastNamemapping properties use a predicate so that thepathexpression will only execute if the Contact is actually a Person. This arrangement allows thepathexpression to be cleaner. The arrangement also avoids awkward ternary expressions.
