jeudi 30 avril 2015

Preferred Ember Data URL and JSON structure for multi-word models

If I have an Ember model named DatabaseType, and want to use it with a REST adapter for Ember Data (I control the server-side API), what should the API URL look like, and what does Ember Data expect the payload to look like, in terms of CamelCase vs snake_case/underscore, and in terms of pluralizing?

Given that the recommended REST URL structure for multiple words is to use underscores (and not camel case), but also given that Ember Data is picky and opinionated about naming conventions and payload structure:

A. Should the API endpoint be:

  1. CamelCase - /databaseTypes/1/

  2. snake_case - /database_types/1/

B. What should the payload JSON root be?

  1. Get database types -> { databaseTypes: [ ... ] }

  2. Get database types -> { database_types: [ ... ] }




Aucun commentaire:

Enregistrer un commentaire