oas/json_schema

Types

Node in the Specification that might be represented by a reference.

pub type Ref(t) {
  Ref(
    ref: String,
    summary: option.Option(String),
    description: option.Option(String),
  )
  Inline(value: t)
}

Constructors

Represents a decoded JSON schema.

Chosen to add metadata inline as it doesn’t belong on ref object https://json-schema.org/draft/2020-12/json-schema-validation#name-a-vocabulary-for-basic-meta

pub type Schema {
  Boolean(
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Integer(
    multiple_of: option.Option(Int),
    maximum: option.Option(Int),
    exclusive_maximum: option.Option(Int),
    minimum: option.Option(Int),
    exclusive_minimum: option.Option(Int),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Number(
    multiple_of: option.Option(Int),
    maximum: option.Option(Int),
    exclusive_maximum: option.Option(Int),
    minimum: option.Option(Int),
    exclusive_minimum: option.Option(Int),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  String(
    max_length: option.Option(Int),
    min_length: option.Option(Int),
    pattern: option.Option(String),
    format: option.Option(String),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Null(
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Array(
    max_items: option.Option(Int),
    min_items: option.Option(Int),
    unique_items: Bool,
    items: Ref(Schema),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Object(
    properties: dict.Dict(String, Ref(Schema)),
    required: List(String),
    additional_properties: option.Option(Ref(Schema)),
    max_properties: option.Option(Int),
    min_properties: Int,
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  AllOf(non_empty_list.NonEmptyList(Ref(Schema)))
  AnyOf(non_empty_list.NonEmptyList(Ref(Schema)))
  OneOf(non_empty_list.NonEmptyList(Ref(Schema)))
  Enum(non_empty_list.NonEmptyList(utils.Any))
  AlwaysPasses
  AlwaysFails
}

Constructors

Values

pub fn array(items: Ref(Schema)) -> Schema
pub fn boolean() -> Schema
pub fn encode(schema: Schema) -> json.Json
pub fn enum_of_strings(
  strings: non_empty_list.NonEmptyList(String),
) -> Schema
pub fn field(key: a, schema: b) -> #(a, Ref(b), Bool)
pub fn integer() -> Schema
pub fn null() -> Schema
pub fn number() -> Schema
pub fn object(
  properties: List(#(String, Ref(Schema), Bool)),
) -> Schema
pub fn optional_field(key: a, schema: b) -> #(a, Ref(b), Bool)
pub fn ref_decoder(
  of: decode.Decoder(t),
) -> decode.Decoder(Ref(t))
pub fn string() -> Schema
pub fn to_fields(schema: Schema) -> dict.Dict(String, utils.Any)
Search Document