class Swarker::Definition
Constants
- PROPERTIES_FIELD
- REF
- REQUIRED_FIELD
Attributes
name[R]
schema[R]
Public Class Methods
new(name, original_schema)
click to toggle source
# File lib/swarker/definition.rb, line 9 def initialize(name, original_schema) @name = name @original_schema = original_schema move_required_fields fix_refs end
Private Instance Methods
fix_refs()
click to toggle source
# File lib/swarker/definition.rb, line 27 def fix_refs properties.each_value do |property| property[REF].sub!(%r{.json#/}, '').sub!(%r{(\.\./)+}, '#/') if property[REF] end end
move_required_fields()
click to toggle source
# File lib/swarker/definition.rb, line 18 def move_required_fields requred_properties = @original_schema.fetch(REQUIRED_FIELD) @schema = @original_schema.reject { |k| k == REQUIRED_FIELD } requred_properties.each do |property| properties[property][REQUIRED_FIELD] = true end end
properties()
click to toggle source
# File lib/swarker/definition.rb, line 33 def properties schema[PROPERTIES_FIELD] end