The Home for
Magento Excellence

Explore. Discover. Elevate. #magento

162
Modules Tested
99
Ready for Magento 2.4
63
Need Your Help
Stable v0.1.1

Zepgram JsonSchema

zepgram/module-json-schema

Magento 2 module to validate JSON Structures against a given Schema.

23,729
Downloads
Below average
1
GitHub Stars
Below average
6mo ago
Last Release
0
Open Issues
Build Issues
0/3 checks passed

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
PHPStan

Tested on Magento 2.4.8-p3

Recent Test History

Each release is tested against the latest Magento version at that time.

v0.1.1 on Magento 2.4.8-p3
Dec 16, 2025
v0.1.0 on Magento 2.4.7-p4
Feb 15, 2025
v0.1.0 on Magento 2.4.7-p3
Oct 24, 2024
v0.1.0 on Magento 2.4.7-p2
Sep 8, 2024
v0.1.0 on Magento 2.4.7-p2
Sep 7, 2024
v0.1.0 on Magento 2.4.7-p1
Jun 25, 2024

+2 older tests

GitHub Repository
Source code & docs
Packagist
Version history
Issues & Support
Get help or report bugs

Looking for Contributors

Composer installation fails. Your contribution could help the entire Magento community!

Contribute

Share This Module's Status

Zepgram JsonSchema Magento compatibility status badge

README

Loaded from GitHub

Zepgram JsonSchema

A Magento implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Based on https://github.com/justinrainbow/json-schema json schema. For more information about json schema: http://json-schema.org/

Installation

composer require zepgram/module-json-schema
bin/magento module:enable Zepgram_JsonSchema
bin/magento setup:upgrade

Guideline

  1. Add the formatted json-schema in your module, where webservice will be implemented under /etc/schema directory.
  2. Create a Virtual Class of type Zepgram\JsonSchema\Model\Validator and adapt fileName and moduleName parameters.

Example

/etc/di.xml

<virtualType name="HelloWorldValidator" type="Zepgram\JsonSchema\Model\Validator">
    <arguments>
        <argument name="fileName" xsi:type="string">schema/hello-world-service.json</argument>
        <argument name="moduleName" xsi:type="string">Zepgram_HelloWorld</argument>
    </arguments>
</virtualType>

/etc/schema/hello-world-service.json

{
  "type":"array",
  "items":{
    "type":"object",
    "required":[
      "helloId",
      "helloContact"
    ],
    "properties":{
      "helloId":{
        "type":"string",
        "description":"Hello Id"
      },
      "helloContact":{
        "type":"array",
        "items":{
          "type":"object",
          "required":[
            "age",
            "fullName"
          ],
          "properties":{
            "age":{
              "type":"integer",
              "format":"int32",
              "description":"contact age",
              "minimum":-2147483648,
              "maximum":2147483647
            },
            "fullName":{
              "type":"object",
              "required":[
                "firstname",
                "lastname"
              ],
              "properties":{
                "firstname":{
                  "type":"string",
                  "description":"contact firstname"
                }, 
                "lastname":{
                  "type":"string",
                  "description":"contact lastname"
                }
              }
            }
          }
        }
      }
    }
  },
  "$schema":"http://json-schema.org/draft-04/schema#"
}

Open API V3

If your architecture is using open API-V3 to describe web service usage you can convert it to json schema.

  1. Install the node utility: https://github.com/mikunn/openapi2schema
  2. Convert the open api yaml file into JSON: openapi2schema -i my-custom-service.yaml | python -m json.tool | jq '."%end_point%".post.body' > my-custom-service.json where %endpoint% must be replaced by your api endpoint described in yaml file (e.g.: /v1/customEndPoint)

Issues

If you encountered an issue during installation or with usage, please report it on this github repository.

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.

Back to All Modules