Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme Test blueprint #13

Closed
wants to merge 2 commits into from
Closed

Theme Test blueprint #13

wants to merge 2 commits into from

Conversation

bph
Copy link
Collaborator

@bph bph commented Apr 11, 2024

It uses the a11y test content as well as the content from the theme team.

Would still need to figure out what to do with the images in the content.
And what are the correct steps are now.
The schema, the documentation, and the source code are not yet in synch

@adamziel
Copy link
Contributor

Would still need to figure out what to do with the images in the content.

That's the problem explored in #6. I'd love to solve it sooner than later.

And what are the correct steps are now.

One option is to merge this PR as it is since it references the "official" community assets that may fluctuate over time.

To include the images in this PR, we'll need a new tool like "WXR to zip" that would accept a WXR export, pull all the images assets etc, and package them into something we could ship in a PR.

The schema, the documentation, and the source code are not yet in synch

What do you mean?

@bph bph closed this by deleting the head repository Apr 12, 2024
@bph
Copy link
Collaborator Author

bph commented Apr 13, 2024

reimic pushed a commit to reimic/blueprints-library-ci that referenced this pull request Jun 11, 2024
…ma (#23)

Solves the Blueprint parsing problem as follows:

* JSON Schema is the source of truth for the Blueprint data structure
* Model classes are generated from JSON Schema
* Input Validation is done against the JSON Schema
* Mapping validated input into model instances is indirectly done based on the JSON Schema

## Summary of the approach

We use [Janephp](https://github.com/janephp/janephp/) to infer the PHP model class structure from the JSON schema

We then use Jane's output to generate PHP code using [Nette PHP generator](https://github.com/nette/php-generator):

* Model classes
* Interfaces for groups of related classes: `StepDefinitionInterface`, `ResourceDefinitionInterface`.
* Interface resolution map for the [JsonMapper library](https://jsonmapper.net/).
* PHP docstrings with more accurate types than Jane to guide the mapping process

From there, the data pipeline looks as follows:

1. Parse raw JSON
2. Validate it with Opis
3. Map it into PHP models using JsonMapper

Or, if you're consuming the PHP API directly:

1. Create Model instances
2. Validate them with Opis

## Remaining work

- [ ] Solve merge conflicts

## Rationale

Parsing and mapping JSON [in TypeScript is a simple problem, but in PHP it's surprisingly involved](WordPress/blueprints#13 (comment)). This PR combines three previously explored approaches into a single pipeline:

* WordPress/blueprints#17
* WordPress/blueprints#19
* WordPress/blueprints#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants