Property defaulting to `required` and support `optional` using SchemaProperty in property list?
Sajjon opened this issue · 2 comments
Sajjon commented
Right now there is a code duplication in the specs, e.g. take a look at user.json
example, where almost all property names occurs inside "properties"
dictionary and also inside the "required"
array.
Maybe whether or not a property is required/optional information can be included in the SchemaProperty? So for user.json
it would change from:
{
"title": "User",
"type": "object",
"description": "Definition of a User",
"identifier": "id",
"properties": {
"id": {"type": "integer"},
"full_name": {"type": "string"},
"email": {"type": "string"},
"timezone": {"type": "string"},
"current_company_id": {"type": "integer"},
"created_at": {"type": "string", "format": "date"},
"companies": {
"type": "array",
"items": {"$ref": "company.json"}
},
"avatar": {"$ref": "avatar.json"}
},
"required": ["id", "full_name", "email", "current_company_id", "created_at", "companies", "avatar"]
}
to:
{
"title": "User",
"type": "object",
"description": "Definition of a User",
"identifier": "id",
"properties": {
"id": {"type": "integer"},
"full_name": {"type": "string"},
"email": {"type": "string"},
"timezone": {"type": "string", "optional": true },
"current_company_id": {"type": "integer"},
"created_at": {"type": "string", "format": "date"},
"companies": {
"type": "array",
"items": {"$ref": "company.json"}
},
"avatar": {"$ref": "avatar.json"}
}}
Without any code duplication! Or am I missing something crucial here?
hebertialmeida commented
So, this is following the JSON-Schema specs http://json-schema.org/examples.html
Sajjon commented
@hebertialmeida Okay thanks! I guess I do not like the json-schema format then :D