View Source ndto_parser_json_schema behaviour (ndto v0.3.1)

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

-type ctx() :: #{base_path := binary(), base_name := binary(), resolved := [binary()], spec := spec()}.
-type opts() :: #{name => atom()}.
-type spec() :: njson:t().
-opaque t()
A parser is a module that implements the ndto_parser_json_schema behaviour.

Callbacks

-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

Link to this function

clean_optionals(RawValue)

View Source
-spec clean_optionals(RawValue) -> Value when RawValue :: term(), Value :: term().
-spec get(Keys, Spec) -> Result when Keys :: [binary()], Spec :: map(), Result :: term().
-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.
-spec parse_spec(SpecPath) -> Result
              when
                  SpecPath :: binary(),
                  Result :: {ok, Spec} | {error, Reason},
                  Spec :: ndto_parser:spec(),
                  Reason :: term().
-spec resolve_ref(Ref, CTX) -> Result
               when
                   Ref :: binary(),
                   CTX :: ctx(),
                   Result :: {NewResolved, NewSchema, NewCTX},
                   NewResolved :: binary(),
                   NewSchema :: ndto:schema(),
                   NewCTX :: ctx().