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"
}
using System.Text.Json.Serialization;
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
}
type Student struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
}
type Student {
firstName: String
lastName: String
age: Int
}
<div id="Student" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Student {
private String firstName;
private String lastName;
private Integer age;
@JsonSetter("firstName")
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@JsonGetter("firstName")
public String getFirstName() {
return this.firstName;
}
@JsonSetter("lastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonGetter("lastName")
public String getLastName() {
return this.lastName;
}
@JsonSetter("age")
public void setAge(Integer age) {
this.age = age;
}
@JsonGetter("age")
public Integer getAge() {
return this.age;
}
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"$ref": "#/definitions/Student"
}
open class Student {
var firstName: String? = null
var lastName: String? = null
var age: Int? = null
}
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
class Student implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $firstName = null;
protected ?string $lastName = null;
protected ?int $age = null;
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
public function getFirstName() : ?string
{
return $this->firstName;
}
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
public function getLastName() : ?string
{
return $this->lastName;
}
public function setAge(?int $age) : void
{
$this->age = $age;
}
public function getAge() : ?int
{
return $this->age;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('firstName', $this->firstName);
$record->put('lastName', $this->lastName);
$record->put('age', $this->age);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Student {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional int64 age = 3 [json_name="age"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class Student(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
age: Optional[int] = Field(default=None, alias="age")
pass
class Student
attr_accessor :first_name, :last_name, :age
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
end
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Student {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "age")]
age: Option<u64>,
}
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
}
}
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"
}
Imports System.Text.Json.Serialization
Public Class Student
<JsonPropertyName("firstName")>
Public Property FirstName As String
<JsonPropertyName("lastName")>
Public Property LastName As String
<JsonPropertyName("age")>
Public Property Age As Integer
End Class
{
"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"
}
using System.Text.Json.Serialization;
public class Human
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
}
using System.Text.Json.Serialization;
public class Student : Human
{
[JsonPropertyName("studentId")]
public string? StudentId { get; set; }
}
type Human struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
}
type Student struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
StudentId string `json:"studentId"`
}
type Human {
firstName: String
lastName: String
age: Int
}
type Student {
studentId: String
}
<div id="Human" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="Student" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Student">Student</a> extends <a class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Human {
private String firstName;
private String lastName;
private Integer age;
@JsonSetter("firstName")
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@JsonGetter("firstName")
public String getFirstName() {
return this.firstName;
}
@JsonSetter("lastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonGetter("lastName")
public String getLastName() {
return this.lastName;
}
@JsonSetter("age")
public void setAge(Integer age) {
this.age = age;
}
@JsonGetter("age")
public Integer getAge() {
return this.age;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Student extends Human {
private String studentId;
@JsonSetter("studentId")
public void setStudentId(String studentId) {
this.studentId = studentId;
}
@JsonGetter("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"
}
open class Human {
var firstName: String? = null
var lastName: String? = null
var age: Int? = null
}
open class Student : Human {
var studentId: String? = null
}
# Human
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
studentId | String | |
class Human implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $firstName = null;
protected ?string $lastName = null;
protected ?int $age = null;
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
public function getFirstName() : ?string
{
return $this->firstName;
}
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
public function getLastName() : ?string
{
return $this->lastName;
}
public function setAge(?int $age) : void
{
$this->age = $age;
}
public function getAge() : ?int
{
return $this->age;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('firstName', $this->firstName);
$record->put('lastName', $this->lastName);
$record->put('age', $this->age);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
class Student extends Human implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $studentId = null;
public function setStudentId(?string $studentId) : void
{
$this->studentId = $studentId;
}
public function getStudentId() : ?string
{
return $this->studentId;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = parent::toRecord();
$record->put('studentId', $this->studentId);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Human {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional int64 age = 3 [json_name="age"];
}
message Student {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional int64 age = 3 [json_name="age"];
optional string studentId = 4 [json_name="studentId"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class Human(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
age: Optional[int] = Field(default=None, alias="age")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .human import Human
class Student(Human):
student_id: Optional[str] = Field(default=None, alias="studentId")
pass
class Human
attr_accessor :first_name, :last_name, :age
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
end
class Student
extend Human
attr_accessor :student_id
def initialize(student_id)
@student_id = student_id
end
end
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Human {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "age")]
age: Option<u64>,
}
use serde::{Serialize, Deserialize};
use human::Human;
#[derive(Serialize, Deserialize)]
pub struct Student {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "age")]
age: Option<u64>,
#[serde(rename = "studentId")]
student_id: Option<String>,
}
class Human: Codable {
var firstName: String
var lastName: String
var age: Int
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
}
}
class Student: Human {
var studentId: String
enum CodingKeys: String, CodingKey {
case studentId = "studentId"
}
}
export interface Human {
firstName?: string
lastName?: string
age?: number
}
import {Human} from "./Human";
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"
}
Imports System.Text.Json.Serialization
Public Class Human
<JsonPropertyName("firstName")>
Public Property FirstName As String
<JsonPropertyName("lastName")>
Public Property LastName As String
<JsonPropertyName("age")>
Public Property Age As Integer
End Class
Imports System.Text.Json.Serialization
Public Class Student
Inherits Human
<JsonPropertyName("studentId")>
Public Property StudentId As String
End Class
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"faculty": {
"$ref": "Faculty"
}
}
},
"Faculty": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
},
"$ref": "Student"
}
using System.Text.Json.Serialization;
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
[JsonPropertyName("faculty")]
public Faculty? Faculty { get; set; }
}
using System.Text.Json.Serialization;
public class Faculty
{
[JsonPropertyName("name")]
public string? Name { get; set; }
}
type Student struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
Faculty *Faculty `json:"faculty"`
}
type Faculty struct {
Name string `json:"name"`
}
type Student {
firstName: String
lastName: String
age: Int
faculty: Faculty
}
type Faculty {
name: String
}
<div id="Student" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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-key">"faculty"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Faculty</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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">faculty</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Faculty">Faculty</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="Faculty" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Faculty">Faculty</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span>
<span class="psx-object-json-key">"name"</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">name</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Student {
private String firstName;
private String lastName;
private Integer age;
private Faculty faculty;
@JsonSetter("firstName")
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@JsonGetter("firstName")
public String getFirstName() {
return this.firstName;
}
@JsonSetter("lastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonGetter("lastName")
public String getLastName() {
return this.lastName;
}
@JsonSetter("age")
public void setAge(Integer age) {
this.age = age;
}
@JsonGetter("age")
public Integer getAge() {
return this.age;
}
@JsonSetter("faculty")
public void setFaculty(Faculty faculty) {
this.faculty = faculty;
}
@JsonGetter("faculty")
public Faculty getFaculty() {
return this.faculty;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Faculty {
private String name;
@JsonSetter("name")
public void setName(String name) {
this.name = name;
}
@JsonGetter("name")
public String getName() {
return this.name;
}
}
{
"definitions": {
"Faculty": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"faculty": {
"$ref": "#/definitions/Faculty"
}
}
}
},
"$ref": "#/definitions/Student"
}
open class Student {
var firstName: String? = null
var lastName: String? = null
var age: Int? = null
var faculty: Faculty? = null
}
open class Faculty {
var name: String? = null
}
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
faculty | Faculty | |
# Faculty
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
name | String | |
class Student implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $firstName = null;
protected ?string $lastName = null;
protected ?int $age = null;
protected ?Faculty $faculty = null;
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
public function getFirstName() : ?string
{
return $this->firstName;
}
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
public function getLastName() : ?string
{
return $this->lastName;
}
public function setAge(?int $age) : void
{
$this->age = $age;
}
public function getAge() : ?int
{
return $this->age;
}
public function setFaculty(?Faculty $faculty) : void
{
$this->faculty = $faculty;
}
public function getFaculty() : ?Faculty
{
return $this->faculty;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('firstName', $this->firstName);
$record->put('lastName', $this->lastName);
$record->put('age', $this->age);
$record->put('faculty', $this->faculty);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
class Faculty implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $name = null;
public function setName(?string $name) : void
{
$this->name = $name;
}
public function getName() : ?string
{
return $this->name;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('name', $this->name);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Student {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional int64 age = 3 [json_name="age"];
optional Faculty faculty = 4 [json_name="faculty"];
}
message Faculty {
optional string name = 1 [json_name="name"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .faculty import Faculty
class Student(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
age: Optional[int] = Field(default=None, alias="age")
faculty: Optional[Faculty] = Field(default=None, alias="faculty")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class Faculty(BaseModel):
name: Optional[str] = Field(default=None, alias="name")
pass
class Student
attr_accessor :first_name, :last_name, :age, :faculty
def initialize(first_name, last_name, age, faculty)
@first_name = first_name
@last_name = last_name
@age = age
@faculty = faculty
end
end
class Faculty
attr_accessor :name
def initialize(name)
@name = name
end
end
use serde::{Serialize, Deserialize};
use faculty::Faculty;
#[derive(Serialize, Deserialize)]
pub struct Student {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "age")]
age: Option<u64>,
#[serde(rename = "faculty")]
faculty: Option<Faculty>,
}
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Faculty {
#[serde(rename = "name")]
name: Option<String>,
}
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
var faculty: Faculty
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
case faculty = "faculty"
}
}
class Faculty: Codable {
var name: String
enum CodingKeys: String, CodingKey {
case name = "name"
}
}
import {Faculty} from "./Faculty";
export interface Student {
firstName?: string
lastName?: string
age?: number
faculty?: Faculty
}
export interface Faculty {
name?: string
}
{
"definitions": {
"Faculty": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"faculty": {
"$ref": "Faculty"
}
}
}
},
"$ref": "Student"
}
Imports System.Text.Json.Serialization
Public Class Student
<JsonPropertyName("firstName")>
Public Property FirstName As String
<JsonPropertyName("lastName")>
Public Property LastName As String
<JsonPropertyName("age")>
Public Property Age As Integer
<JsonPropertyName("faculty")>
Public Property Faculty As Faculty
End Class
Imports System.Text.Json.Serialization
Public Class Faculty
<JsonPropertyName("name")>
Public Property Name As String
End Class
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"$ref": "Student_Properties"
}
}
},
"Student_Properties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"$ref": "Student"
}
using System.Text.Json.Serialization;
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
[JsonPropertyName("properties")]
public StudentProperties? Properties { get; set; }
}
using System.Text.Json.Serialization;
using System.Collections.Generic;
public class StudentProperties : Dictionary<string, string>
{
}
type Student struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
Properties *StudentProperties `json:"properties"`
}
type StudentProperties = map[string]string
type Student {
firstName: String
lastName: String
age: Int
properties: [String]
}
<div id="Student" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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-key">"properties"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Student_Properties</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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">properties</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Student_Properties">Student_Properties</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="StudentProperties" class="psx-object psx-map"><h1><a class="psx-type-link" data-name="StudentProperties">StudentProperties</a></h1><pre class="psx-object-json">Map (String)</pre></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Student {
private String firstName;
private String lastName;
private Integer age;
private StudentProperties properties;
@JsonSetter("firstName")
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@JsonGetter("firstName")
public String getFirstName() {
return this.firstName;
}
@JsonSetter("lastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonGetter("lastName")
public String getLastName() {
return this.lastName;
}
@JsonSetter("age")
public void setAge(Integer age) {
this.age = age;
}
@JsonGetter("age")
public Integer getAge() {
return this.age;
}
@JsonSetter("properties")
public void setProperties(StudentProperties properties) {
this.properties = properties;
}
@JsonGetter("properties")
public StudentProperties getProperties() {
return this.properties;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.Map;
import java.util.HashMap;
public class StudentProperties extends HashMap<String, String> {
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/Student_Properties"
}
}
},
"Student_Properties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"$ref": "#/definitions/Student"
}
open class Student {
var firstName: String? = null
var lastName: String? = null
var age: Int? = null
var properties: StudentProperties? = null
}
import java.util.HashMap;
open class StudentProperties : HashMap<String, String>() {
}
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
properties | Student_Properties | |
# StudentProperties
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
* | Map (String) | |
class Student implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $firstName = null;
protected ?string $lastName = null;
protected ?int $age = null;
protected ?StudentProperties $properties = null;
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
public function getFirstName() : ?string
{
return $this->firstName;
}
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
public function getLastName() : ?string
{
return $this->lastName;
}
public function setAge(?int $age) : void
{
$this->age = $age;
}
public function getAge() : ?int
{
return $this->age;
}
public function setProperties(?StudentProperties $properties) : void
{
$this->properties = $properties;
}
public function getProperties() : ?StudentProperties
{
return $this->properties;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('firstName', $this->firstName);
$record->put('lastName', $this->lastName);
$record->put('age', $this->age);
$record->put('properties', $this->properties);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
/**
* @extends \PSX\Record\Record<string>
*/
class StudentProperties extends \PSX\Record\Record
{
}
message Student {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional int64 age = 3 [json_name="age"];
optional map<string, string> properties = 4 [json_name="properties"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .student_properties import StudentProperties
class Student(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
age: Optional[int] = Field(default=None, alias="age")
properties: Optional[StudentProperties] = Field(default=None, alias="properties")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class StudentProperties(Dict[str, str]):
@classmethod
def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema:
return core_schema.dict_schema(handler.generate_schema(str), handler.generate_schema(str))
class Student
attr_accessor :first_name, :last_name, :age, :properties
def initialize(first_name, last_name, age, properties)
@first_name = first_name
@last_name = last_name
@age = age
@properties = properties
end
end
use serde::{Serialize, Deserialize};
use student_properties::StudentProperties;
#[derive(Serialize, Deserialize)]
pub struct Student {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "age")]
age: Option<u64>,
#[serde(rename = "properties")]
properties: Option<StudentProperties>,
}
use std::collections::HashMap;
pub type StudentProperties = HashMap<String, String>;
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
var properties: StudentProperties
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
case properties = "properties"
}
}
typealias StudentProperties = Dictionary<String, String>;
import {StudentProperties} from "./StudentProperties";
export interface Student {
firstName?: string
lastName?: string
age?: number
properties?: StudentProperties
}
export type StudentProperties = Record<string, string>;
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"$ref": "Student_Properties"
}
}
},
"Student_Properties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"$ref": "Student"
}
Imports System.Text.Json.Serialization
Public Class Student
<JsonPropertyName("firstName")>
Public Property FirstName As String
<JsonPropertyName("lastName")>
Public Property LastName As String
<JsonPropertyName("age")>
Public Property Age As Integer
<JsonPropertyName("properties")>
Public Property Properties As StudentProperties
End Class
Imports System.Text.Json.Serialization
Imports System.Collections.Generic
Public Class StudentProperties
Inherits Dictionary(Of String, String)
End Class
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"$ref": "Student"
}
using System.Text.Json.Serialization;
using System.Collections.Generic;
public class Student
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("age")]
public int? Age { get; set; }
[JsonPropertyName("properties")]
public Dictionary<string, string>? Properties { get; set; }
}
type Student struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Age int `json:"age"`
Properties map[string]string `json:"properties"`
}
type Student {
firstName: String
lastName: String
age: Int
properties: [String]
}
<div id="Student" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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-key">"properties"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (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">firstName</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name psx-property-optional">properties</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (String)">Map (String)</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.Map;
public class Student {
private String firstName;
private String lastName;
private Integer age;
private Map<String, String> properties;
@JsonSetter("firstName")
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@JsonGetter("firstName")
public String getFirstName() {
return this.firstName;
}
@JsonSetter("lastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonGetter("lastName")
public String getLastName() {
return this.lastName;
}
@JsonSetter("age")
public void setAge(Integer age) {
this.age = age;
}
@JsonGetter("age")
public Integer getAge() {
return this.age;
}
@JsonSetter("properties")
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
@JsonGetter("properties")
public Map<String, String> getProperties() {
return this.properties;
}
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"$ref": "#/definitions/Student"
}
import java.util.HashMap;
open class Student {
var firstName: String? = null
var lastName: String? = null
var age: Int? = null
var properties: HashMap<String, String>? = null
}
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
age | Integer | |
properties | Map (String) | |
class Student implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $firstName = null;
protected ?string $lastName = null;
protected ?int $age = null;
/**
* @var \PSX\Record\Record<string>|null
*/
protected ?\PSX\Record\Record $properties = null;
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
public function getFirstName() : ?string
{
return $this->firstName;
}
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
public function getLastName() : ?string
{
return $this->lastName;
}
public function setAge(?int $age) : void
{
$this->age = $age;
}
public function getAge() : ?int
{
return $this->age;
}
public function setProperties(?\PSX\Record\Record $properties) : void
{
$this->properties = $properties;
}
public function getProperties() : ?\PSX\Record\Record
{
return $this->properties;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('firstName', $this->firstName);
$record->put('lastName', $this->lastName);
$record->put('age', $this->age);
$record->put('properties', $this->properties);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Student {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional int64 age = 3 [json_name="age"];
optional map<string, string> properties = 4 [json_name="properties"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class Student(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
age: Optional[int] = Field(default=None, alias="age")
properties: Optional[Dict[str, str]] = Field(default=None, alias="properties")
pass
class Student
attr_accessor :first_name, :last_name, :age, :properties
def initialize(first_name, last_name, age, properties)
@first_name = first_name
@last_name = last_name
@age = age
@properties = properties
end
end
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
#[derive(Serialize, Deserialize)]
pub struct Student {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "age")]
age: Option<u64>,
#[serde(rename = "properties")]
properties: Option<HashMap<String, String>>,
}
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
var properties: Dictionary<String, String>
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
case properties = "properties"
}
}
export interface Student {
firstName?: string
lastName?: string
age?: number
properties?: Record<string, string>
}
{
"definitions": {
"Student": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"$ref": "Student"
}
Imports System.Text.Json.Serialization
Imports System.Collections.Generic
Public Class Student
<JsonPropertyName("firstName")>
Public Property FirstName As String
<JsonPropertyName("lastName")>
Public Property LastName As String
<JsonPropertyName("age")>
Public Property Age As Integer
<JsonPropertyName("properties")>
Public Property Properties As Dictionary(Of String, String)
End Class
{
"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"
}
using System.Text.Json.Serialization;
public class Human
{
[JsonPropertyName("firstName")]
public string? FirstName { get; set; }
[JsonPropertyName("lastName")]
public string? LastName { get; set; }
[JsonPropertyName("location")]
public object? Location { get; set; }
}
using System.Text.Json.Serialization;
public class Location
{
[JsonPropertyName("type")]
public string? Type { get; set; }
}
using System.Text.Json.Serialization;
public class Web : Location
{
[JsonPropertyName("url")]
public string? Url { get; set; }
}
using System.Text.Json.Serialization;
public class World : Location
{
[JsonPropertyName("lat")]
public string? Lat { get; set; }
[JsonPropertyName("long")]
public string? Long { get; set; }
}
type Human struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Location any `json:"location"`
}
type Location struct {
Type string `json:"type"`
}
type Web struct {
Type string `json:"type"`
Url string `json:"url"`
}
type World struct {
Type string `json:"type"`
Lat string `json:"lat"`
Long string `json:"long"`
}
type Human {
firstName: String
lastName: String
location: Web | World
}
type Location {
type: String!
}
type Web {
url: String
}
type World {
lat: String
long: String
}
<div id="Human" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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">Web | World</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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Web | World">Web | 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 class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="Web" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Web">Web</a> extends <a class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
<div id="World" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="World">World</a> extends <a class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Human {
private String firstName;
private String lastName;
private Object location;
@JsonSetter("firstName")
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@JsonGetter("firstName")
public String getFirstName() {
return this.firstName;
}
@JsonSetter("lastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}
@JsonGetter("lastName")
public String getLastName() {
return this.lastName;
}
@JsonSetter("location")
public void setLocation(Object location) {
this.location = location;
}
@JsonGetter("location")
public Object getLocation() {
return this.location;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Location {
private String type;
@JsonSetter("type")
public void setType(String type) {
this.type = type;
}
@JsonGetter("type")
public String getType() {
return this.type;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Web extends Location {
private String url;
@JsonSetter("url")
public void setUrl(String url) {
this.url = url;
}
@JsonGetter("url")
public String getUrl() {
return this.url;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class World extends Location {
private String lat;
private String _long;
@JsonSetter("lat")
public void setLat(String lat) {
this.lat = lat;
}
@JsonGetter("lat")
public String getLat() {
return this.lat;
}
@JsonSetter("long")
public void setLong(String _long) {
this._long = _long;
}
@JsonGetter("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"
}
open class Human {
var firstName: String? = null
var lastName: String? = null
var location: Any? = null
}
open class Location {
var type: String? = null
}
open class Web : Location {
var url: String? = null
}
open class World : Location {
var lat: String? = null
var long: String? = null
}
# Human
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
firstName | String | |
lastName | String | |
location | Web | World | |
# Location
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
type | String | **REQUIRED**. |
# Web
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
url | String | |
# World
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
lat | String | |
long | String | |
use PSX\Schema\Attribute\Discriminator;
class Human implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $firstName = null;
protected ?string $lastName = null;
#[Discriminator('type')]
protected Web|World|null $location = null;
public function setFirstName(?string $firstName) : void
{
$this->firstName = $firstName;
}
public function getFirstName() : ?string
{
return $this->firstName;
}
public function setLastName(?string $lastName) : void
{
$this->lastName = $lastName;
}
public function getLastName() : ?string
{
return $this->lastName;
}
public function setLocation(Web|World|null $location) : void
{
$this->location = $location;
}
public function getLocation() : Web|World|null
{
return $this->location;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('firstName', $this->firstName);
$record->put('lastName', $this->lastName);
$record->put('location', $this->location);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
use PSX\Schema\Attribute\Required;
#[Required(array('type'))]
class Location implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $type = null;
public function setType(?string $type) : void
{
$this->type = $type;
}
public function getType() : ?string
{
return $this->type;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('type', $this->type);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
class Web extends Location implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $url = null;
public function setUrl(?string $url) : void
{
$this->url = $url;
}
public function getUrl() : ?string
{
return $this->url;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = parent::toRecord();
$record->put('url', $this->url);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
class World extends Location implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $lat = null;
protected ?string $long = null;
public function setLat(?string $lat) : void
{
$this->lat = $lat;
}
public function getLat() : ?string
{
return $this->lat;
}
public function setLong(?string $long) : void
{
$this->long = $long;
}
public function getLong() : ?string
{
return $this->long;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = parent::toRecord();
$record->put('lat', $this->lat);
$record->put('long', $this->long);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Human {
optional string firstName = 1 [json_name="firstName"];
optional string lastName = 2 [json_name="lastName"];
optional Struct location = 3 [json_name="location"];
}
message Location {
optional string type = 1 [json_name="type"];
}
message Web {
optional string type = 1 [json_name="type"];
optional string url = 2 [json_name="url"];
}
message World {
optional string type = 1 [json_name="type"];
optional string lat = 2 [json_name="lat"];
optional string long = 3 [json_name="long"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .web import Web
from .world import World
class Human(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
location: Optional[Union[Web, World]] = Field(default=None, alias="location")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class Location(BaseModel):
type: Optional[str] = Field(default=None, alias="type")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .location import Location
class Web(Location):
url: Optional[str] = Field(default=None, alias="url")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .location import Location
class World(Location):
lat: Optional[str] = Field(default=None, alias="lat")
long: Optional[str] = Field(default=None, alias="long")
pass
class Human
attr_accessor :first_name, :last_name, :location
def initialize(first_name, last_name, location)
@first_name = first_name
@last_name = last_name
@location = location
end
end
class Location
attr_accessor :type
def initialize(type)
@type = type
end
end
class Web
extend Location
attr_accessor :url
def initialize(url)
@url = url
end
end
class World
extend Location
attr_accessor :lat, :long
def initialize(lat, long)
@lat = lat
@long = long
end
end
use serde::{Serialize, Deserialize};
use web::Web;
use world::World;
#[derive(Serialize, Deserialize)]
pub struct Human {
#[serde(rename = "firstName")]
first_name: Option<String>,
#[serde(rename = "lastName")]
last_name: Option<String>,
#[serde(rename = "location")]
location: Option<serde_json::Value>,
}
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Location {
#[serde(rename = "type")]
_type: Option<String>,
}
use serde::{Serialize, Deserialize};
use location::Location;
#[derive(Serialize, Deserialize)]
pub struct Web {
#[serde(rename = "type")]
_type: Option<String>,
#[serde(rename = "url")]
url: Option<String>,
}
use serde::{Serialize, Deserialize};
use location::Location;
#[derive(Serialize, Deserialize)]
pub struct World {
#[serde(rename = "type")]
_type: Option<String>,
#[serde(rename = "lat")]
lat: Option<String>,
#[serde(rename = "long")]
long: Option<String>,
}
class Human: Codable {
var firstName: String
var lastName: String
var location: Web | World
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case location = "location"
}
}
class Location: Codable {
var _type: String
enum CodingKeys: String, CodingKey {
case _type = "type"
}
}
class Web: Location {
var url: String
enum CodingKeys: String, CodingKey {
case url = "url"
}
}
class World: Location {
var lat: String
var long: String
enum CodingKeys: String, CodingKey {
case lat = "lat"
case long = "long"
}
}
import {Web} from "./Web";
import {World} from "./World";
export interface Human {
firstName?: string
lastName?: string
location?: Web | World
}
export interface Location {
type: string
}
import {Location} from "./Location";
export interface Web extends Location {
url?: string
}
import {Location} from "./Location";
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"
}
Imports System.Text.Json.Serialization
Public Class Human
<JsonPropertyName("firstName")>
Public Property FirstName As String
<JsonPropertyName("lastName")>
Public Property LastName As String
<JsonPropertyName("location")>
Public Property Location As Object
End Class
Imports System.Text.Json.Serialization
Public Class Location
<JsonPropertyName("type")>
Public Property Type As String
End Class
Imports System.Text.Json.Serialization
Public Class Web
Inherits Location
<JsonPropertyName("url")>
Public Property Url As String
End Class
Imports System.Text.Json.Serialization
Public Class World
Inherits Location
<JsonPropertyName("lat")>
Public Property Lat As String
<JsonPropertyName("long")>
Public Property _Long As String
End Class
{
"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"
}
using System.Text.Json.Serialization;
public class Student
{
[JsonPropertyName("matricleNumber")]
public int? MatricleNumber { get; set; }
}
using System.Text.Json.Serialization;
public class StudentMap : Map<Student>
{
}
using System.Text.Json.Serialization;
public class Map<T>
{
[JsonPropertyName("totalResults")]
public int? TotalResults { get; set; }
[JsonPropertyName("entries")]
public List<T>? Entries { get; set; }
}
type Student struct {
MatricleNumber int `json:"matricleNumber"`
}
type StudentMap = Map[Student]
type Map[T any] struct {
TotalResults int `json:"totalResults"`
Entries []T `json:"entries"`
}
type Student {
matricleNumber: Int
}
type Map {
totalResults: Int
entries: [T]
}
<div id="Student" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="Integer">Integer</a></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: Map
<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 class="psx-type-link" data-name="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"><a class="psx-type-link" data-name="Integer">Integer</a></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"><a class="psx-type-link" data-name="Array (T)">Array (T)</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Student {
private Integer matricleNumber;
@JsonSetter("matricleNumber")
public void setMatricleNumber(Integer matricleNumber) {
this.matricleNumber = matricleNumber;
}
@JsonGetter("matricleNumber")
public Integer getMatricleNumber() {
return this.matricleNumber;
}
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class StudentMap extends Map<Student> {
}
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.List;
public class Map<T> {
private Integer totalResults;
private List<T> entries;
@JsonSetter("totalResults")
public void setTotalResults(Integer totalResults) {
this.totalResults = totalResults;
}
@JsonGetter("totalResults")
public Integer getTotalResults() {
return this.totalResults;
}
@JsonSetter("entries")
public void setEntries(List<T> entries) {
this.entries = entries;
}
@JsonGetter("entries")
public List<T> getEntries() {
return this.entries;
}
}
{
"definitions": {
"Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": []
}
}
},
"Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
}
}
}
}
},
"$ref": "#/definitions/StudentMap"
}
open class Student {
var matricleNumber: Int? = null
}
typealias StudentMap = Map<Student>
open class Map<T> {
var totalResults: Int? = null
var entries: Array<T>? = null
}
# Student
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
matricleNumber | Integer | |
# Map
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
totalResults | Integer | |
entries | Array (T) | |
class Student implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?int $matricleNumber = null;
public function setMatricleNumber(?int $matricleNumber) : void
{
$this->matricleNumber = $matricleNumber;
}
public function getMatricleNumber() : ?int
{
return $this->matricleNumber;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('matricleNumber', $this->matricleNumber);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
/**
* @extends Map<Student>
*/
class StudentMap extends Map
{
}
/**
* @template T
*/
class Map implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?int $totalResults = null;
/**
* @var array<T>|null
*/
protected ?array $entries = null;
public function setTotalResults(?int $totalResults) : void
{
$this->totalResults = $totalResults;
}
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 toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('totalResults', $this->totalResults);
$record->put('entries', $this->entries);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Student {
optional int64 matricleNumber = 1 [json_name="matricleNumber"];
}
message Map {
optional int64 totalResults = 1 [json_name="totalResults"];
optional repeated T entries = 2 [json_name="entries"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
class Student(BaseModel):
matricle_number: Optional[int] = Field(default=None, alias="matricleNumber")
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .map import Map
from .student import Student
class StudentMap(Map[Student]):
pass
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
T = TypeVar("T")
class Map(BaseModel, Generic[T]):
total_results: Optional[int] = Field(default=None, alias="totalResults")
entries: Optional[List[T]] = Field(default=None, alias="entries")
pass
class Student
attr_accessor :matricle_number
def initialize(matricle_number)
@matricle_number = matricle_number
end
end
class StudentMap
extend Map
end
class Map
attr_accessor :total_results, :entries
def initialize(total_results, entries)
@total_results = total_results
@entries = entries
end
end
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Student {
#[serde(rename = "matricleNumber")]
matricle_number: Option<u64>,
}
use map::Map;
use student::Student;
pub type StudentMap = Map;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Map {
#[serde(rename = "totalResults")]
total_results: Option<u64>,
#[serde(rename = "entries")]
entries: Option<Vec<T>>,
}
class Student: Codable {
var matricleNumber: Int
enum CodingKeys: String, CodingKey {
case matricleNumber = "matricleNumber"
}
}
typealias StudentMap = Map<Student>;
class Map: Codable {
var totalResults: Int
var entries: Array<T>
enum CodingKeys: String, CodingKey {
case totalResults = "totalResults"
case entries = "entries"
}
}
export interface Student {
matricleNumber?: number
}
import {Map} from "./Map";
import {Student} from "./Student";
export 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"
}
Imports System.Text.Json.Serialization
Public Class Student
<JsonPropertyName("matricleNumber")>
Public Property MatricleNumber As Integer
End Class
Imports System.Text.Json.Serialization
Public Class StudentMap : Map(Student)
Inherits Map(Student)
End Class
Imports System.Text.Json.Serialization
Public Class Map(Of T)
<JsonPropertyName("totalResults")>
Public Property TotalResults As Integer
<JsonPropertyName("entries")>
Public Property Entries As T()
End Class
{
"$import": {
"my_ns": "file:///generic.json"
},
"definitions": {
"Faculty": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"items": {
"$ref": "my_ns:StudentMap"
}
}
}
}
},
"$ref": "Faculty"
}
using System.Text.Json.Serialization;
public class Faculty
{
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("students")]
public List<StudentMap>? Students { get; set; }
}
type Faculty struct {
Description string `json:"description"`
Students []StudentMap `json:"students"`
}
type Faculty {
description: String
students: [StudentMap]
}
<div id="Faculty" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="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 (my_ns:StudentMap)</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"><a class="psx-type-link" data-name="String">String</a></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"><a class="psx-type-link" data-name="Array (my_ns:StudentMap)">Array (my_ns:StudentMap)</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div>
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.List;
public class Faculty {
private String description;
private List<StudentMap> students;
@JsonSetter("description")
public void setDescription(String description) {
this.description = description;
}
@JsonGetter("description")
public String getDescription() {
return this.description;
}
@JsonSetter("students")
public void setStudents(List<StudentMap> students) {
this.students = students;
}
@JsonGetter("students")
public List<StudentMap> getStudents() {
return this.students;
}
}
{
"definitions": {
"Map": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": []
}
}
},
"Student": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"type": "object",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
}
}
}
},
"Faculty": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"items": {
"$ref": "#/definitions/StudentMap"
}
}
}
}
},
"$ref": "#/definitions/Faculty"
}
open class Faculty {
var description: String? = null
var students: Array<StudentMap>? = null
}
# Faculty
Field | Type | Description | Constraints
----- | ---- | ----------- | -----------
description | String | |
students | Array (my_ns:StudentMap) | |
class Faculty implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?string $description = null;
/**
* @var array<StudentMap>|null
*/
protected ?array $students = null;
public function setDescription(?string $description) : void
{
$this->description = $description;
}
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 toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('description', $this->description);
$record->put('students', $this->students);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}
message Faculty {
optional string description = 1 [json_name="description"];
optional repeated StudentMap students = 2 [json_name="students"];
}
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from .student_map import StudentMap
class Faculty(BaseModel):
description: Optional[str] = Field(default=None, alias="description")
students: Optional[List[StudentMap]] = Field(default=None, alias="students")
pass
class Faculty
attr_accessor :description, :students
def initialize(description, students)
@description = description
@students = students
end
end
use serde::{Serialize, Deserialize};
use student_map::StudentMap;
#[derive(Serialize, Deserialize)]
pub struct Faculty {
#[serde(rename = "description")]
description: Option<String>,
#[serde(rename = "students")]
students: Option<Vec<StudentMap>>,
}
class Faculty: Codable {
var description: String
var students: Array<StudentMap>
enum CodingKeys: String, CodingKey {
case description = "description"
case students = "students"
}
}
import {StudentMap} from "./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"
}
Imports System.Text.Json.Serialization
Public Class Faculty
<JsonPropertyName("description")>
Public Property Description As String
<JsonPropertyName("students")>
Public Property Students As StudentMap()
End Class