Skip to content

Instantly share code, notes, and snippets.

@carlesjove
Last active August 29, 2015 14:17
Show Gist options
  • Save carlesjove/239163a50f15c6f48def to your computer and use it in GitHub Desktop.
Save carlesjove/239163a50f15c6f48def to your computer and use it in GitHub Desktop.
Draft for a CJ Spec definition that includes meta data
# Commented lines mean that this would be the assumption unless otherwise is not specified
# so:
# unless validates_as: is specified, it is validated as a :string
# unless required: true is specified, it is required: false
module CollectionJson
module Spec
definition do
defines :href, validates_as: :url
defines :links do
defines :href, required: true, validates_as: :url
defines :rel, required: true
defines :name # required: false, validates_as: :string
defines :prompt
defines :render
end
defines :items do
defines :href
defines :data
defines :name, required: true
defines :value
defines :prompt
end
defines :links
defines :href, required: true, validates_as: :url
defines :rel, required: true
defines :name
defines :prompt
defines :render
end
end
defines :template
defines :data
defines :name, required: true
defines :value
defines :prompt
end
end
defines :queries
defines :href, required: true, validates_as: :url
defines :rel, required: true
defines :name
defines :prompt
defines :data
defines :name, required: true
defines :value
end
end
defines :error
defines :title
defines :code
defines :message
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment