lib/schemacop/v3/node.rb in schemacop-3.0.23 vs lib/schemacop/v3/node.rb in schemacop-3.0.24
- old
+ new
@@ -6,10 +6,11 @@
attr_reader :default
attr_reader :title
attr_reader :description
attr_reader :options
attr_reader :parent
+ attr_reader :require_key
class_attribute :_supports_children
self._supports_children = nil
def self.supports_children(name: false)
@@ -48,11 +49,11 @@
return node
end
def self.allowed_options
- %i[name required default description examples enum parent options title as]
+ %i[name required default description examples enum parent options title as require_key]
end
def self.dsl_methods
%i[dsl_scm dsl_node]
end
@@ -85,10 +86,11 @@
@default = options.delete(:default)
@title = options.delete(:title)
@description = options.delete(:description)
@examples = options.delete(:examples)
@enum = options.delete(:enum)&.to_set
+ @require_key = !!options.delete(:require_key)
@parent = options.delete(:parent)
@options = options
@schemas = {}
# Run subclass init #
@@ -134,10 +136,14 @@
def required?
@required
end
+ def require_key?
+ @require_key
+ end
+
def as_json
process_json([], {})
end
def cast(value)
@@ -179,9 +185,10 @@
json[:title] = @title if @title
json[context.swagger_json? ? :example : :examples] = @examples if @examples
json[:description] = @description if @description
json[:default] = @default unless @default.nil?
json[:enum] = @enum.to_a if @enum
+ json[:require_key] = @require_key if @require_key
return json.as_json
end
def type_assertion_method