rspec-api-docs 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60a330ec02c82ad9a129e508386c67e173c0cd81
4
- data.tar.gz: fed6d9f849bf9e1cee2cb44f04abce403353a064
3
+ metadata.gz: b6e7c92209d8f94e43eb1a790f207e172304477e
4
+ data.tar.gz: 4cd8916ae2205054cf17803fc987b098261a09ef
5
5
  SHA512:
6
- metadata.gz: bc1785537527f94c561951c4ab62c6a0d37da817c26be4f55f8acbdaba7fc9cf14b31046c088a509b170a3fc36bb7484aa5c8d8fb93b956f5e7dd451572387cc
7
- data.tar.gz: a258eba2025273e8f43a710d2f813c61633b7284d3a47714ed98b415557d54bbd4c6e88c0a29df19cd06597ad835a91cd16d5cc19cd78f4e7a20aab7cb2e416a
6
+ metadata.gz: 99b1b8b472fcb9ea6c0e459e69ab99e27ab9d69c5117a2eaf90c0e5d5c95e37eb6249af8d305ea66f85e2dbd05cec52675b756db3eafbdbcf1c4f28ff46cbac0
7
+ data.tar.gz: 67d2c88fad377d95d1b2a076cf07a57793cb0e925d9f22c34339d97ea220df58bbc5c5c11d540a2c4051e3457db55f24488f24370317b0933f7bf08aa07494fb
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'active_support/core_ext/hash/keys'
2
3
  require 'rspec_api_docs/formatter/renderer/json_renderer/name'
3
4
  require 'rspec_api_docs/formatter/renderer/json_renderer/resource_serializer'
4
5
 
@@ -23,7 +24,17 @@ module RspecApiDocs
23
24
 
24
25
  def output
25
26
  resources.map do |resource|
26
- ResourceSerializer.new(resource).to_h
27
+ format_hash ResourceSerializer.new(resource).to_h
28
+ end
29
+ end
30
+
31
+ def format_hash(hash)
32
+ hash.deep_transform_keys do |key|
33
+ if key =~ /\A[a-z]/
34
+ key.to_s.camelize(:lower).to_sym
35
+ else
36
+ key
37
+ end
27
38
  end
28
39
  end
29
40
 
@@ -8,22 +8,22 @@ module RspecApiDocs
8
8
  @example = example
9
9
  end
10
10
 
11
- def to_h # rubocop:disable Metrics/AbcSize
11
+ def to_h
12
12
  {
13
13
  description: example.description,
14
14
  name: example.name,
15
- httpMethod: example.http_method,
16
- parameters: parameters(example.parameters),
15
+ http_method: example.http_method,
16
+ parameters: parameters,
17
17
  path: example.path,
18
18
  requests: example.requests,
19
- responseFields: response_fields(example.response_fields),
19
+ response_fields: response_fields,
20
20
  }
21
21
  end
22
22
 
23
23
  private
24
24
 
25
- def parameters(parameters)
26
- parameters.map do |parameter|
25
+ def parameters
26
+ example.parameters.map do |parameter|
27
27
  {
28
28
  name: Name.(name: parameter.name, scope: parameter.scope),
29
29
  description: parameter.description,
@@ -32,8 +32,8 @@ module RspecApiDocs
32
32
  end
33
33
  end
34
34
 
35
- def response_fields(fields)
36
- fields.map do |field|
35
+ def response_fields
36
+ example.response_fields.map do |field|
37
37
  {
38
38
  name: Name.(name: field.name, scope: field.scope),
39
39
  description: field.description,
@@ -1,3 +1,3 @@
1
1
  module RspecApiDocs
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-api-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Odin Dutton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-31 00:00:00.000000000 Z
11
+ date: 2017-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport