-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
- Platform: Darwin Joshs-MacBook-Pro-2.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
- Database: sqlite
- Lux Version: 1.2.3
- Node Version: v10.15.3
The guides for Controller#params seem to indicate that it is optional:
If you do not override this property all of the attributes specified in the Serializer that represents a Controller's resource. If the Serializer cannot be resolved, this property will default to an empty array.
However, this defaulting doesn't seem to be working for me.
(Demo repo here: https://github.com/CodingItWrong/lux-test)
When I have the following Serializer and Controller with explicit params, I can successfully create a record with values passed in:
class RestaurantsController extends Controller {
params = ['name', 'address'];
}
class RestaurantsSerializer extends Serializer {
attributes = ['name', 'address'];
}
But if I remove Controller#params:
class RestaurantsController extends Controller {
}
Then upon POSTing a record I get empty attributes back:
POST:
{
"data": {
"type": "restaurants",
"attributes": {
"name": "Sushi Place",
"address": "123 Main Street"
}
}
}
Response:
{
"data": {
"id": "3",
"type": "restaurants",
"attributes": {},
"relationships": {
"dishes": {
"data": []
}
}
},
"links": {
"self": "http://localhost:4000/restaurants"
},
"jsonapi": {
"version": "1.0"
}
}
And if I GET /restaurants/ I get null values for the attributes:
{
"data": [
{
"id": "1",
"type": "restaurants",
"attributes": {
"name": null,
"address": null
},
...
}
],
...
}
Metadata
Metadata
Assignees
Labels
No labels