class Jdoc::Property
Attributes
name[R]
Public Class Methods
new(name: nil, schema: nil)
click to toggle source
@param name [String] @param schema [JsonSchema::Schema]
# File lib/jdoc/property.rb, line 7 def initialize(name: nil, schema: nil) @name = name @schema = schema end
Public Instance Methods
description()
click to toggle source
@return [String, nil] Description text, defined in description property
# File lib/jdoc/property.rb, line 24 def description @schema.description end
example()
click to toggle source
@return [String, nil] Example value, defined in example property
# File lib/jdoc/property.rb, line 29 def example if @schema.data.has_key?("example") %<`#{@schema.data["example"].inspect}`> end end
format()
click to toggle source
@return [Stirng, nil] Format constraint, defined in format property
# File lib/jdoc/property.rb, line 43 def format @schema.format end
options()
click to toggle source
@return [Hash] Key-Value pair of metadata of this property
# File lib/jdoc/property.rb, line 13 def options { Example: example, Type: type, Format: format, Pattern: pattern, ReadOnly: read_only, }.reject {|key, value| value.nil? } end
pattern()
click to toggle source
@return [String, nil] Pattern constraint, defined in pattern property
# File lib/jdoc/property.rb, line 36 def pattern if str = @schema.pattern "`#{str.inspect}`" end end
read_only()
click to toggle source
@return [true, nil] True if readOnly property is defined and it's true
# File lib/jdoc/property.rb, line 48 def read_only true if @schema.read_only == true end
type()
click to toggle source
@return [String, nil] Possible types defined in type property
# File lib/jdoc/property.rb, line 53 def type unless @schema.type.empty? @schema.type.join(", ") end end