Sha256: e791af3fe9f4b92a9a861ac383a33bd77d07624a747aca9494c9dd999cb7e245
Contents?: true
Size: 1017 Bytes
Versions: 20
Compression:
Stored size: 1017 Bytes
Contents
require_relative "./util" require_relative "./header" module Swagger class Schema class Headers def initialize(schema) @schema = schema end def [](name) header = Util.try_hash(@schema, name) Header.new(header) if header end def to_json_schema return { "type" => "object" } unless @schema properties = {} required = [] @schema.each do |_name, param| name = _name.to_s header = Header.new(param) properties[name] = header.to_json_schema required << name if header.required if Util.try_hash(properties[name], :type).to_s == "string" && !parameter.allowEmptyValue && Util.try_hash(properties[name], :minLength).nil? properties[name]["minLength"] = 1 end end schema = { "type" => "object", "properties" => properties } schema["required"] = required unless required.empty? schema end end end end
Version data entries
20 entries across 20 versions & 1 rubygems