TypeSchema is a JSON format to describe data models in a language neutral format. A TypeSchema can be easily transformed into specific code for almost any programming language. This helps to reuse core data models in different environments.
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"$ref": "Student"
}
public class Student
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
// Student
type Student struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
}
<div id="Student" class="psx-object psx-struct"><h1><a href="#Student">Student</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"firstName"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"lastName"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"age"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Integer</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">firstName</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">lastName</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">age</span></td><td><span class="psx-property-type">Integer</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
public static class Student {
private String firstName;
private String lastName;
private int age;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return this.firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return this.lastName;
}
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return this.age;
}
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"$ref": "#\/definitions\/Student"
}
<a name="Student"></a>
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
class Student implements \JsonSerializable
{
/**
* @var string|null
*/
protected $firstName;
/**
* @var string|null
*/
protected $lastName;
/**
* @var int|null
*/
protected $age;
/**
* @param string|null $firstName
*/
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
/**
* @return string|null
*/
public function getFirstName() : ?string
{
return $this->firstName;
}
/**
* @param string|null $lastName
*/
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
/**
* @return string|null
*/
public function getLastName() : ?string
{
return $this->lastName;
}
/**
* @param int|null $age
*/
public function setAge(?int $age) : void
{
$this->age = $age;
}
/**
* @return int|null
*/
public function getAge() : ?int
{
return $this->age;
}
public function jsonSerialize()
{
return (object) array_filter(array('firstName' => $this->firstName, 'lastName' => $this->lastName, 'age' => $this->age), static function ($value) : bool {
return $value !== null;
});
}
}
message Student {
string firstName = 1;
string lastName = 2;
int64 age = 3;
}
class Student:
def __init__(self, firstName: str, lastName: str, age: int):
self.firstName = firstName
self.lastName = lastName
self.age = age
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
}
export interface Student {
firstName?: string
lastName?: string
age?: number
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"$ref": "Student"
}
{
"definitions": {
"Human": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Student": {
"$extends": "Human",
"type": "object",
"properties": {
"studentId": {
"type": "string"
}
}
}
},
"$ref": "Student"
}
public class Human
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
public class Student extends Human
{
public string StudentId { get; set; }
}
// Human
type Human struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
}
// Student
type Student struct {
*Human
StudentId string `json:"studentId"`
}
<div id="Human" class="psx-object psx-struct"><h1><a href="#Human">Human</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"firstName"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"lastName"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"age"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Integer</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">firstName</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">lastName</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">age</span></td><td><span class="psx-property-type">Integer</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="Student" class="psx-object psx-struct"><h1><a href="#Student">Student</a> extends <a href="#Human">Human</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"studentId"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">studentId</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
public static class Human {
private String firstName;
private String lastName;
private int age;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return this.firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return this.lastName;
}
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return this.age;
}
}
public static class Student extends Human {
private String studentId;
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getStudentId() {
return this.studentId;
}
}
{
"definitions": {
"Human": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Student": {
"allOf": [
{
"$ref": "#\/definitions\/Human"
},
{
"type": "object",
"properties": {
"studentId": {
"type": "string"
}
}
}
]
}
},
"$ref": "#\/definitions\/Student"
}
<a name="Human"></a>
# Human
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
<a name="Student"></a>
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
studentId | String | |
class Human implements \JsonSerializable
{
/**
* @var string|null
*/
protected $firstName;
/**
* @var string|null
*/
protected $lastName;
/**
* @var int|null
*/
protected $age;
/**
* @param string|null $firstName
*/
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
/**
* @return string|null
*/
public function getFirstName() : ?string
{
return $this->firstName;
}
/**
* @param string|null $lastName
*/
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
/**
* @return string|null
*/
public function getLastName() : ?string
{
return $this->lastName;
}
/**
* @param int|null $age
*/
public function setAge(?int $age) : void
{
$this->age = $age;
}
/**
* @return int|null
*/
public function getAge() : ?int
{
return $this->age;
}
public function jsonSerialize()
{
return (object) array_filter(array('firstName' => $this->firstName, 'lastName' => $this->lastName, 'age' => $this->age), static function ($value) : bool {
return $value !== null;
});
}
}
class Student extends Human implements \JsonSerializable
{
/**
* @var string|null
*/
protected $studentId;
/**
* @param string|null $studentId
*/
public function setStudentId(?string $studentId) : void
{
$this->studentId = $studentId;
}
/**
* @return string|null
*/
public function getStudentId() : ?string
{
return $this->studentId;
}
public function jsonSerialize()
{
return (object) array_merge((array) parent::jsonSerialize(), array_filter(array('studentId' => $this->studentId), static function ($value) : bool {
return $value !== null;
}));
}
}
message Human {
string firstName = 1;
string lastName = 2;
int64 age = 3;
}
message Student {
string studentId = 1;
}
class Human:
def __init__(self, firstName: str, lastName: str, age: int):
self.firstName = firstName
self.lastName = lastName
self.age = age
class Student(Human):
def __init__(self, studentId: str):
self.studentId = studentId
class Human: Codable {
var firstName: String
var lastName: String
var age: Int
}
class Student: Human {
var studentId: String
}
export interface Human {
firstName?: string
lastName?: string
age?: number
}
export interface Student extends Human {
studentId?: string
}
{
"definitions": {
"Human": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Student": {
"$extends": "Human",
"type": "object",
"properties": {
"studentId": {
"type": "string"
}
}
}
},
"$ref": "Student"
}
{
"definitions": {
"Human": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"location": {
"oneOf": [{
"$ref": "Web"
}, {
"$ref": "World"
}],
"discriminator": {
"propertyName": "type"
}
}
}
},
"Location": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"required": ["type"]
},
"Web": {
"$extends": "Location",
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
},
"World": {
"$extends": "Location",
"type": "object",
"properties": {
"lat": {
"type": "string"
},
"long": {
"type": "string"
}
}
}
},
"$ref": "Human"
}
public class Human
{
public string FirstName { get; set; }
public string LastName { get; set; }
public object Location { get; set; }
}
public class Location
{
public string Type { get; set; }
}
public class Web extends Location
{
public string Url { get; set; }
}
public class World extends Location
{
public string Lat { get; set; }
public string Long { get; set; }
}
// Human
type Human struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Location interface{} `json:"location"`
}
// Location
type Location struct {
Type string `json:"type"`
}
// Web
type Web struct {
*Location
Url string `json:"url"`
}
// World
type World struct {
*Location
Lat string `json:"lat"`
Long string `json:"long"`
}
<div id="Human" class="psx-object psx-struct"><h1><a href="#Human">Human</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"firstName"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"lastName"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"location"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Object (<a href="#Web">Web</a>) | Object (<a href="#World">World</a>)</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">firstName</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">lastName</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">location</span></td><td><span class="psx-property-type">Object (<a href="#Web">Web</a>) | Object (<a href="#World">World</a>)</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="Location" class="psx-object psx-struct"><h1><a href="#Location">Location</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"type"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-required">type</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="Web" class="psx-object psx-struct"><h1><a href="#Web">Web</a> extends <a href="#Location">Location</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"url"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">url</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="World" class="psx-object psx-struct"><h1><a href="#World">World</a> extends <a href="#Location">Location</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"lat"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"long"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">lat</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">long</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
public static class Human {
private String firstName;
private String lastName;
private Object location;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return this.firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return this.lastName;
}
public void setLocation(Object location) {
this.location = location;
}
public Object getLocation() {
return this.location;
}
}
public static class Location {
private String type;
public void setType(String type) {
this.type = type;
}
public String getType() {
return this.type;
}
}
public static class Web extends Location {
private String url;
public void setUrl(String url) {
this.url = url;
}
public String getUrl() {
return this.url;
}
}
public static class World extends Location {
private String lat;
private String long;
public void setLat(String lat) {
this.lat = lat;
}
public String getLat() {
return this.lat;
}
public void setLong(String long) {
this.long = long;
}
public String getLong() {
return this.long;
}
}
{
"definitions": {
"Human": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"location": {
"oneOf": [
{
"$ref": "#\/definitions\/Web"
},
{
"$ref": "#\/definitions\/World"
}
],
"discriminator": {
"propertyName": "type"
}
}
}
},
"Location": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"required": [
"type"
]
},
"Web": {
"allOf": [
{
"$ref": "#\/definitions\/Location"
},
{
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
}
]
},
"World": {
"allOf": [
{
"$ref": "#\/definitions\/Location"
},
{
"type": "object",
"properties": {
"lat": {
"type": "string"
},
"long": {
"type": "string"
}
}
}
]
}
},
"$ref": "#\/definitions\/Human"
}
<a name="Human"></a>
# Human
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
location | Object ([Web](#Web)) | Object ([World](#World)) | |
<a name="Location"></a>
# Location
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
type | String | **REQUIRED**. |
<a name="Web"></a>
# Web
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
url | String | |
<a name="World"></a>
# World
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
lat | String | |
long | String | |
class Human implements \JsonSerializable
{
/**
* @var string|null
*/
protected $firstName;
/**
* @var string|null
*/
protected $lastName;
/**
* @var Web|World|null
* @Discriminator("type", {})
*/
protected $location;
/**
* @param string|null $firstName
*/
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
/**
* @return string|null
*/
public function getFirstName() : ?string
{
return $this->firstName;
}
/**
* @param string|null $lastName
*/
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
/**
* @return string|null
*/
public function getLastName() : ?string
{
return $this->lastName;
}
/**
* @param Web|World|null $location
*/
public function setLocation($location) : void
{
$this->location = $location;
}
/**
* @return Web|World|null
*/
public function getLocation()
{
return $this->location;
}
public function jsonSerialize()
{
return (object) array_filter(array('firstName' => $this->firstName, 'lastName' => $this->lastName, 'location' => $this->location), static function ($value) : bool {
return $value !== null;
});
}
}
/**
* @Required({"type"})
*/
class Location implements \JsonSerializable
{
/**
* @var string|null
*/
protected $type;
/**
* @param string|null $type
*/
public function setType(?string $type) : void
{
$this->type = $type;
}
/**
* @return string|null
*/
public function getType() : ?string
{
return $this->type;
}
public function jsonSerialize()
{
return (object) array_filter(array('type' => $this->type), static function ($value) : bool {
return $value !== null;
});
}
}
class Web extends Location implements \JsonSerializable
{
/**
* @var string|null
*/
protected $url;
/**
* @param string|null $url
*/
public function setUrl(?string $url) : void
{
$this->url = $url;
}
/**
* @return string|null
*/
public function getUrl() : ?string
{
return $this->url;
}
public function jsonSerialize()
{
return (object) array_merge((array) parent::jsonSerialize(), array_filter(array('url' => $this->url), static function ($value) : bool {
return $value !== null;
}));
}
}
class World extends Location implements \JsonSerializable
{
/**
* @var string|null
*/
protected $lat;
/**
* @var string|null
*/
protected $long;
/**
* @param string|null $lat
*/
public function setLat(?string $lat) : void
{
$this->lat = $lat;
}
/**
* @return string|null
*/
public function getLat() : ?string
{
return $this->lat;
}
/**
* @param string|null $long
*/
public function setLong(?string $long) : void
{
$this->long = $long;
}
/**
* @return string|null
*/
public function getLong() : ?string
{
return $this->long;
}
public function jsonSerialize()
{
return (object) array_merge((array) parent::jsonSerialize(), array_filter(array('lat' => $this->lat, 'long' => $this->long), static function ($value) : bool {
return $value !== null;
}));
}
}
message Human {
string firstName = 1;
string lastName = 2;
Struct location = 3;
}
message Location {
string type = 1;
}
message Web {
string url = 1;
}
message World {
string lat = 1;
string long = 2;
}
class Human:
def __init__(self, firstName: str, lastName: str, location: ):
self.firstName = firstName
self.lastName = lastName
self.location = location
class Location:
def __init__(self, type: str):
self.type = type
class Web(Location):
def __init__(self, url: str):
self.url = url
class World(Location):
def __init__(self, lat: str, long: str):
self.lat = lat
self.long = long
class Human: Codable {
var firstName: String
var lastName: String
var location: Web | World
}
class Location: Codable {
var type: String
}
class Web: Location {
var url: String
}
class World: Location {
var lat: String
var long: String
}
export interface Human {
firstName?: string
lastName?: string
location?: Web | World
}
export interface Location {
type: string
}
export interface Web extends Location {
url?: string
}
export interface World extends Location {
lat?: string
long?: string
}
{
"definitions": {
"Human": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"location": {
"oneOf": [
{
"$ref": "Web"
},
{
"$ref": "World"
}
],
"discriminator": {
"propertyName": "type"
}
}
}
},
"Location": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"required": [
"type"
]
},
"Web": {
"$extends": "Location",
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
},
"World": {
"$extends": "Location",
"type": "object",
"properties": {
"lat": {
"type": "string"
},
"long": {
"type": "string"
}
}
}
},
"$ref": "Human"
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"$ref": "Map",
"$template": {
"T": "Student"
}
},
"Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"$generic": "T"
}
}
}
}
},
"$ref": "StudentMap"
}
public class Student
{
public int MatricleNumber { get; set; }
}
public class StudentMap : Map<Student>
{
}
public class Map<T>
{
public int TotalResults { get; set; }
public T[] Entries { get; set; }
}
// Student
type Student struct {
MatricleNumber int `json:"matricleNumber"`
}
// Map
type Map struct {
TotalResults int `json:"totalResults"`
Entries []T `json:"entries"`
}
<div id="Student" class="psx-object psx-struct"><h1><a href="#Student">Student</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"matricleNumber"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Integer</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">matricleNumber</span></td><td><span class="psx-property-type">Integer</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="StudentMap" class="psx-object psx-reference"><h1><a href="#StudentMap">StudentMap</a></h1><pre class="psx-object-json">Reference: Object (<a href="#Map">Map</a>)
<span class="psx-object-json-key">"T"</span><span class="psx-object-json-pun"> = </span><span class="psx-property-type"><a href="#Student">Student</a></span></pre></div>
<div id="Map" class="psx-object psx-struct"><h1><a href="#Map">Map</a><T></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"totalResults"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Integer</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"entries"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Array (T)</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">totalResults</span></td><td><span class="psx-property-type">Integer</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">entries</span></td><td><span class="psx-property-type">Array (T)</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
public static class Student {
private int matricleNumber;
public void setMatricleNumber(int matricleNumber) {
this.matricleNumber = matricleNumber;
}
public int getMatricleNumber() {
return this.matricleNumber;
}
}
public class StudentMap extends Map<Student> {
}
public static class Map<T> {
private int totalResults;
private T[] entries;
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
public int getTotalResults() {
return this.totalResults;
}
public void setEntries(T[] entries) {
this.entries = entries;
}
public T[] getEntries() {
return this.entries;
}
}
{
"definitions": {
"Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"$generic": "T"
}
}
}
},
"Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"$ref": "#\/definitions\/Map"
}
},
"$ref": "#\/definitions\/StudentMap"
}
<a name="Student"></a>
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
matricleNumber | Integer | |
<a name="Map"></a>
# Map
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
totalResults | Integer | |
entries | Array (T) | |
class Student implements \JsonSerializable
{
/**
* @var int|null
*/
protected $matricleNumber;
/**
* @param int|null $matricleNumber
*/
public function setMatricleNumber(?int $matricleNumber) : void
{
$this->matricleNumber = $matricleNumber;
}
/**
* @return int|null
*/
public function getMatricleNumber() : ?int
{
return $this->matricleNumber;
}
public function jsonSerialize()
{
return (object) array_filter(array('matricleNumber' => $this->matricleNumber), static function ($value) : bool {
return $value !== null;
});
}
}
/**
* @extends Map<Student>
*/
class StudentMap extends Map
{
}
/**
* @template T
*/
class Map implements \JsonSerializable
{
/**
* @var int|null
*/
protected $totalResults;
/**
* @var array<T>|null
*/
protected $entries;
/**
* @param int|null $totalResults
*/
public function setTotalResults(?int $totalResults) : void
{
$this->totalResults = $totalResults;
}
/**
* @return int|null
*/
public function getTotalResults() : ?int
{
return $this->totalResults;
}
/**
* @param array<T>|null $entries
*/
public function setEntries(?array $entries) : void
{
$this->entries = $entries;
}
/**
* @return array<T>|null
*/
public function getEntries() : ?array
{
return $this->entries;
}
public function jsonSerialize()
{
return (object) array_filter(array('totalResults' => $this->totalResults, 'entries' => $this->entries), static function ($value) : bool {
return $value !== null;
});
}
}
message Student {
int64 matricleNumber = 1;
}
message Map {
int64 totalResults = 1;
repeated T entries = 2;
}
class Student:
def __init__(self, matricleNumber: int):
self.matricleNumber = matricleNumber
class StudentMap(Map):
class Map:
def __init__(self, totalResults: int, entries: List[T]):
self.totalResults = totalResults
self.entries = entries
class Student: Codable {
var matricleNumber: Int
}
typealias StudentMap = Map<Student>;
class Map: Codable {
var totalResults: Int
var entries: Array<T>
}
export interface Student {
matricleNumber?: number
}
type StudentMap = Map<Student>;
export interface Map<T> {
totalResults?: number
entries?: Array<T>
}
{
"definitions": {
"Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"$generic": "T"
}
}
}
},
"Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"$ref": "Map",
"$template": {
"T": "Student"
}
}
},
"$ref": "StudentMap"
}
{
"$import": {
"my_ns": "file:///generic.json"
},
"definitions": {
"Faculty": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"items": {
"$ref": "my_ns:StudentMap"
}
}
}
}
},
"$ref": "Faculty"
}
public class Faculty
{
public string Description { get; set; }
public StudentMap[] Students { get; set; }
}
// Faculty
type Faculty struct {
Description string `json:"description"`
Students []StudentMap `json:"students"`
}
<div id="Faculty" class="psx-object psx-struct"><h1><a href="#Faculty">Faculty</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"description"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-key">"students"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Array (Object (<a href="#my_ns:StudentMap">my_ns:StudentMap</a>))</span><span class="psx-object-json-pun">,</span>
<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name psx-property-optional">description</span></td><td><span class="psx-property-type">String</span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">students</span></td><td><span class="psx-property-type">Array (Object (<a href="#my_ns:StudentMap">my_ns:StudentMap</a>))</span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
public static class Faculty {
private String description;
private StudentMap[] students;
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return this.description;
}
public void setStudents(StudentMap[] students) {
this.students = students;
}
public StudentMap[] getStudents() {
return this.students;
}
}
{
"definitions": {
"my_ns:Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"$generic": "T"
}
}
}
},
"my_ns:Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"my_ns:StudentMap": {
"$ref": "#\/definitions\/my_ns:Map"
},
"Faculty": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"items": {
"$ref": "#\/definitions\/my_ns:StudentMap"
}
}
}
}
},
"$ref": "#\/definitions\/Faculty"
}
<a name="Faculty"></a>
# Faculty
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
description | String | |
students | Array (Object ([my_ns:StudentMap](#my_ns:StudentMap))) | |
class Faculty implements \JsonSerializable
{
/**
* @var string|null
*/
protected $description;
/**
* @var array<StudentMap>|null
*/
protected $students;
/**
* @param string|null $description
*/
public function setDescription(?string $description) : void
{
$this->description = $description;
}
/**
* @return string|null
*/
public function getDescription() : ?string
{
return $this->description;
}
/**
* @param array<StudentMap>|null $students
*/
public function setStudents(?array $students) : void
{
$this->students = $students;
}
/**
* @return array<StudentMap>|null
*/
public function getStudents() : ?array
{
return $this->students;
}
public function jsonSerialize()
{
return (object) array_filter(array('description' => $this->description, 'students' => $this->students), static function ($value) : bool {
return $value !== null;
});
}
}
message Faculty {
string description = 1;
repeated StudentMap students = 2;
}
class Faculty:
def __init__(self, description: str, students: List[StudentMap]):
self.description = description
self.students = students
class Faculty: Codable {
var description: String
var students: Array<StudentMap>
}
export interface Faculty {
description?: string
students?: Array<StudentMap>
}
{
"definitions": {
"my_ns:Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"$generic": "T"
}
}
}
},
"my_ns:Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"my_ns:StudentMap": {
"$ref": "my_ns:Map",
"$template": {
"T": "my_ns:Student"
}
},
"Faculty": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"items": {
"$ref": "my_ns:StudentMap"
}
}
}
}
},
"$ref": "Faculty"
}