One-to-one relationships in the schema configuration files
When you configure a schema, you typically modify the following files:
- The schema extension file: This file specifies extensions for two schemas - one for the parent and one for the child.
- The mapping extension file: This file specifies extensions for two mappers - one for the parent and one for the child.
- The updater extension file: This file specifies extensions for two updaters - one for the parent and one for the child.
Filename | Guidewire Studio node |
---|---|
<API>_ext-1.0.schema.json |
integration -> schemas -> ext -> <API>.v1 |
<API>_ext-1.0.mapping.json |
integration -> mappers -> ext -> <API>.v1 |
<API>_ext-1.0.updater.json |
integration -> updaters -> ext -> <API>.v1 |
The schema extension file
Each schema extension file for every API contains a definitions
section.
In the base configuration, this section is typically blank. You can add the name of one
or more schemas to the definitions
section. In each schema, you can
define a properties
section, which lists one or more properties defined
for the schema.
For a one-to-one relationship, you must add or modify two schema definitions:
- The parent schema definition must have a property that references the child schema
definition. This property must specify a
$ref
. - You must also add a new schema definition for the child that specifies all the
properties to be inlined and a
type
for each property.
The parent schema
In the schema extension file, if the parent schema is not already present, then you
must add it to the definitions
section, and you must add a child
properties
section.
You must define the one-to-one property. The title and description attributes are
optional. The $ref
property is required and it must be set to
"#/definitions/<nameOfChildSchema>"
.
For example, the following defines an activityLegalInfo_Ext
property
in the Activity
schema.
"definitions": {
"Activity": {
"properties": {
...
"activityLegalInfo_Ext": {
"title": "ActivityLegalInfo_Ext",
"description": "One-to-one association to ActivityLegalInfo_Ext",
"$ref": "#/definitions/ActivityLegalInfo_Ext"
}
}
},
The child schema
In the schema definition file, you must add the new schema definition to the
definitions
section for the child. You must add a
properties
section to that definition. Then you must add the
following properties:
- A read-only
id
property whose type isstring
. - One property declaration for each field in the one-to-one child that is to be exposed to Cloud API.
For example, the following defines an ActivityLegalInfo_Ext
schema,
with three properties: id
, legalCaseNumber
, and
legalReviewDate
.
"definitions": {
...
"ActivityLegalInfo_Ext": {
"properties": {
"id": {
"title": "ID",
"description": "Object ID",
"type": "string",
"readOnly": true
},
"legalCaseNumber": {
"title": "LegalCaseNumber",
"description": "Legal case number",
"type": "string"
},
"legalReviewDate": {
"title": "LegalReviewDate",
"description": "Legal review date",
"type": "string",
"format": "date-time"
}
}
}
The inline child properties are typically scalars, compound datatypes, or foreign keys. For more information on how to configure schemas for these type of properties, see:
The mapping extension file
Each mapping extension file for every API contains a mappers
section. In
the base configuration, this section is typically blank. You can add the name of one or
more schemas to the mappers
section. In each schema, you can define a
properties
section, which lists one or more properties defined in
the schema.
For a one-to-one relationship, you must add or modify two mappers:
- The parent mapper must specify the path mapping for the one-to-one property that points to the child.
- You must also add a new mapper for the child that specifies the path mappings for the inline child properties.
The parent mapper
In the mapping file, if the parent mapper is not already present, then you must add
it to the mappers
section, and you must add a child
properties
section. For the one-to-one field, you must specify
the path
and mapper
.
For example, the following defines an activityLegalInfo_Ext
mapper
for the Activity
schema.
"mappers": {
"Activity": {
"properties": {
...,
"activityLegalInfo_Ext": {
"path": "Activity.ActivityLegalInfo_Ext",
"mapper": "#/mappers/ActivityLegalInfo_Ext"
}
}
},
The child mapper
In the mapping file, you must add the child
mapper to the mappers
section with the following properties:
schemaDefinition
- set to the name of the child schemaroot
- set toentity.<nameOfChildEntity>
Then, you must add a properties
section to that mapper with the
following properties:
- A read-only
id
property whose path is typically set to"<childEntity>.RestId"
. - One property for each inline child field. For each property, you must specify
its
path
.
For example, the following defines the mapper for
ActivityLegalInfo_Ext
, with three properties:
id
, legalCaseNumber
, and
legalReviewDate
.
"mappers": {
...
"ActivityLegalInfo_Ext": {
"schemaDefinition": "ActivityLegalInfo_Ext",
"root": "entity.ActivityLegalInfo_Ext",
"properties": {
"id": {
"path": "ActivityLegalInfo_Ext.RestId"
},
"legalCaseNumber": {
"path": "ActivityLegalInfo_Ext.LegalCaseNumber"
},
"legalReviewDate": {
"path": "ActivityLegalInfo_Ext.LegalReviewDate"
}
}
}
}
The inline child properties are typically scalars, compound
datatypes, or foreign keys. For more information on how to configure mappers for these
type of properties, see:The updater extension file
Each updater extension file for every API contains a updaters
section.
In the base configuration, this section is typically blank. You can add the name of one
or more schemas to the updaters
section. In each schema, you can define
a properties
section, which lists one or more properties defined in the
schema.
For a one-to-one relationship, you must add or modify two updaters:
- The parent updater must specify the path mapping for the one-to-one property that points to the child.
- You must also add a new updater for the child that specifies the path mappings for the inline child properties.
The parent updater
In the updater file, if the parent is not already present, then you must add it to
the updaters
section, and you must add a child
properties
section. For the one-to-one field, you must specify
the following attributes:
path
- set to<root>.<foreignKeyToChild>
create
- set tonew <childEntity>(<root>)
updateRef
- set to#/updaters/<childUpdater>
For example, the following defines an activityLegalInfo_Ext
updater
for the Activity
schema.
"updaters": {
"Activity": {
"properties": {
...
"activityLegalInfo_Ext": {
"path": "Activity.ActivityLegalInfo_Ext",
"create": "new ActivityLegalInfo_Ext(Activity)",
"updaterRef": "#/updaters/ActivityLegalInfo_Ext"
}
}
},
...
The child updater
In the updater file, you must add the child updater to the updaters
section with the following properties:
schemaDefinition
- set to the name of the child schemaroot
- set toentity.<nameOfChildEntity>
Then, you must add a properties
section to that updater with one
property for each inline field that is to be writeable from Cloud API. For each
property, you must specify its path
.
For example, the following defines the updater for the
ActivityLegalInfo_Ext
schema, with two properties:
legalCaseNumber
and legalReviewDate
.
"updaters": {
...,
"ActivityLegalInfo_Ext": {
"schemaDefinition": "ActivityLegalInfo_Ext",
"root": "entity.ActivityLegalInfo_Ext",
"properties": {
"legalCaseNumber": {
"path": "ActivityLegalInfo_Ext.LegalCaseNumber"
},
"legalReviewDate": {
"path": "ActivityLegalInfo_Ext.LegalReviewDate"
}
}
}
}
The inline child properties are typically scalars, compound datatypes, or foreign keys. For more information on how to configure updaters for these type of properties, see: