This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
json-api-schema with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
JSON Api Schema is a JSON dialect ( just a json file ) that can describe any Web Based API that uses JSON to exchange data.
A JSON Api Schema can be used to share an unabiguous object model between servers and clients along with validation logic, classes and so on.
In other words JSON Api Schema is a set of two related specification:
JSON Api Schema is designed to express a generic API minimizing constraints on implementations. JSON Api Schema Description Language can support applicaition specific behaviours through extensions. JSON Api Schema is designed to be able to express a super-set of RESTful APIs and JSON APIs, as a mean to communicate interactions and data structures exposed by an API. Application specific stuffs are expressed through protocol options.
JSON Api Schema Object Model adopt conventions that make it easy to be implemented in most languages. For example we use getters and setters over properties and accessors, iterators instead of closures, ecc...
Being easy to implement in both clients and servers JSON Api Schema is perfect to renew an old data source.
JSON Api Schema heavily relies on JSON Schema to export validation logic to clients.
Implementing Types JSON Api Schema makes it easy (but not forces) to hide network requests behind OOP objects and classes.
JSON Api Schema support documentation attributes everywhere. A traversable model make it easy to generate a beautiful readable documentation.
An application consists of a data api, a website and a mobile app:
Data Api exports its interface through JSON Api Schema. Website and Mobile App consumes that through dynamically or statically generated stubs, or either by directly calling actions via ajax requests.
The entry point of the model. An Api is a set of interactions, types and resources. An api exposes also protocol specific global informations to configure interactions.
A Resource is a type that has interactions. A Resource can have nested resources. Nested resources are somewhat logically bound to their container, eg. by ID or by URI.
A JSON Schema instance. Anything that can be validated should have or be a schema.
Just a named
An interaction is a communication available with the api. It can represent both a client-initiated communication or a server initiated communication. Protocol based informations about an interaction are stored in a
An action is a client initiated interaction. It has two validatable sub-entities along with protocol specification:
An event is a server initiated interaction. It has a validatable sub-entity along with protocol specification: