jsonapi_compliable 0.10.4 → 0.10.5

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: f0dfed95b2e591f55607d09e2e9474d3b829c2c5
4
- data.tar.gz: fdcb00d3692b33d53723c8fdf36e567d46b4548d
3
+ metadata.gz: 9cb1bfc6c5708240c5117381e7b67d0187984df6
4
+ data.tar.gz: 90409ae0cea6bb561eefb3e652703994691fadb9
5
5
  SHA512:
6
- metadata.gz: 3d5358d1bcf58341f5e77d4213a4b975390f6c97846ac21401c0d21996a97cc6c5dcaeeb4a79e0256c2bc9bb33ae2ce828157ac2bdf733cdcf08c6256d26095e
7
- data.tar.gz: f5140772a00d7cde5f1b73a889dee660eb7d3fd895a1a710d3ff6be827ebedea47484ad115d67a15a423ebcd5f6892c962b61660c3a2afe7429e4918996fdcd7
6
+ metadata.gz: cdc0ee68b9c6e1310aaaad7cdfb12aec895477f1ff5d6990b42887521652766cbacc9e057a605b5fe8d913cc713e052162b4b1afa476e9f171a7c7f12004465e
7
+ data.tar.gz: a58368863fe6abd409d19d32e05243f4375cb5ffaf35e51acb0b9038e05ab9a3c43bc44edab2af33ad4021025c3ba5422177252b96e58821b95953ee38ded256
@@ -33,6 +33,7 @@ module Jsonapi
33
33
  generate_route
34
34
  generate_tests
35
35
  generate_resource
36
+ generate_swagger if docs_controller?
36
37
  end
37
38
 
38
39
  private
@@ -68,6 +69,19 @@ module Jsonapi
68
69
  'ApplicationResource'.safe_constantize.present?
69
70
  end
70
71
 
72
+ def docs_controller?
73
+ File.exists?('app/controllers/docs_controller.rb')
74
+ end
75
+
76
+ def generate_swagger
77
+ code = " jsonapi_resource '/v1/#{type}'"
78
+ code << ", only: [#{actions.map { |a| ":#{a}" }.join(', ')}]" if actions.length < 5
79
+ code << "\n"
80
+ inject_into_file 'app/controllers/docs_controller.rb', before: /^end/ do
81
+ code
82
+ end
83
+ end
84
+
71
85
  def generate_spec_payload
72
86
  to = File.join('spec/payloads', class_path, "#{file_name}.rb")
73
87
  template('payload.rb.erb', to)
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.10.4"
2
+ VERSION = "0.10.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_compliable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond