api_scaffold 0.1.7 → 0.1.8
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac9acf1f92a45c9c9b077bbe6b2e2fc37f97dccf04cd0cc843e01a08ebd7e14
|
4
|
+
data.tar.gz: bf06a96ba3a1124ce2cbc6ac0f30e457b189c33ab4e05660cf843e316acd2031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d841662ee53332f6d1df1477106c31f2285d37b5cd3d9c9f36c338222b80301b16cd785e949d35919115b0b1a01208023ca12b1170ee64d5a1f5de3693b3a0b5
|
7
|
+
data.tar.gz: 5d74353382a5bbd9300aee9dc6aec04ba22682648eda4802fc73ebbe21e898bb6c57fbde107b1f80ad4a095cc33e2966d015b3a1dbb9c195f7fdca039abf68f2
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
A useful Rails API generator for scaffolding. Compatible with :
|
4
4
|
- Fast JSON API/Active Model Serializers
|
5
|
-
- Rspec/TestUnit
|
5
|
+
- Rspec/TestUnit
|
6
|
+
- Fixtures/FactoryBot
|
6
7
|
- Api Pagination
|
7
8
|
- Apipie
|
8
9
|
|
@@ -42,7 +43,7 @@ If you wish to specify the api version:
|
|
42
43
|
$ rails g api_scaffold Book title description:text --api-version=2
|
43
44
|
|
44
45
|
## TODO
|
45
|
-
-
|
46
|
+
- Nested resources
|
46
47
|
|
47
48
|
## Contributing
|
48
49
|
|
data/lib/api_scaffold/version.rb
CHANGED
@@ -12,19 +12,19 @@ class <%= prefixed_controller_class_name %>Controller < ApplicationController
|
|
12
12
|
<% end -%>end
|
13
13
|
end
|
14
14
|
|
15
|
-
api
|
15
|
+
api :GET, '/<%= plural_table_name %>', 'List <%= plural_table_name %>'
|
16
16
|
<% end -%>def index
|
17
17
|
@<%= plural_table_name %> = <%= 'paginate ' if gem_available?('api-pagination') %><%= orm_class.all(class_name) %>
|
18
18
|
render json: <%= "@#{plural_table_name}" %>
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
def show
|
21
|
+
|
22
|
+
<% if apipie_installed? -%>api :GET, '/<%= [prefix, plural_table_name].join("/") %>/:id', 'Show <%= singular_table_name %>'
|
23
|
+
<% end -%>def show
|
24
24
|
render json: <%= "@#{singular_table_name}" %>
|
25
25
|
end
|
26
26
|
|
27
|
-
<% if apipie_installed? -%>api
|
27
|
+
<% if apipie_installed? -%>api :POST, '/<%= [prefix, plural_table_name].join("/") %>', 'Create <%= singular_table_name %>'
|
28
28
|
param_group :<%= singular_table_name %>
|
29
29
|
<% end -%>def create
|
30
30
|
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
@@ -36,7 +36,7 @@ class <%= prefixed_controller_class_name %>Controller < ApplicationController
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
<% if apipie_installed? -%>api
|
39
|
+
<% if apipie_installed? -%>api :PUT, '/<%= [prefix, plural_table_name].join("/") %>/:id', 'Update <%= singular_table_name %>'
|
40
40
|
param_group :<%= singular_table_name %>
|
41
41
|
<% end -%>def update
|
42
42
|
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
@@ -46,9 +46,8 @@ class <%= prefixed_controller_class_name %>Controller < ApplicationController
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
def destroy
|
49
|
+
<% if apipie_installed? -%>api :DELETE, '/<%= [prefix, plural_table_name].join("/") %>/:id', 'Delete <%= singular_table_name %>'
|
50
|
+
<% end -%>def destroy
|
52
51
|
@<%= orm_instance.destroy %>
|
53
52
|
end
|
54
53
|
|
@@ -12,19 +12,18 @@ class <%= prefixed_controller_class_name %>Controller < ApplicationController
|
|
12
12
|
<% end -%>end
|
13
13
|
end
|
14
14
|
|
15
|
-
api
|
15
|
+
api :GET, '/<%= [prefix, plural_table_name].join("/") %>', 'List <%= plural_table_name %>'
|
16
16
|
<% end -%>def index
|
17
17
|
@<%= plural_table_name %> = <%= 'paginate ' if gem_available?('api-pagination') %><%= orm_class.all(class_name) %>
|
18
18
|
render json: <%= class_name %>Serializer.new(<%= "@#{plural_table_name}" %>)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
def show
|
21
|
+
<% if apipie_installed? -%>api :GET, '/<%= [prefix, plural_table_name].join("/") %>/:id', 'Show <%= singular_table_name %>'
|
22
|
+
<% end -%>def show
|
24
23
|
render json: <%= class_name %>Serializer.new(<%= "@#{singular_table_name}" %>)
|
25
24
|
end
|
26
|
-
|
27
|
-
<% if apipie_installed? -%>api
|
25
|
+
|
26
|
+
<% if apipie_installed? -%>api :POST, '/<%= [prefix, plural_table_name].join("/") %>', 'Create <%= singular_table_name %>'
|
28
27
|
param_group :<%= singular_table_name %>
|
29
28
|
<% end -%>def create
|
30
29
|
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
@@ -36,7 +35,7 @@ class <%= prefixed_controller_class_name %>Controller < ApplicationController
|
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
<% if apipie_installed? -%>api
|
38
|
+
<% if apipie_installed? -%>api :PUT, '/<%= [prefix, plural_table_name].join("/") %>/:id', 'Update <%= singular_table_name %>'
|
40
39
|
param_group :<%= singular_table_name %>
|
41
40
|
<% end -%>def update
|
42
41
|
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
@@ -46,9 +45,8 @@ class <%= prefixed_controller_class_name %>Controller < ApplicationController
|
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
def destroy
|
48
|
+
<% if apipie_installed? -%>api :DELETE, '/<%= [prefix, plural_table_name].join("/") %>/:id', 'Delete <%= singular_table_name %>'
|
49
|
+
<% end -%>def destroy
|
52
50
|
@<%= orm_instance.destroy %>
|
53
51
|
end
|
54
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Atkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|