You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+75-8Lines changed: 75 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,16 @@
1
-
# Rest Api Generator
1
+
# rest-api-generator
2
2
3
-
This gem helps your to build a Ruby on Rails REST api, using a scaffold generator following the best pratices.
3
+
This gem helps you to build a Ruby on Rails REST API, using a scaffold generator following the best practices.
4
4
5
5
## How it works?
6
6
7
-
We use SwitchDreams default way to make controller using RSpec and FactoryBot for testing and use a custom expection to centralize error handle like this article https://medium.com/rails-ember-beyond/error-handling-in-rails-the-modular-way-9afcddd2fe1b
7
+
The gems use rails generators and some templates to create all resources needed to build an REST API.
8
+
9
+
The controller is built following SwitchDreams default way:
10
+
11
+
- Using an error handler module to deal with a custom exception for centralize error handler following
12
+
this article https://medium.com/rails-ember-beyond/error-handling-in-rails-the-modular-way-9afcddd2fe1b.
13
+
- For tests, we use RSpec and FactoryBot.
8
14
9
15
## Installation
10
16
@@ -23,6 +29,7 @@ Or install it yourself as:
23
29
$ gem install rest-api-generator
24
30
25
31
## Requirements
32
+
26
33
You need to have installed in your application rspec and factory bot
27
34
28
35
<ul>
@@ -31,31 +38,91 @@ You need to have installed in your application rspec and factory bot
31
38
</ul>
32
39
33
40
## Usage
41
+
34
42
### Generate Resource
43
+
35
44
```bash
36
-
$ rails g rest-api-generator-resource table_name attributes
45
+
$ rails g rest-api-generator:resource table_name attributes
37
46
```
47
+
38
48
This command will create:
49
+
39
50
-**Model and Migration**: Using rails default model generator
40
51
-**Controller**: A controller with index,show,create,update and destroy methods.
41
52
-**Specs for the created controller**
42
53
-**Factory bot factory for created model**
43
54
-**Routes**: with rails resources
44
55
56
+
### Example
57
+
58
+
```bash
59
+
$ rails g rest-api-generator:resource car name:string color:string
60
+
```
61
+
62
+
Will generate following controller and the other files:
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
107
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
108
+
also run `bin/console` for an interactive prompt that will allow you to experiment.
48
109
49
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
110
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
111
+
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
112
+
push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
113
51
114
## Contributing
52
115
53
-
Bug reports and pull requests are welcome on GitHub at https://github.com/SwitchDreams/rest-api-generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/SwitchDreams/rest-api-generator/blob/master/CODE_OF_CONDUCT.md).
116
+
Bug reports and pull requests are welcome on GitHub at https://github.com/SwitchDreams/rest-api-generator. This project
117
+
is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
118
+
the [code of conduct](https://github.com/SwitchDreams/rest-api-generator/blob/master/CODE_OF_CONDUCT.md).
54
119
55
120
## License
56
121
57
122
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
58
123
59
124
## Code of Conduct
60
125
61
-
Everyone interacting in the Rest::Api::Generator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rest-api-generator/blob/master/CODE_OF_CONDUCT.md).
126
+
Everyone interacting in the Rest::Api::Generator project's codebases, issue trackers, chat rooms and mailing lists is
127
+
expected to follow
128
+
the [code of conduct](https://github.com/[USERNAME]/rest-api-generator/blob/master/CODE_OF_CONDUCT.md).
0 commit comments