https://github.com/foca/granola-schema
JSON Schema support for Granola serialisers
https://github.com/foca/granola-schema
Last synced: 11 months ago
JSON representation
JSON Schema support for Granola serialisers
- Host: GitHub
- URL: https://github.com/foca/granola-schema
- Owner: foca
- License: mit
- Created: 2015-04-08T07:57:37.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-08T08:09:13.000Z (about 11 years ago)
- Last Synced: 2023-04-10T10:19:51.130Z (about 3 years ago)
- Language: Ruby
- Size: 117 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Granola <3 JSON Schema [](https://travis-ci.org/foca/granola-schema) [](https://rubygems.org/gems/granola-schema)
Support for defining [JSON schema][schema] for your Granola serializers.
[schema]: http://json-schema.org
## Example
``` ruby
require "granola/schema"
class PersonSerializer < Granola::Serializer
def self.schema
{
"type" => "object",
"required" => ["name", "email"],
"properties" => {
"name" => { "type" => "string" },
"email" => { "type" => "string" },
"age" => { "type" => "integer" },
}
}
end
def data
{
"name" => object.name,
"email" => object.email,
"age" => object.age
}
end
end
serializer = PersonSerializer.new(person)
serializer.valid? #=> true
```
## Install
gem install granola-schema
## License
This project is shared under the MIT license. See the attached [LICENSE][] file
for details.
[LICENSE]: ./LICENSE