Backend - REST API, JSON
POST
vs PATCH
vs PUT
POST
is used when client is sending new data and server creates a new resource.
PUT
is used when client is sending data. When resource already exists, it is being updated. If no resource exists, it is being created.
PATCH
is used when client is sending updated data of a resource.
JSON Schema
Here (or on Github and there is example response) you can find a good example how to define JSON Schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"education": {
"items": {
"properties": {
"is_current": ["boolean", "null"],
"degree": {
"type": ["string", "null"]
},
"end_date": {
"type": ["string", "null"]
},
"locations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"continent": {
"type": ["string", "null"]
},
"country": {
"type": ["string", "null"]
},
"geo": {
"type": ["string", "null"]
},
"type": {
"type": ["string", "null"]
},
"is_primary": {
"type": ["null", "boolean"]
},
"locality": {
"type": ["string", "null"]
},
"name": {
"type": ["string", "null"]
},
"po_box": {
"type": ["string", "null"]
},
"postal_code": {
"type": ["string", "null"]
},
"region": {
"type": ["string", "null"]
},
"street_address": {
"type": ["string", "null"]
}
}
}
},
"majors": {
"type": "array",
"items": {
"type": "string"
}
},
"degrees": {
"type": "array",
"items": {
"type": "string"
}
},
"minors": {
"type": "array",
"items": {
"type": "string"
}
},
"school": {
"type": "object",
"properties": {
"location": {
"type": ["string", "null"]
},
"name": {
"type": ["string", "null"]
},
"website": {
"type": ["string", "null"]
},
"profiles": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"start_date": {
"type": ["string", "null"]
}
}
},
"type": "array"
},
"emails": {
"type": "array",
"items": {
"type": "object",
"properties": {
"address": {
"type": "string"
},
"is_primary": {
"type": ["null", "boolean"]
},
"type": {
"type": ["string", "null"]
},
"domain": {
"type": ["string", "null"]
},
"local": {
"type": ["string", "null"]
}
}
}
},
"industries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"is_primary": {
"type": ["null", "boolean"]
},
"name": {
"type": "string"
}
}
}
},
"experience": {
"items": {
"properties": {
"is_current": ["boolean", "null"],
"company": {
"type": "object",
"properties": {
"industry": {
"type": ["string", "null"]
},
"location": {
"type": ["string", "null"]
},
"name": {
"type": ["string", "null"]
},
"size": {
"type": ["string", "null"]
},
"website": {
"type": ["string", "null"]
},
"profiles": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"end_date": {
"type": ["string", "null"]
},
"locations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"continent": {
"type": ["string", "null"]
},
"country": {
"type": ["string", "null"]
},
"geo": {
"type": ["string", "null"]
},
"type": {
"type": ["string", "null"]
},
"is_primary": {
"type": ["null", "boolean"]
},
"locality": {
"type": ["string", "null"]
},
"name": {
"type": ["string", "null"]
},
"po_box": {
"type": ["string", "null"]
},
"postal_code": {
"type": ["string", "null"]
},
"region": {
"type": ["string", "null"]
},
"street_address": {
"type": ["string", "null"]
}
}
}
},
"start_date": {
"type": ["string", "null"]
},
"title": {
"type": "object",
"properties": {
"functions": {
"type": "array",
"items": {
"type": ["string", "null"]
}
},
"levels": {
"type": "array",
"items": {
"type": ["string", "null"]
}
},
"name": {
"type": ["string", "null"]
}
}
}
}
},
"type": "array"
},
"interests": {
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"type": "array"
},
"locations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"continent": {
"type": ["string", "null"]
},
"country": {
"type": ["string", "null"]
},
"geo": {
"type": ["string", "null"]
},
"type": {
"type": ["string", "null"]
},
"is_primary": {
"type": ["null", "boolean"]
},
"locality": {
"type": ["string", "null"]
},
"name": {
"type": ["string", "null"]
},
"po_box": {
"type": ["string", "null"]
},
"postal_code": {
"type": ["string", "null"]
},
"region": {
"type": ["string", "null"]
},
"street_address": {
"type": ["string", "null"]
}
}
}
},
"names": {
"items": {
"type": "object",
"properties": {
"clean": {
"type": ["string", "null"]
},
"first_name": {
"type": ["string", "null"]
},
"is_primary": {
"type": ["boolean", "null"]
},
"last_name": {
"type": ["string", "null"]
},
"middle_name": {
"type": ["string", "null"]
},
"name": {
"type": ["string", "null"]
},
"pedigree": {
"type": ["string", "null"]
},
"suffix": {
"type": ["string", "null"]
},
"title": {
"type": ["string", "null"]
}
}
},
"type": "array"
},
"phone_numbers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"E164": {
"type": ["string", "null"]
},
"area_code": {
"type": ["string", "null"]
},
"country_code": {
"type": ["string", "null"]
},
"extension": {
"type": ["string", "null"]
},
"is_primary": {
"type": ["null", "boolean"]
},
"national_number": {
"type": ["string", "null"]
},
"number": {
"type": "string"
},
"type": {
"type": ["string", "null"]
}
}
}
},
"photos": {
"items": {
"type": "object",
"properties": {
"source": {
"type": ["string", "null"]
},
"url": {
"type": "string"
}
}
},
"type": "array"
},
"profiles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"aliases": {
"type": "array",
"items": {
"type": "string"
}
},
"ids": {
"type": "array",
"items": {
"type": "string"
}
},
"clean": {
"type": ["string", "null"]
},
"is_active": {
"type": ["null", "boolean"]
},
"network": {
"type": ["string", "null"]
},
"url": {
"type": ["string", "null"]
},
"username": {
"type": ["string", "null"]
}
}
}
},
"skills": {
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"type": "array"
},
"websites": {
"items": {
"type": "object",
"properties": {
"is_primary": {
"type": ["boolean", "null"]
},
"type": {
"type": ["string", "null"]
},
"url": {
"type": "string"
},
"domain": {
"type": "string"
}
}
},
"type": "array"
}
}
}