JsonSchema.Types.ConstType (json_schema v0.6.0)

Copy Markdown View Source

Represents a custom const type definition in a JSON schema.

JSON Schema:

"favoriteNumber": {
  "type": "integer",
  "const": 42
}

or

"testStruct": {
  "const": {
    "name": "Test",
    "foo": 43
  }
}

Resulting in the Elixir representation:

%ConstType{name: "favoriteNumber",
           description: nil,
           type: :number,
           path: URI.parse("#/favoriteNumber"),
           const: 42}

or

%ConstType{name: "testStruct",
           description: nil,
           type: :object,
           path: URI.parse("#/testStruct"),
           const: %{"name" => "Test", "foo" => 43}}

Summary

Types

t()

@type t() :: %JsonSchema.Types.ConstType{
  const: value(),
  description: String.t() | nil,
  name: String.t() | :anonymous,
  path: URI.t(),
  type: value_type()
}

value()

@type value() :: nil | boolean() | integer() | number() | String.t() | map() | list()

value_type()

@type value_type() ::
  :null | :boolean | :integer | :number | :string | :object | :array