ezimuel / zend-expressive-api

Web API skeleton using zend-expressive
59 stars 30 forks source link

Proposed changes to API skeleton #3

Closed weierophinney closed 6 years ago

weierophinney commented 6 years ago

This patch accomplishes the following:

I've provided ample documentation in the commit notes detailing each change as well.

Rockstar04 commented 6 years ago

Not sure if this should be addressed here, or in the repo for ZendDB, but $this->table->lastInsertValue can return a string depending on the driver used, causing the examples as laid out here to break when trying to create a new user.

The UserInputValidator is also missing (possibly be design) a field for the users name, so creating a new user leaves you with a name.

ezimuel commented 6 years ago

@Rockstar04 if you think that lastInsertValue() has some issue please open it at https://github.com/zendframework/zend-db. Regarding the missing user name this is by design, becuase the user name is not required in the table. Thanks for your feedback!

ezimuel commented 6 years ago

@weierophinney thanks a ton for the awesome PR!

weierophinney commented 6 years ago

Actually, @Rockstar04 has a point: if the field is not defined, it will not be in the values pulled from the input filter (which is one change I made). We need to add all fields to the input filter; if they're not required, we simply mark them as such.

Rockstar04 commented 6 years ago

@ezimuel ZendDB's AbstractTableGateway.php does not declare its return type (other than in its docBlock), but UserModel.php sets a return type of int with no validation or guarantee that that the table gateway has actually returned an int.

ezimuel commented 6 years ago

@Rockstar04 ok, I misunderstood your original proposal. I already merged your PR. Thanks!