Module: Croods::Resource::JsonSchema::Links::Member

Defined in:
lib/croods/resource/json_schema/links/member.rb

Class Method Summary collapse

Class Method Details



9
10
11
12
13
14
15
16
17
# File 'lib/croods/resource/json_schema/links/member.rb', line 9

def link(resource, action)
  {
    href: "#{resource.member_path}/#{action.name}",
    method: action.method.upcase,
    rel: 'self',
    schema: schema,
    targetSchema: target_schema(resource)
  }
end

.schemaObject



19
20
21
22
23
24
25
# File 'lib/croods/resource/json_schema/links/member.rb', line 19

def schema
  {
    strictProperties: true,
    properties: {},
    type: ['object']
  }
end

.target_schema(resource) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/croods/resource/json_schema/links/member.rb', line 27

def target_schema(resource)
  {
    anyOf: [
      resource.ref,
      { '$ref': '#/definitions/error' }
    ]
  }
end