Skip to content

Commit 19ec5fd

Browse files
📝 Improves README.md
1 parent 112f342 commit 19ec5fd

File tree

1 file changed

+15
-75
lines changed

1 file changed

+15
-75
lines changed

README.md

Lines changed: 15 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
# RestApiGenerator
1+
# Rest Api Generator
22

3-
This gem works as a scaffold to generate an endpoint, it generates:
3+
This gem helps your to build a Ruby on Rails REST api, using a scaffold generator following the best pratices.
44

5-
<ul>
6-
<li> Model </li>
7-
<li> Migration </li>
8-
<li> Routes (resource) </li>
9-
<li> Controller </li>
10-
<li> Spec test of controller </li>
11-
<li> Factory bot </li>
12-
</ul>
5+
## How it works?
136

14-
the commnad its simmilar to the model generator "rails g model model_name attributes", in fact it invokes this generator to genrate the model and migration file
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
158

169
## Installation
1710

@@ -37,70 +30,17 @@ You need to have installed in your application rspec and factory bot
3730
<li>Factory bot: https://github.com/thoughtbot/factory_bot_rails</li>
3831
</ul>
3932

40-
then inside your folder app/spec create a new folder called "requests", that's where your tests will be generated
41-
4233
## Usage
43-
### Run command
44-
$ rails g generator table_name attributes
45-
46-
************************************************************************************
47-
#### Model
48-
this will generate a table and a migration with the table name and it's attribute, it invokes the model generator
49-
50-
************************************************************************************
51-
#### Endpoint
52-
It will genrate a controller CarsController that has the methods
53-
54-
##### Create
55-
saves instance of generated model to database and return json of instance with status ok
56-
57-
##### Update
58-
updates instance of generated modelfrom database and return json of instance with status ok
59-
60-
##### Delete
61-
deletes instance of generated model from database
62-
63-
##### Show
64-
returns JSON instance of generated model from database with status ok
65-
66-
##### Index
67-
returns JSON instance of generated model from database with status ok
68-
69-
70-
create and update will have permitted params defined by the attributes defined in the command (except if the attribute is type reference)
71-
************************************************************************************
72-
### Spec
73-
74-
##### Create
75-
checks if instance was saved in database
76-
77-
##### Update
78-
checks if instance was updated in database ok
79-
80-
##### Delete
81-
checks if instance was deleted from database
82-
83-
##### Show
84-
check if status ok
85-
86-
##### Index
87-
check if status ok
88-
89-
************************************************************************************
90-
### Factory
91-
The factory will be generated with it's custom generator, defined in the instalation of the factory-bot
92-
93-
************************************************************************************
94-
### Routes
95-
the routes generated are the basic resources routes:
96-
table_name: resources
97-
98-
************************************************************************************
99-
### Scope
100-
It's possible to add flag in the command to generate an endpoint with a parent
101-
$ rails g generator table_name attributes --scope father_name
102-
103-
the only thing this won't genrate it's the nested routes, but it will generate all the previous files mentioned just liek a scaffold
34+
### Generate Resource
35+
```bash
36+
$ rails g rest-api-generator-resource table_name attributes
37+
```
38+
This command will create:
39+
- **Model and Migration**: Using rails default model generator
40+
- **Controller**: A controller with index,show,create,update and destroy methods.
41+
- **Specs for the created controller**
42+
- **Factory bot factory for created model**
43+
- **Routes**: with rails resources
10444

10545
## Development
10646

@@ -110,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
11050

11151
## Contributing
11252

113-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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/[USERNAME]/rest-api-generator/blob/master/CODE_OF_CONDUCT.md).
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).
11454

11555
## License
11656

0 commit comments

Comments
 (0)