ndto_parser_json_schema behaviour (ndto v0.3.1)

View Source
An ndto interface for parsing JSON Schemas.

Summary

Types

t/0
A parser is a module that implements the ndto_parser_json_schema behaviour.

Functions

Parses a JSONSchema specification into a list of ndto:schema() values.

Types

ctx/0

-type ctx() :: #{base_path := binary(), base_name := binary(), resolved := [binary()], spec := spec()}.

opts/0

-type opts() :: #{name => atom()}.

spec/0

-type spec() :: njson:t().

t/0

-opaque t()
A parser is a module that implements the ndto_parser_json_schema behaviour.

Callbacks

parse/2

-callback parse(Spec, CTX) -> Result
                   when
                       Spec :: spec(),
                       CTX :: ctx(),
                       Result :: {Schema, ExtraSchemas, NewCTX},
                       Schema :: ndto:schema(),
                       ExtraSchemas :: [{ndto:name(), ndto:schema()}],
                       NewCTX :: ctx().

Functions

clean_optionals(RawValue)

-spec clean_optionals(RawValue) -> Value when RawValue :: term(), Value :: term().

get(Keys, Spec)

-spec get(Keys, Spec) -> Result when Keys :: [binary()], Spec :: map(), Result :: term().

parse(SpecPath, Opts)

-spec parse(SpecPath, Opts) -> Result
               when
                   SpecPath :: file:filename_all(),
                   Opts :: opts(),
                   Result :: {ok, Schemas} | {error, Reason},
                   Schemas :: [{ndto:name(), ndto:schema()}],
                   Reason :: term().
Parses a JSONSchema specification into a list of ndto:schema() values.

parse_spec(SpecPath)

-spec parse_spec(SpecPath) -> Result
                    when
                        SpecPath :: binary(),
                        Result :: {ok, Spec} | {error, Reason},
                        Spec :: ndto_parser:spec(),
                        Reason :: term().

resolve_ref(Ref, CTX)

-spec resolve_ref(Ref, CTX) -> Result
                     when
                         Ref :: binary(),
                         CTX :: ctx(),
                         Result :: {NewResolved, NewSchema, NewCTX},
                         NewResolved :: binary(),
                         NewSchema :: ndto:schema(),
                         NewCTX :: ctx().