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 +4 -4
- data/lib/generators/jsonapi/resource_generator.rb +14 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb1bfc6c5708240c5117381e7b67d0187984df6
|
4
|
+
data.tar.gz: 90409ae0cea6bb561eefb3e652703994691fadb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|