Schema

class Schema<T : Any?>


Represents a parameter for a declared function

Summary

Public companion functions

Schema<List<String>>
arr(name: String, description: String)

Registers a schema for an array

Schema<Boolean>
bool(name: String, description: String)

Registers a schema for a boolean

Schema<String>
enum(name: String, description: String, values: List<String>)

Registers a schema for an enum

Schema<Long>
int(name: String, description: String)

Registers a schema for an integer number

Schema<Double>
num(name: String, description: String)

Registers a schema for a floating point number

Schema<JSONObject>
obj(name: String, description: String)

Registers a schema for a complex object.

Schema<String>
str(name: String, description: String)

Registers a schema for a string

Public constructors

<T : Any?> Schema(
    name: String,
    description: String,
    format: String?,
    enum: List<String>?,
    properties: Map<StringSchema<Any>>?,
    required: List<String>?,
    items: Schema<Any>?,
    type: FunctionType<T>
)

Public functions

T?
fromString(value: String?)

Parses an instance of this Schema from the provided String.

Public properties

String

: The description of what the parameter should contain or represent

List<String>?

: contains the enum values for a string enum

String?

: format information for the parameter, this can include bitlength in the case of int/float or keywords like "enum" for the string type

Schema<Any>?

: if the type is ARRAY, then this contains a description of the objects in the array

String

: The name of the parameter

Map<StringSchema<Any>>?

: if type is OBJECT, then this contains the description of the fields of the object by name

List<String>?

: if type is OBJECT, then this contains the list of required keys

FunctionType<T>

: contains the type info and parser

Public companion functions

arr

fun arr(name: String, description: String): Schema<List<String>>

Registers a schema for an array

bool

fun bool(name: String, description: String): Schema<Boolean>

Registers a schema for a boolean

enum

fun enum(name: String, description: String, values: List<String>): Schema<String>

Registers a schema for an enum

int

fun int(name: String, description: String): Schema<Long>

Registers a schema for an integer number

num

fun num(name: String, description: String): Schema<Double>

Registers a schema for a floating point number

obj

fun obj(name: String, description: String): Schema<JSONObject>

Registers a schema for a complex object. In a function it will be returned as a JSONObject

str

fun str(name: String, description: String): Schema<String>

Registers a schema for a string

Public constructors

Schema

<T : Any?> Schema(
    name: String,
    description: String,
    format: String? = null,
    enum: List<String>? = null,
    properties: Map<StringSchema<Any>>? = null,
    required: List<String>? = null,
    items: Schema<Any>? = null,
    type: FunctionType<T>
)

Public functions

fromString

fun fromString(value: String?): T?

Parses an instance of this Schema from the provided String.

This is done via the parse method of type.

Public properties

description

val descriptionString

: The description of what the parameter should contain or represent

enum

val enumList<String>?

: contains the enum values for a string enum

format

val formatString?

: format information for the parameter, this can include bitlength in the case of int/float or keywords like "enum" for the string type

items

val itemsSchema<Any>?

: if the type is ARRAY, then this contains a description of the objects in the array

name

val nameString

: The name of the parameter

properties

val propertiesMap<StringSchema<Any>>?

: if type is OBJECT, then this contains the description of the fields of the object by name

required

val requiredList<String>?

: if type is OBJECT, then this contains the list of required keys

type

val typeFunctionType<T>

: contains the type info and parser