Module: Croods::Resource::JsonSchema::Links::Update

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

Class Method Summary collapse

Class Method Details



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

def link(resource)
  {
    href: resource.member_path,
    method: 'PUT',
    rel: 'self',
    schema: schema(resource),
    targetSchema: target_schema(resource)
  }
end

.schema(resource) ⇒ Object



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

def schema(resource)
  {
    additionalProperties: false,
    properties: Properties.schema(resource, request: true),
    type: ['object']
  }
end

.target_schema(resource) ⇒ Object



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

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