c74015c5cb
* add: updated shipstation copy to reflect global presence * changelogs |
||
---|---|---|
.. | ||
bin | ||
bundles | ||
changelog | ||
schemas | ||
src | ||
tests | ||
README.md | ||
changelog.md | ||
composer.json | ||
composer.lock | ||
package.json | ||
phpunit.xml |
README.md
Remote Specification Validation
Installation
composer require woocommerce/remote-specs-validation
Available Schemas
Filename | Endpoint | Bundle |
---|---|---|
remote-inbox-notification.json | https://woocommerce.com/wp-json/wccom/inbox-notifications/2.0/notifications.json | remote-inbox-notification |
payment-gateway-suggestions.json | https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/suggestions.json | payment-gateway-suggestions |
obw-free-extensions.json | https://woocommerce.com/wp-json/wccom/obw-free-extensions/4.0/extensions.json | obw-free-extensions |
wc-pay-promotions.json | https://woocommerce.com/wp-json/wccom/payment-gateway-suggestions/2.0/payment-method/promotions.json | wc-pay-promotions |
shipping-partner-suggestions.json | https://woocommerce.com/wp-json/wccom/shipping-partner-suggestions/2.0/suggestions.json | shipping-partner-suggestions |
Working with Schema
If it's your first time working with JSON Schema, we highly recommend reading https://json-schema.org/learn/getting-started-step-by-step first.
- Open a schema file from
schemas
directory. - Make changes.
- Run
./bin/build schemas/:name-of-schema-file
- Bundled schema file will be saved in
bundles
directory.
Validation Examples
use Automattic\WooCommerce\Tests\RemoteSpecsValidation\RemoteSpecValidator;
$validator = RemoteSpecValidator::create_from_bundle( 'remote-inbox-notification' );
$spec = json_decode( file_get_contents(":your-remote-inbox-noficiation-json") );
$result = $validator->validate( $spec );
if ( !$result->is_valid() ) {
var_dump( $result->get_errors() );
} else {
var_dump('everyting looks good!');
}