Skip to main content
Last updated: 31 Oct 2024

publishing-api: Adding a new content schema

Create a file in formats named after your schema with a jsonnet extension. Eg for a case_study you'd create formats/case_study.jsonnet

With the following contents:

(import "shared/default_format.jsonnet") + {
}

You can then use the contents of the formats/_example.jsonnet as the basis of what to put into the file.

Once you have completed these file add the new format to allowed_document_types.yml. You can generate the corresponding schemas with the rake task.

Sample PR adding a new content schema

Examples

Any new schema should also ship with a set of curated examples. These examples will be validated against the schema and can also be used by the corresponding frontend applications to verify that it can render examples of the schema. These examples should be added to the examples/FORMAT_NAME/frontend folder.

Ensure new content schema text can be parsed by Content Data API

To ensure new content schema text can be parsed by Content Data API, it needs to be added to an appropriate Edition Content Parser or a new praser should be created. This ensures that content quality metrics such as word count or reading time are available in Content Data.

Example of adding a new content schema to the Content Body parser.

Failing to do so, will cause Etl::Edition::Content::Parser::InvalidSchemaError in Content Data API but basic metrics will still be available in Content Data.