jsonapionify 0.12.9 → 0.12.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDY5OTI1YzBhMWMzMjE1NmNiYjM3NTM5NWI2Y2FhNWJmMDI3ZDYyMQ==
4
+ ZDU0ZmY4YTUxZTBiMzRmYWI3ZGYzODE3YmVmYTA0NWIyNzJmNjczNg==
5
5
  data.tar.gz: !binary |-
6
- MTRiNTI3NTI4ODhjZTk1NzNiNzExYzBmOTU5NjE2ZTliZjRmN2Y4Zg==
6
+ YjAxNzVhMzI3YjZmODhkZDI2NDM5M2U2ZThhOTYzNmQ3MDBjZjEwZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGM4NTlkMDAxYWE5YjAwZDIwNjA4YjQ3NTE2MGU2MTM3MTI0ZTJlZTUzOWFk
10
- OTFmODZjN2EzODhiYmU0ZjdjNWQ3YmU0YjdiNTIxZDI5NDRmMzRmMTAxYzFk
11
- MjUxYjUyNjA3NTNlZjk1ZDIxNjgzNzJhM2RiNDM0MWU2ODkxNGY=
9
+ NDNhNjZlNzZiZTI3ZDZhM2IzZDMwMmZhZjQ1YmM0ZGU5NDAyNmFjMWJiNDky
10
+ YjAyOGM5NDk5NjMxMWJkMDg0YjVlZGQ0NjA4MjBmOGEwMzVlYzhiYjAzMmEy
11
+ ZTMyYjVhZWI3MTEwMjk0YzExOWRhMWQ4NjU0NmE3ZmNmOTY4MjI=
12
12
  data.tar.gz: !binary |-
13
- MzI4NDUyZTQyZTgyOTdiNWJiZjZkNzE0Y2JiYWRhZTYzMzY0MDVjNjM2ZWMy
14
- MTAwOWFkNmJjZmJkNmUwZmMzZmE0MjQ3NTI1MjkyNTQ2M2U3MjJlMzBmMDQ1
15
- MmNkNjY2OGVhZDBkMzY3NmU0NWY3NDU5ZjM5ZDQ1ZmFkNzRlNDc=
13
+ MTdhOTRkYmUwZTU4MTQwMDM1NzE5YTljNmY5NGI4NDE0ZTE2OGViNTRjYTRh
14
+ M2U5ZmUwODUxMmM0ZWMzMzVhMzQ1YWQ2YTI4ZDk3ZDc4ZjQyOWJmOGIyODZh
15
+ ZmVhODdmN2JhNWM1YzNiNjY3MjY1YjhmZmIxYWMyMzFlNWI3YWQ=
@@ -37,7 +37,9 @@ module JSONAPIonify
37
37
  end
38
38
 
39
39
  def self.files
40
- Dir.glob(File.join __dir__, './**/*.rb').map { |f| File.expand_path f }.sort
40
+ files = Dir.glob(File.join __dir__, './**/*.rb').map { |f| File.expand_path f }
41
+ files << File.expand_path('./jsonapionify/documentation/template.erb', __dir__)
42
+ files.sort
41
43
  end
42
44
 
43
45
  def self.digest
@@ -48,36 +48,14 @@ module JSONAPIonify::Api
48
48
  accept = response.accept || response.example_accept
49
49
  opts['HTTP_ACCEPT'] = accept
50
50
  if content_type == 'application/vnd.api+json' && @example_input
51
- opts[:input] = example_input(resource)
51
+ opts[:input] = "{ ...request body... }"
52
52
  end
53
53
  url = "#{url}.#{response.extension}" if response.extension
54
54
  request = Server::Request.env_for(url, request_method, opts)
55
- response = Server::MockResponse.new(*sample_request(resource, request))
56
-
57
55
  OpenStruct.new(
58
56
  request: request.http_string,
59
- response: response.http_string
60
57
  )
61
58
  end
62
59
  end
63
-
64
- def sample_context(resource)
65
- action = self
66
- resource.context_definitions.dup.tap do |defs|
67
- collection_context = proc do |context|
68
- 3.times.map { resource.example_instance_for_action(action.name, context) }
69
- end
70
- defs[:_is_example_] = Context.new(:_is_example_, readonly: true) { true }
71
- defs[:collection] = Context.new(:collection, &collection_context)
72
- defs[:paginated_collection] = Context.new(:paginated_collection) { |collection:| collection }
73
- defs[:instance] = Context.new(:instance, readonly: true) { |collection:| collection.first }
74
- defs[:owner_context] = Context.new(:owner_context, readonly: true) { ContextDelegate::Mock.new } if defs.has_key? :owner_context
75
- defs[:action] = Context.new(:action, readonly: true) { action }
76
- end
77
- end
78
-
79
- def sample_request(resource, request)
80
- call(resource, request, context_definitions: sample_context(resource), callbacks: false)
81
- end
82
60
  end
83
61
  end
@@ -66,6 +66,10 @@ module JSONAPIonify::Api
66
66
  with_value @default
67
67
  end
68
68
 
69
+ def default_value
70
+ @default
71
+ end
72
+
69
73
  def extract_value(params)
70
74
  keypath.reduce(params) do |p, key|
71
75
  p[key.to_s]
@@ -16,11 +16,13 @@ module JSONAPIonify::Api
16
16
 
17
17
  def documentation_object(base_url)
18
18
  OpenStruct.new(
19
- name: type,
20
- description: JSONAPIonify::Documentation.render_markdown(@description || ''),
21
- relationships: relationships.map { |r| r.documentation_object },
22
- attributes: attributes.sort_by(&:name).map(&:documentation_object),
23
- actions: documented_actions_in_order.map do |action, base, args|
19
+ name: type,
20
+ description: JSONAPIonify::Documentation.render_markdown(@description || ''),
21
+ relationships: relationships.map { |r| r.documentation_object },
22
+ request_headers: request_header_definitions.values.map { |h| OpenStruct.new name: h.name, required: h.required, actions: h.actions },
23
+ params: param_definitions.values.map { |p| OpenStruct.new name: p.string, required: p.required, default: p.default_value }.reject { |p| p.name.start_with? 'fields[' },
24
+ attributes: attributes.sort_by(&:name).map(&:documentation_object),
25
+ actions: documented_actions_in_order.map do |action, base, args|
24
26
  action.documentation_object File.join(base_url, base), *args
25
27
  end
26
28
  )
@@ -381,6 +381,51 @@
381
381
  <p><%= resource.description %></p>
382
382
 
383
383
  <div class="details">
384
+ <% if resource.request_headers.present? %>
385
+ <h4 id="<%= resource.name %>-params">Request Headers</h4>
386
+ <ul class="attributes">
387
+ <% resource.request_headers.each do |header| %>
388
+ <li>
389
+ <div class="row-attribute">
390
+ <div class="col-xs-4 param-name">
391
+ <strong><%= header.name %></strong>
392
+ <% if header.required %>
393
+ <p class="optional">required: <%= header.required %></p>
394
+ <% else %>
395
+ <p class="optional">optional</p>
396
+ <% end %>
397
+ </div>
398
+ <div style="clear: both;"></div>
399
+ </div>
400
+ </li>
401
+ <% end %>
402
+ </ul>
403
+ <% end %>
404
+
405
+ <% if resource.params.present? %>
406
+ <h4 id="<%= resource.name %>-params">Query Params</h4>
407
+ <ul class="attributes">
408
+ <% resource.params.each do |param| %>
409
+ <li>
410
+ <div class="row-attribute">
411
+ <div class="col-xs-4 param-name">
412
+ <strong><%= param.name %></strong>
413
+ <% if param.default.present? %>
414
+ <i class="attribute-default">&mdash; default: <%= param.default %></i>
415
+ <% end %>
416
+ <% if param.required %>
417
+ <p class="optional">required: <%= param.required %></p>
418
+ <% else %>
419
+ <p class="optional">optional</p>
420
+ <% end %>
421
+ </div>
422
+ <div style="clear: both;"></div>
423
+ </div>
424
+ </li>
425
+ <% end %>
426
+ </ul>
427
+ <% end %>
428
+
384
429
  <% if resource.attributes.present? %>
385
430
  <h4 id="<%= resource.name %>-attributes">Attributes</h4>
386
431
  <ul class="attributes">
@@ -423,8 +468,6 @@
423
468
  <% action.sample_requests.each do |sample_request| %>
424
469
  <h5>Request</h5>
425
470
  <pre><code class="http"><%= sample_request.request %></code></pre>
426
- <h5>Response</h5>
427
- <pre><code class="http"><%= sample_request.response %></code></pre>
428
471
  <% end %>
429
472
  <% end %>
430
473
  </div>
@@ -1,3 +1,3 @@
1
1
  module JSONAPIonify
2
- VERSION = "0.12.9"
2
+ VERSION = "0.12.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapionify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.9
4
+ version: 0.12.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Waldrip
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport