PHPackages                             jojo1981/json-schema-asg - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jojo1981/json-schema-asg

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

jojo1981/json-schema-asg
========================

Json schema abstract semantic graph builder

4.2.0(3mo ago)31.3kMITPHPPHP ^8.1CI passing

Since Oct 18Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/jojo1981/json-schema-asg)[ Packagist](https://packagist.org/packages/jojo1981/json-schema-asg)[ RSS](/packages/jojo1981-json-schema-asg/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (12)Used By (0)

JSON Schema ASG builder for PHP
===============================

[](#json-schema-asg-builder-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/c598d281c4d7d04ed6601fa9b0f65416700c7fe166703dbde4b7dafadd9a51cd/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6a6f313938312f6a736f6e2d736368656d612d6173672f762f737461626c65)](https://packagist.org/packages/jojo1981/json-schema-asg)[![Total Downloads](https://camo.githubusercontent.com/847eecb4e1dfcd9275f8e042361d2b5f8676ad4621c930386408d7abbc2897ab/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6a6f313938312f6a736f6e2d736368656d612d6173672f646f776e6c6f616473)](https://packagist.org/packages/jojo1981/json-schema-asg)[![License](https://camo.githubusercontent.com/6cff8bfe39d2a350cdaa21dcfec7133ed12e7bc415cbb157efacdf7bdcd930ba/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6a6f313938312f6a736f6e2d736368656d612d6173672f6c6963656e7365)](https://packagist.org/packages/jojo1981/json-schema-asg)

Author: Joost Nijhuis &lt;&gt;

A PHP Implementation for building an ASG (Abstract semantic graph) from a reference to a `JSON schema file`.
Support for json schemas defined in `JSON` and `YAML`.
Full support for the JSON schema draft 07 specification. More information can be found [here](http://json-schema.org/draft-07/schema).
The ASG is visitable and can be visited by implementing a visitor (Behavioral Design Pattern Visitor).

Purposes of this library are:

- Validate JSON Schemas and give the end user a precise error message about semantically errors
- Transform an ASG into something else. For example generate entity classes from it, generate static validation classes, etc...
- Travers ASG by implementing your own visitor. (implement `Jojo1981\JsonSchemaAsg\Visitor\VisitorInterface`)

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. More information can be found [here](https://json-schema.org).

Installation
------------

[](#installation)

### Library

[](#library)

```
git clone https://github.com/jojo1981/json-schema-asg.git
```

### Composer

[](#composer)

[Install PHP Composer](https://getcomposer.org/doc/00-intro.md)

```
composer require jojo1981/json-schema-asg
```

Implement your own visitor.
---------------------------

[](#implement-your-own-visitor)

Make sure when implementing the method: `visitReferenceNode` you check if the reference is circular. for example:

```
    /**
     * @param ReferenceNode $referenceNode
     * @return mixed
     */
    public function visitReferenceNode(ReferenceNode $referenceNode)
    {
        if (!$referenceNode->isCircular()) {
            $referenceNode->getPointToSchema()->accept($this);
        }
    }
```

Usage
-----

[](#usage)

Make sure the reference is an absolute reference to a url or file on the local file system.

```
