annotation Schema::Param
Overview
An HTTP parameter annotation.
Options:
- key -- a key to use for (de)serializing. By default all possible variations
of the instance variable name are used (i.e.
"foo_bar"
,"fooBar"
,"FooBar"
,"foo-bar"
and"Foo-Bar"
for a@foo_bar
variable) - converter -- a converter to use for casting.
Some types implement converter forwarding, for example,
Array
:
require "schema"
require "schema/ext/time/epoch_converter"
struct MyParams
include Schema::Definition
@[Schema::Param(converter: Time::EpochConverter, key: "theTime")]
getter time : Array(Time)
end
params = MyParams.from_query("theTime[]=1544958806")
pp params.time.class # => Array(Time)