{
"definitions": {
"Student": {
"description": "A simple student struct",
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"root": "Student"
}
module TypeSchema
# A simple student struct
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
end
{
"definitions": {
"Human": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Student": {
"parent": {
"type": "reference",
"target": "Human"
},
"type": "struct",
"properties": {
"studentId": {
"type": "string"
}
}
}
},
"root": "Student"
}
module TypeSchema
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
end
module TypeSchema
class Student
extend Human
attr_accessor :student_id
def initialize(student_id)
@student_id = student_id
end
end
end
{
"definitions": {
"Student": {
"description": "A student struct with an assigned faculty",
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"faculty": {
"type": "reference",
"target": "Faculty"
}
}
},
"Faculty": {
"type": "struct",
"properties": {
"name": {
"type": "string"
}
}
}
},
"root": "Student"
}
module TypeSchema
# A student struct with an assigned faculty
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
end
module TypeSchema
class Faculty
attr_accessor :name
def initialize(name)
@name = name
end
end
end
{
"definitions": {
"Student": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"type": "map",
"schema": {
"type": "string"
}
}
}
}
},
"root": "Student"
}
module TypeSchema
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
end
{
"definitions": {
"Human": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"location": {
"type": "reference",
"target": "Location"
}
}
},
"Location": {
"type": "struct",
"base": true,
"properties": {
"type": {
"type": "string"
}
},
"discriminator": "type",
"mapping": {
"Web": "web",
"World": "world"
}
},
"Web": {
"parent": {
"type": "reference",
"target": "Location"
},
"type": "struct",
"properties": {
"url": {
"type": "string"
}
}
},
"World": {
"parent": {
"type": "reference",
"target": "Location"
},
"type": "struct",
"properties": {
"lat": {
"type": "string"
},
"long": {
"type": "string"
}
}
}
},
"root": "Human"
}
module TypeSchema
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
end
module TypeSchema
class Location
attr_accessor :type
def initialize(type)
@type = type
end
end
end
module TypeSchema
class Web
extend Location
attr_accessor :url
def initialize(url)
@url = url
end
end
end
module TypeSchema
class World
extend Location
attr_accessor :lat, :long
def initialize(lat, long)
@lat = lat
@long = long
end
end
end
{
"definitions": {
"Student": {
"type": "struct",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"type": "struct",
"parent": {
"type": "reference",
"target": "Map",
"template": {
"T": "Student"
}
}
},
"Map": {
"type": "struct",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"schema": {
"type": "generic",
"name": "T"
}
}
}
}
},
"root": "StudentMap"
}
module TypeSchema
class Student
attr_accessor :matricle_number
def initialize(matricle_number)
@matricle_number = matricle_number
end
end
end
module TypeSchema
class Map
attr_accessor :total_results, :entries
def initialize(total_results, entries)
@total_results = total_results
@entries = entries
end
end
end
module TypeSchema
class StudentMap
extend Map
def initialize()
end
end
end
{
"import": {
"my_ns": "file:///generic.json"
},
"definitions": {
"Faculty": {
"type": "struct",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"schema": {
"type": "reference",
"target": "my_ns:StudentMap"
}
}
}
}
},
"root": "Faculty"
}
module TypeSchema
class Faculty
attr_accessor :description, :students
def initialize(description, students)
@description = description
@students = students
end
end
end