ghaiklor / generator-sails-rest-api

Yeoman generator for scaffolding Sails REST API with predefined features
http://ghaiklor.github.io/generator-sails-rest-api/
MIT License
334 stars 52 forks source link

Model generator should be called API generator and docs improvement #238

Open Fr33maan opened 8 years ago

Fr33maan commented 8 years ago

Hi,

I experienced something very strange with model names like coach and person. Their pluralized forms are coaches and people (try it there) so I tried to create ressources by posting to `v1/coaches or v1/people which give me the following response :

{
  "code": "OK",
  "message": "Operation is successfully executed",
  "data": {}
}

Off course, nothing is created, this is not the standard response for ressource creation.

I tried to set pluralize : false and if I ping non pluralized route I get the same response and nothing gets created.

How can I use thoses model names ?

Note that blueprint routes works perfectly in native sails so I guess it comes from the PluralizeHook or other code from this module ?

Fr33maan commented 8 years ago

Ok it's not a bug at all, you must avoid to create api with Controller generator and then Model generator. Just use Model generator.

Could you write it in capital letters in the doc ? I've seen nowhere that generate controller then model will break blueprints.

Why ? Because when you generate a controller, the generator write an index action inside and this breaks blueprint routes.

And in fact, the Model generator corresponds to the api generator in sails because it generates model AND controller. This should be renamed as it is really confusing.

ghaiklor commented 8 years ago

@prisonier what you think about contributing in the generator ? I have no time for fixing all the issues that we have already, since I'm working on another open-source project. I can be your mentor and help with PR review.

Fr33maan commented 8 years ago

@ghaiklor I'm really interested

ghaiklor commented 8 years ago

@prisonier you can pick up any issue then and make PR. Issues are really easy and I always can help you with reviewing and discussing the PRs.

Read the contributing guide first. And don't forgot to install commitizen. I'm using semantic-release, so your commits should be formatted by standard, commitizen helps you with that.

First issue is really issue for first contributing - #225. You need to upgrade sails and other dependencies in generators/app/templates/package.json and check that tests are passing and it generates project locally with Sails 0.12. Any questions to can ask there - #225 :)

Fr33maan commented 7 years ago

I've added precision in the wiki about what model generator does. I was pretty sure this would create a PR but instead it directly modified the wiki...