Common entity schema
http://developers.ros.gov.uk/schema/common/schema.json
Overview
The following is a collection of entities and formats which are inspired, but not necessarily directly lifted from our existing applications.
It's recommended to use them in the following ways:
- When representing the same kind of data, we should where possible use the same structure
- The following should be taken as 'super' cases of the items we need. Not every field will be required in every setting. We should however attempt to use degenerate versions of the existing structures.
- If a structure is related, but doesn't seem to quite fit a new use case, it's a good time to bring it up for discussion.
Primitives
The schema provides a number of non domain specific entities for use in other schema.
General
- Coded value - items in controlled lists of values
- Contact details - for email addresses, phone numbers etc.
- Structured address - an address with items like
street
rather thanline1
,line2
People and Companies
We provide the following elements for representing people and companies:
- Person - a person with a person name
- Company - a company with a company name
- Party - either a person or company distinguished by type
- Agent - a person with a company
Formats
This schema provides a number of distinct formats which you can reference to prevent you from having to repeat yourself in your schema.
You can include these by using a JSON schema reference:
{
"type": "object",
"properties": {
"myFasNumber": {
"$ref": "http://developers.ros.gov.uk/schema/common/schema.json#/fasNumber"
}
}
}
Other formats are available in domain specific schema.
Patterns
The schema provides a few examples of common patterns used in RoS schema.
These are not intended to be directly referenced, but to provide examples and some explanation of some patterns you may encounter.
#/ - Common entity schema
A collection of common entities and formats
The root element here is nonsense. You wouldn't want to validate a data structure against the root schema; this schema is only intended to be used to reference the individual entities described in it.
{
"$schema": "http://json-schema.org/schema#",
"id": "http://developers.ros.gov.uk/schema/common/schema.json",
"title": "Common entity schema",
"description": "A collection of common entities and formats"
}
#/agent - Agent
An agent is a person who works for a company. Although both the agent and their company are full person and company entities, in most use cases, only a small number of the possible fields are actually expected or used by the application.
Typically this will be a solicitor in a Land Registry context. Many different solicitors may work for the same company and therefore may share the same company details.
Field notes
{
"title": "Agent",
"allOf": [
{"$ref": "#/person"},
{
"properties": {
"company": {"$ref": "#/company"}
},
"required": ["company"]
}
]
}
{
"type": {"code": "natural"},
"name": {
"prefix": {
"code": "doctor",
"prettyPrint": "Doctor"
},
"first": "Jane",
"last": "Smith",
"prettyPrint": "Doctor Jane Smith"
},
"contact": {
"phoneNumber": "0123 123 1111",
"emailAddress": "bobb@bobo.bob"
},
"address" : {
"name" : "A house",
"postcode" : "EH56 0QY",
"prettyPrint": "A house, 23, 3F1, West Bromlinton St., Edinburgh, INVERURIE, UK, EH56 0QY, Lothian"
},
"company": {
"type": {"code": "non_natural"},
"name": {
"prefix": {
"code": "the",
"prettyPrint": "The"
},
"company": "Solicitor Co.",
"prettyPrint": "The Solicitor Co."
}
},
"prettyPrint": "Doctor Jane Smith\nThe Solicitor Co.\nA house, 23, 3F1, West Bromlinton St., Edinburgh, INVERURIE, UK, EH56 0QY, Lothian"
}
#/codedValue - Coded value
The common format used to represent all coded lists of values.
Discovering the right values
Whenever you see this entity, you should always see it accompanied by a format telling you what values are expected.
In the following example we can see a well formed reference to a coded value:
{
"allOf": [
{"$ref": "http://developers.ros.gov.uk/schema/common/schema.json#/codedValue"},
{"property": {
"code": {"format": "ref:lr/application/type"}
}}
]
}
It has:
- An
allOf
which states that this is acodedValue
- An additional schema which sets the reference format
- The format specified begins with
ref:
telling you this is a value from the Reference API - The format after the colon tells you the path to retrieve the coded list in the Reference API
- It could have also included an enum if the list is small and static
Using this entity without a reference format is considered an error.
{
"title": "Coded value",
"type": "object",
"additionalProperties": false,
"properties": {
"code": {"type": "string"},
"prettyPrint": {
"type": "string",
"pattern": "\\S+",
"minLength": 1
}
},
"required": ["code"]
}
{
"code": "tp",
"prettyPrint": "Transfer of part"
}
#/codedValueOrOther - Coded value or other value by providing prettyPrint
The common format used to represent coded lists of values where custom values are allowed.
This entity extends coded value with the option of specifying the other
code,
in which case the prettyPrint
value must be sent and will be read by the server side.
Using this entity without a reference format is considered an error.
{
"title": "Coded value or other value by providing prettyPrint",
"allOf": [
{"$ref": "#/codedValue"},
{
"anyOf": [
{
"properties": {
"code": {"not": {"enum": ["other"]}}
}
},
{
"properties": {
"code": {"enum": ["other"]}
},
"required": ["prettyPrint"]
}
]
}
]
}
{
"code": "other",
"prettyPrint": "Full description of what this is"
}
#/company - Company
Represents a non-natural person (a company or organisation).
In general non_natural_uk
companies are a subset of non_natural
companies. Therefore for applications where the distinction is irrelevant (such as in the agent) it is perfectly acceptable to set the type to non_natural
.
Field notes
For Non-UK companies:
- The
allocatedNumber
is optional
For UK companies:
- The
ukCompanyNumber
is mandatory - As the
ukCompanyNumber
is a more specific case of anallocatedNumber
, UK companies should set both (the same)
{
"title": "Company",
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"allOf":[
{"$ref": "#/codedValue"},
{
"properties": {
"code": {
"type": "string",
"format": "ref:core/party/type",
"enum": ["non_natural", "non_natural_uk"]
}
}
}
]
},
"contact": {"$ref": "#/contactDetails"},
"address": {"$ref": "#/structuredAddress"},
"name": {"$ref": "#/companyName"},
"reference": {
"type": "object",
"additionalProperties": false,
"properties": {
"ukCompanyNumber": {
"type": "string",
"minLength": 1,
"pattern": "\\S+"
},
"allocatedNumber": {"type": "string"}
}
},
"prettyPrint": {"type": "string"}
},
"required": ["type", "name"]
}
{
"type": {"code": "non_natural_uk"},
"name": {
"prefix": {
"code": "the",
"prettyPrint": "The"
},
"company": "Magic Co.",
"prettyPrint": "The Magic Co."
},
"contact": {
"phoneNumber": "0123 123 1111",
"emailAddress": "bobb@bobo.bob"
},
"address" : {
"name" : "A house",
"postcode" : "EH56 0QY",
"prettyPrint": "A house, 23, 3F1, West Bromlinton St., Edinburgh, INVERURIE, UK, EH56 0QY, Lothian"
},
"reference": {
"ukCompanyNumber": "97823475634",
"allocatedNumber": "97823475634"
},
"prettyPrint": "The Magic Co.\nA house, 23, 3F1, West Bromlinton St., Edinburgh, INVERURIE, UK, EH56 0QY, Lothian"
}
#/companyName - Company name
A company name.
Note that the company prefix
unusually references two reference lists:
- If the type of the containing company is
non_natural
the format must beref:core/company/name/prefix
- If the type of the containing company is
non_natural_uk
the format must beref:core/company/name/prefix/uk
You do not need to provide the prettyPrint
fields as these will be automatically created.
{
"title": "Company name",
"type": "object",
"additionalProperties": false,
"properties": {
"prefix": {"allOf": [
{"$ref": "#/codedValue"},
{
"properties": {
"code": {
"anyOf": [
{"format": "ref:core/company/name/prefix"},
{"format": "ref:core/company/name/prefix/uk"}
]
}
}
}]
},
"company": {
"type": "string",
"minLength": 1,
"pattern": "\\S+"
},
"prettyPrint": {"type": "string"}
},
"required": ["company"]
}
{
"prefix": {
"code": "the",
"prettyPrint": "The"
},
"company": "Magic Co.",
"prettyPrint": "The Magic Co."
}
#/contactDetails - Contact details
An entity for containing contact details.
{
"title": "Contact details",
"type": "object",
"additionalProperties": false,
"properties": {
"phoneNumber": {
"type": "string",
"format": "phone",
"minLength": 1,
"pattern": "\\d"
},
"emailAddress": {
"type": "string",
"format": "email",
"minLength": 1
}
}
}
{
"phoneNumber": "0123 123 1111",
"emailAddress": "bobb@bobo.bob"
}
#/currency - Currency
{
"title": "Currency",
"allOf": [
{
"$ref": "#/codedValue"
},
{
"properties": {
"code": {
"enum": [
"gbp"
]
}
}
}
]
}
{
"code": "gbp",
"prettyPrint": "GB - Pound"
}
#/designPattern
Patterns are not referenced in external schema, but represent common patterns and the thinking behind them.
#/designPattern/booleanValues
If you are representing boolean values, the name should always begin with is
, even if this is slightly grammatically awkward.
For example:
isNotAvailable
- If a negation is requiredisWithAttachments
- Where perhapshasAttachments
might be more natural
{
"isValid": true,
"isChecked": false
}
#/designPattern/dateBlock
Dates should be nested into an object which only contains flat key value pairs, where all values are dates in RFC3339 format.
Any time the single key date
is used in any schema, it should refer to a flat object with dates inside.
A schema using the date field in another way would be considered an error
{
"date": {
"created": "1985-04-12T23:20:50Z",
"updated": "1996-12-19T16:39:57Z"
}
}
#/designPattern/prettyPrint
This is more of a practice than a particular schema. The pretty print field is intended to provide a human readable summary of the object at it's level in the hierarchy for just about any object it might be useful for.
As the submitter of data you almost never need to send prettyPrint
. The only counter example is in coded values or other when submitting other
.
- The value is for human benefit, not for automated usage
- The value should be automatically generated from the other fields in the object
- As a result, the value is usually ignored by the back end (and regenerated)
- This relieves people submitting data to the service from having to understand the logic of creating the field
- The result represents the object at the level it is and below (not above, closer to the root)
- There is no generic solution for creating
prettyPrint
strings. They tend to be domain specific (even for the same object type) - It's useful for:
- Making user interfaces
- Debugging
- Inserting merged data into old systems that don't separate different parts of the data
{
"quantity": 3,
"item": {
"size": "LGE",
"category": "MUNI",
"type": {
"code": "HAMMER-P4L",
"prettyPrint": "Ball-peen Hammer"
},
"prettyPrint": "Large Municipal Ball-peen Hammer"
},
"prettyPrint": "3 lots of: Large Municipal Ball-peen Hammer"
}
#/designPattern/referenceBlock
This is a block intended to store references to this block in other systems, but is not intended for the primary entity id.
There's not much to see, basically it's a flat object where the values are interpreted as external references.
{
"reference": {
"agent": "FFE - Susan 2010/10/01",
"lrs": "15FFE0123",
"caseManagement": "108347597234895F"
}
}
#/fasNumber - FAS number
A number used to identify the account to charge for various transactions.
Although the schema states that the format is just four digits, in truth only certain FAS numbers are valid, and each is associated with a particular user.
In addition, certain FAS numbers are associated with certain payment methods (cheque/direct debit), and therefore may be invalid if provided in the wrong context.
{
"title": "FAS number",
"type": "string",
"format": "fasNumber",
"pattern": "^\\d{4}$"
}
"1222"
#/monetaryValue - Monetary Value
{
"title": "Monetary Value",
"type": "object",
"properties": {
"amount": {
"title": "Amount",
"type": "number",
"minimum": 0,
"maximum": 99999,
"multipleOf": 0.01
},
"currency": {
"$ref": "#/currency"
}
},
"required": [
"amount",
"currency"
]
}
{
"amount": 20.00,
"currency": {"code": "gbp"}
}
#/party - Party
Represents a person or company when you don't know which you are going to get.
Parties are either natural or non-natural.
- "Natural people" - are actual individual humans
- "Non-natural people" - are companies and organisations
- UK companies are specifically coded separately from international companies (see company)
The person or company entities are designed to share many fields, so that in many cases they can be treated identically.
Specifically, all parties have:
- A
type
field, which must match the entity type. name.prettyPrint
address
contact
- Contact details
#/person - Person
Represents a natural person (a human).
Although there is only one possible value for type, you still need to supply it to distinguish between a person and a company when used as part of a party). See party for more details of natural and non-natural people.
{
"title": "Person",
"type": "object",
"properties": {
"type": {
"allOf":[
{"$ref": "#/codedValue"},
{
"properties": {
"code": {
"type": "string",
"format": "ref:core/party/type",
"enum": ["natural"]
}
}
}
]
},
"name": {"$ref": "#/personName"},
"contact": {"$ref": "#/contactDetails"},
"address": {"$ref": "#/structuredAddress"},
"prettyPrint": {"type": "string"}
},
"required": ["type"]
}
{
"type": {"code": "natural"},
"name": {
"prefix": {
"code": "lady",
"prettyPrint": "Lady"
},
"first": "Jane",
"last": "Smith",
"prettyPrint": "Lady Jane Smith"
},
"contact": {
"phoneNumber": "0123 123 1111",
"emailAddress": "bobb@bobo.bob"
},
"address" : {
"name" : "A house",
"postcode" : "EH56 0QY",
"town": "Edinburgh",
"prettyPrint": "A house, 23, 3F1, West Bromlinton St., Edinburgh, INVERURIE, UK, EH56 0QY, Lothian"
},
"prettyPrint": "Lady Jane Smith\nA house, 23, 3F1, West Bromlinton St., Edinburgh, INVERURIE, UK, EH56 0QY, Lothian"
}
#/personName - Person name
A person's name.
Field notes
- The prefix includes only formal titles rather than a common titles
- The prefix therefore does not include values like 'Mr'
- There is currently no way of submitting common titles
- Common titles are not used by Registers of Scotland
{
"title": "Person name",
"type": "object",
"additionalProperties": false,
"properties": {
"prefix": {
"allOf":[
{"$ref": "#/codedValue"},
{"properties": {
"code": {"format": "ref:core/person/name/prefix"}
}}
]
},
"first": {"type": "string"},
"middle": {"type": "string"},
"last": {
"type": "string",
"minLength": 1,
"pattern": "\\S+"
},
"prettyPrint": {"type": "string"}
},
"required": ["last"]
}
{
"prefix": {
"code": "lady",
"prettyPrint": "Lady"
},
"first": "Jane",
"middle": "Elizabeth Gurtrude",
"last": "Smith",
"prettyPrint": "Lady Jane Elizabeth Gurtrude Smith"
}
#/structuredAddress - Structured address
This is to store structured addresses where we know which item is which, as opposed to addresses expressed as an array of "lines".
The main address structure is a great deal more fully featured than most applications can accept. It will therefore be up to applications to specify what fields are required or accepted in their specific cases.
Field notes
- As always, no effort should be spent constructing the
prettyPrint
fields, as they are ignored and recalculated by the receiving application. - The country codes are the ISO 3166-1 alpha-2 codes. In the event that you need to supply an uncoded country, you can use the 'ZZ' code (as the code is mandatory), but be aware that many consumers will discard the value in this case.
{
"title": "Structured address",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {"type": "string"},
"number": {"type": "string"},
"subBuilding": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {"type": "string"},
"number": {"type": "string"}
}
},
"locality": {"type": "string"},
"town": {"type": "string"},
"street": {"type": "string"},
"county": {"type": "string"},
"country": {"allOf": [
{"$ref": "#/codedValue"},
{"properties": {
"code": {"format": "ref:core/address/country"}
}}
]},
"postcode": {"type": "string", "format": "postcode"},
"reference" : {
"type": "object",
"additionalProperties": false,
"properties": {
"apr": {"type": "string"},
"uprn": {"type": "string"}
}
},
"cmsAddenda": {
"additionalProperties": false,
"type": "object",
"properties": {
"uprn": {
"type": "number"
},
"northing": {
"type": "number"
},
"easting": {
"type": "number"
},
"coordinateReferenceSystem": {
"type": "string"
}
}
},
"prettyPrint": {"type": "string"}
}
}
{
"name" : "Gordon House",
"number" : "3",
"subBuilding": {
"name": "Garden Flat",
"number": "GF1"
},
"locality" : "Morningside",
"town" : "Edinburgh",
"street" : "Smith St.",
"postcode" : "EH123XX",
"reference" : {
"apr" : "APJL9H857V2432T0EM",
"uprn": "..."
},
"county": "Fife",
"country": {
"code": "GB",
"prettyPrint": "United Kingdom of Great Britain and Northern Ireland"
},
"cmsAddenda" : {
"northing" : 743856.0,
"coordinateReferenceSystem" : "EPSG:27700",
"easting" : 193482.0,
"uprn" : 125783469
},
"prettyPrint": "GF1 Garden Flat, 3 Gordon House, Smith St. Morningside, Edinburgh, EH123A, United Kingdom of Great Britain and Northern Ireland"
}
#/user - User
Represents a user interacting with one of our systems.
Although the username
is simply stated to be a string, only valid usernames will work. The valid usernames will differ from system to system.
{
"title": "User",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {"$ref": "#/personName"},
"username": {"type": "string"},
"email": {"type": "string", "format": "email"}
},
"required": ["username"]
}
{
"name": {
"first": "Berty",
"last": "Testington",
"prettyPrint": "Berty Testington"
},
"username": "testingbe",
"email": "testingbe@example.com"
}