JSON Api Schema
A Json based Web API Description Language and Object Model
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-DL: A JSON API Description Language
- JSON Api Schema-OM: A related API Object Model (similar of what DOM is to HTML)
Be generic enough to describe complex systems
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.
Be available in multiple languages
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...
Be suitable to readapt existing data models
Being easy to implement in both clients and servers JSON Api Schema is perfect to renew an old data source.
Be a real-world solution
Allow to share validation logic between servers and clients
JSON Api Schema heavily relies on JSON Schema to export validation logic to clients.
Be suitable to build RMI on top of it
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.
A typical use case
An application consists of a data api, a website and a mobile app:
- They are 3 separate systems that may be written in different languages.
- They shares the same domain model.
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.
Api Model (For Both DL and OM):
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: