Skip to content

Define the structure of a Schema with a json-schema.org #134

@psrpinto

Description

@psrpinto

A Schema makes it possible for Try WordPress to be able to work with any type of source data (from hereon referred to as Subject, e.g. blog post, page, product, etc), without requiring any changes to the code. Adding support for a new Subject type should be a matter of just supplying a new Schema for that subject type.

A Schema is a JSON file that exists under the schemas/ directory at the root of the repo. The schema of a blog post would look something like the following:

Note that more complex field types will exist in the future, like array. For the time being those are not being considered.

// ./schemas/blog-post.json
{
    "title": "Blog Post",
    "postType": "post"
    "fields": {
        "title": {
            "type": "text"
        },
        "date": {
            "type": "date"
        },
        "content": {
            "type": "html"
        }
    }
}

Additionally, there is a JSON Schema that specifies the format of the JSON file of a Schema.

There should be a script that validates all schemas under schemas/ using the JSON Schema. The script must also validate that there are no two schemas with the same postType.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions