-
Notifications
You must be signed in to change notification settings - Fork 47
JSON Schemas: Add SCF_Schema_Builder for field schema composition
#301
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
base: trunk
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #301 +/- ##
============================================
+ Coverage 14.36% 14.46% +0.09%
- Complexity 4386 4397 +11
============================================
Files 286 287 +1
Lines 35270 35320 +50
============================================
+ Hits 5066 5108 +42
- Misses 30204 30212 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a4954d7 to
4e320f1
Compare
ref resolution thereSCF_Schema_Builder for field schema composition
89d843b to
2cad3db
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What
Required for #162.
Adds a
SCF_Schema_Builderclass to handle JSON Schema composition for field type validation.Why
WordPress internal JSON validation uses V4 and doesn't understand JSON Schema
$refor complex schema composition. Field validation requires type-specific rules while sharing:This builder enables strict per-type validation through
oneOfcomposition and extracts the existing$refresolution.How
Extracting schema building logic from abilities classes into a dedicated
SCF_Schema_Builderclass that:$refreferences by inlining definitions for WordPress compatibilityoneOfvariants for each field typeSince WordPress validation doesn't support
allOffor the field composition, what we do here for fields at runtime is:oneOfeach complete field schema.This PR also adds the most basic field schema,
text.schema.json, as the first type-specific schema to validate the composition pipeline.Testing Instructions
vendor/bin/phpunit tests/php/includes/SCFSchemaBuilderTest.php- all 8 tests should passvendor/bin/phpunit- all 404 tests should passcomposer test:phpstan- no errors