-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model routes should be dasherized, not camelized #308
Comments
(from Ember 2.17.0 customizing-serializers) Reading through #15 and trying to figure out where this discrepancy crept in. |
You're right. But in the meantime, it is still possible to give all the fields in your structs custom names. So you could do it like in our example and give dasherized names to your fields, see: api2go/examples/model/model_user.go Lines 10 to 18 in e7b6938
Maybe we should make this a configurable option whether people want to use the standard dasherized or camel version. |
Agreed -- I'm already using dasherized field names and that is working great. This issue is specifically about the parent struct name and how it's converted to a URL/route name. |
My colleague just pointed out EntityNamer, which looks like a way to work around this on the server side. |
If you are using ember-data, I would suggest not to dasherize your fieldNames and types, as you are adding more work for ember-data serializer - specifically to normalize your response. Ember data internally stores data in json:api format, where fieldNames are camelCase and types are singular. Ember-data Serializer was meant to be a stop gap for you to align your API, if you have control over it, which sounds like you do. |
When the NewAPI().AddResource() mechanism is used to register a model with a name such as
MyStruct
, the route that is registered should be the dasherizedmy-struct
. Instead, the route that is registered is the camelizedmyStruct
. This isn't compatible with Ember Data. And in fact, Ember does not even have a convenient pathForType widget to camelize and pluralize a dasherized route, which makes this a pesky interop issue that requires hacking.The text was updated successfully, but these errors were encountered: