Skip to main content

Simple partial example

Partials are schemas that contain just a definitions section. The definitions in a partial can be used in multiple schemas.

This schema snippet is a simple partial definition for a "person" object with string properties for name and address.

Pre-requisites
Link copied!

To use the definitions in this partial, you must create the schema on your hub. Partials are not registered.

How to use
Link copied!

You can use this definition in another schema as follows:

"person":{
"allOf": [
{ "$ref": "https://schema-examples.com/simple-partial#/definitions/person" }
]
}

Simple partial
Link copied!

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema-examples.com/simple-partial",

"definitions": {
"person":{
"title": "person",
"description": "Use this to enter a person's details",
"type": "object",
"properties": {
"name": {
"title": "name",
"description": "Person's name",
"type": "string",
"minLength": 0,
"maxLength": 255
},
"addressline1": {
"title": "addressline1",
"description": "Address Line 1",
"type": "string",
"minLength": 0,
"maxLength": 300
},
"addressline2": {
"title": "addressline2",
"description": "Address Line 2",
"type": "string",
"minLength": 0,
"maxLength": 300
},
"city": {
"title": "City",
"description": "City",
"type": "string",
"minLength": 0,
"maxLength": 100
}

},
"propertyOrder": []
}


}
}

Using partials