mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
49 lines
962 B
Ruby
49 lines
962 B
Ruby
# frozen_string_literal: true
|
|
|
|
class RelationshipSchema
|
|
def self.schema(resource_name = nil)
|
|
{
|
|
type: :object,
|
|
properties: {
|
|
data: {
|
|
type: :object,
|
|
properties: {
|
|
id: { type: :string },
|
|
type: { type: :string, example: resource_name }
|
|
}
|
|
},
|
|
links: {
|
|
type: :object,
|
|
properties: {
|
|
related: { type: :string }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
end
|
|
|
|
def self.collection(resource_name = nil)
|
|
{
|
|
type: :object,
|
|
properties: {
|
|
data: {
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
properties: {
|
|
id: { type: :string },
|
|
type: { type: :string, example: resource_name }
|
|
}
|
|
}
|
|
},
|
|
links: {
|
|
type: :object,
|
|
properties: {
|
|
related: { type: :string }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
end
|
|
end
|