module Croods::Resource::JsonSchema

Public Instance Methods

json_schema() click to toggle source
# File lib/croods/resource/json_schema.rb, line 12
def json_schema
  return @json_schema if @json_schema

  path = File.expand_path('json_schema/initial_schema.json', __dir__)
  @json_schema = JSON.parse(File.read(path))
  @json_schema['definitions'] = Definitions.schema(self)
  @json_schema['properties'] = Properties.schema(self)
  @json_schema['required'] = Required.schema(self)
  @json_schema['links'] = Links.schema(self)
  @json_schema
end
ref(attribute = nil) click to toggle source
# File lib/croods/resource/json_schema.rb, line 24
def ref(attribute = nil)
  {
    '$ref': "#/definitions/#{resource_name}" +
      (attribute ? "/definitions/#{attribute}" : '')
  }
end