class Jargon::Schema

Overview

A parsed JSON Schema describing one command: its #root property (the object whose properties are the command's options), the named #positional arguments, and any reusable #definitions ($defs/#definitions) that $ref resolves against.

Defined in:

jargon/schema.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_file(path : String) : Schema #

Build a Schema from a JSON Schema file.


[View source]
def self.from_json(json_string : String) : Schema #

Build a Schema from a JSON Schema document (string).


[View source]
def self.from_json_any(json : JSON::Any) : Schema #

Build a Schema from an already-parsed JSON document. The whole document is the root property; #positional and #definitions/$defs are lifted out alongside it.


[View source]
def self.new(root : Property, definitions : Hash(String, Property) = {} of String => Property, positional : Array(String) = [] of String) #

[View source]

Instance Method Detail

def definitions : Hash(String, Property) #

[View source]
def positional : Array(String) #

[View source]
def resolve_ref(ref : String) : Property | Nil #

Resolve a local $ref pointer (e.g. #/$defs/Name) to its definition, or nil if the pointer is non-local or unknown.


[View source]
def root : Property #

[View source]