Dry::Types::JSONSchema
Example
Dry::Types.load_extensions(:json_schema)
AnnotatedString = Dry::Types["string"].meta(format: :email, title: "Notes")
AnnotatedString.json_schema
module Types
include Dry.Types()
end
class StructTest < Dry::Struct
schema schema.meta(title: "Title", description: "description")
VariableList = Types::Array
.of(Types::String | Types::Hash)
.constrained(min_size: 1)
.meta(description: "Allow an array of strings or multiple hashes")
attribute :data, Types::String | Types::Hash
attribute :string, Types::String.constrained(min_size: 1, max_size: 255)
attribute :list, VariableList
end
StructTest.json_schema