Class: Granola::SchemaSerializer

Inherits:
Serializer show all
Defined in:
lib/granola/schema.rb

Overview

Public: Schema serializer to render your JSON schemas.

Example:

serializer = SchemaSerializer.new(PersonSerializer.schema)
serializer.to_json

Instance Attribute Summary

Attributes inherited from Serializer

#object

Instance Method Summary collapse

Methods inherited from Serializer

#initialize, list, #to_json

Methods included from Caching

#cache_key, #last_modified

Methods included from Granola::Serializer::Schema

included, #valid?, #validation_errors

Constructor Details

This class inherits a constructor from Granola::Serializer

Instance Method Details

#attributesObject



55
56
57
58
59
60
# File 'lib/granola/schema.rb', line 55

def attributes
  {
    "$schema".freeze => "http://json-schema.org/schema#".freeze,
    "type".freeze => "object".freeze
  }.merge(object)
end

#mime_typeObject



62
63
64
# File 'lib/granola/schema.rb', line 62

def mime_type
  "application/schema+json".freeze
end