class Rage::OpenAPI::Parsers::YAML
def __parse(object)
def __parse(object) spec = {} if object.is_a?(Hash) spec = { "type" => "object", "properties" => {} } object.each do |key, value| spec["properties"][key] = if value.is_a?(Enumerable) __parse(value) else type_to_spec(value) end end elsif object.is_a?(Array) && object.length == 1 spec = { "type" => "array", "items" => object[0].is_a?(Enumerable) ? __parse(object[0]) : type_to_spec(object[0]) } elsif object.is_a?(Array) spec = { "type" => "string", "enum" => object } end spec end
def initialize(**)
def initialize(**) end
def known_definition?(yaml)
def known_definition?(yaml) object = YAML.safe_load(yaml) rescue nil !!object && object.is_a?(Enumerable) end
def parse(yaml)
def parse(yaml) __parse(YAML.safe_load(yaml)) end
def type_to_spec(type)
def type_to_spec(type) Rage::OpenAPI.__type_to_spec(type) || { "type" => "string", "enum" => [type] } end