Giter Club home page Giter Club logo

php-json-schema-generator's Introduction

PHP JSON Schema Generator

======================

Build Status

Package: php-json-schema-generator

PHP JSON Schema Generator

About JSON Schema

JSON has become a mainstay in the vast HTTP toolbox. In order to make JSON more stable and to increase the longevity of the data structure there must be some standards put into place. These standards will help to define the structure in a way that the industry can rely on. A uniform way to parse the data and interpret the meaning of the data elements can be found in building a schema that represents it.

Due to the flexible nature of JSON a solid Schema definition has been slow coming. At this time there is an internet draft being worked on.
(http://tools.ietf.org/html/draft-zyp-json-schema-04)

The uses/pros/cons and other discussions related to what a schema can and cannot do for you are beyond the scope of this document. Seek your creativity for possible scenarios.

About This Tool

It is a bit tedious to have to manually write out a JSON Schema every time a new REST point or Data object is created. Because JSON can be used to represent a variety of data objects it can be helpful to have a dynamic way to map from one object to a JSON Schema. A php array is considered an object here for the sake of ease of communication.

The goal of the tool is to provide an trivial implement for generating a JSON Schema off a wide range of objects. Some objects provide more options for rich schema generation and some do not. JSON itself is very light on metadata so there is a requirement to infer certain meanings based on the structure of the objects.

Parser Objects Supported

  • JSON string

Parsers To Be Supported

  • JSON/Schema Object
    • Loading the Schema + Properties manually
    • Can be built up easier with an API
  • Array
    • Simple hash
    • API to load an array
    • Will validate the array structure
  • ArrayObject
    • Similar to array hash
  • Doctrine Entity
    • Use the Doctrine 2 infrastructure
    • Generate the schema off the doctrine metadata
    • Map to DB settings
    • Allow map overrides
  • Extensible Objects
    • Load user defined parsers
    • Inherit major functionality

Installation

Simple, assuming you use composer. Add the below lines to your composer.json and run composer update.

"require": {
    "solvire/php-json-schema-generator": "dev-master"
}

Testing

PHPUnit should be included with the composer require-dev configuration. The installation will put an executable in the vendor/bin directly so it can be run from there.

Run:

$ vendor/bin/phpunit

php-json-schema-generator's People

Contributors

apoq avatar solvire avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.