Skip to content

Handle user-defined resource properties that would serialize as reserved json-api keys #84

Open
@csantero

Description

@csantero

The following reserved words cannot be used as resource attribute names:

  • id
  • type
  • links
  • meta

(I am including id in this list because it's possible someone could use UseAsId to specify a particular property as the ID, and then have an additional non-id property called Id.)

To deal with properties like Type, my gut inclination would be to prefix an underscore to the offending field, but that goes against this json-api recommendation:

It is recommended that resource types, attribute names, and association names be "dasherized"; i.e. consist of only lower case alphanumeric characters and dashes

ATM we are using camel-cased resource attribute names, so we aren't complying with this recommendation anyway - although maybe we should?

On a related note, we should probably have some strategy for dealing with models that have naming collisions based on differing capitalization: e.g. a model that has properties called Foo, foo, and fOO. Arguably if you are doing this you have only yourself to blame, but it would be nice if we explicitly blocked it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions