bbc / simorgh

The BBC's Open Source Web Application. Contributions welcome! Used on some of our biggest websites, e.g.
https://www.bbc.com/thai
Other
1.39k stars 219 forks source link

Investigation: extract schema out as common dependency #920

Closed ChrisBAshton closed 5 years ago

ChrisBAshton commented 5 years ago

Is your feature request related to a problem? Please describe. We use Ares fixture data to work locally and render test article pages. But we have no guarantee that we're building against valid fixture data - the data structure from Ares might change and we'd never know, as we're building against an 'unofficial' schema.

The risk is that when the data changes, we're not aware our page is broken until very late in the pipeline (E2E tests or even a production environment).

Describe the solution you'd like A common, shared repository (bbc-blocks-validator?) - under @bbc - that outlines a schema and fixture data and is always in line with the real Ares output. Downstream platforms could use this schema & fixture data to test against locally.

Simorgh already has a schema, which we could use as a starting point.

Optional extra: generate dynamic fixture data from the schema.

Optional extra 2: validate real Ares endpoints against schema.

Isn't a schema constraining? The new Optimo/Ares/Article ideology is one of 'blocks', recursion, and 'anything is possible'. Isn't that at odds with the idea of a schema?

Whilst we can't really have a schema outlining which blocks can appear inside which blocks (anything can be inside anything, really), we can have a schema that describes all possible blocks outputted by Optimo, and the block attributes and attribute types.

Desired outcome A new repository, with a schema & fixture data (copied from / inspired by Simorgh's), and a PR to Simorgh which pulls in said repository as a dependency.

The advantage of the data aspects being extracted out of Simorgh is the single responsibility principle, and increased sense of ownership from Ares & all platforms.

Resources

ChrisBAshton commented 5 years ago

Closed in favour of https://github.com/bbc/articles-validator.