[openstack-dev] [api] Optional Properties in an Entity

Douglas Mendizabal douglas.mendizabal at RACKSPACE.COM
Mon Jan 19 19:55:28 UTC 2015


Hi API WG,

I’m curious about something that came up during a bug discussion in one of the Barbican weekly meetings.  The question is about optional properties in an entity.  e.g. We have a Secret entity that has some properties that are optional, such as the Secret’s name.  We were split on what the best approach for returning the secret representation would be when an optional property is not set.

In one camp, some developers would like to see the properties returned no matter what.  That is to say, the Secret dictionary would include a key for “name” set to null every single time.  i.e.

{
  …
  “secret”: {
    “name”: null,
    …
  }
  ...
}

On the other camp, some developers would like to see optional properties omitted if they were not set by the user.

The advantage of always returning the property is that the response is easier to parse, since you don’t have to check for the existence of the optional keys.  The argument against it is that it makes the API more rigid, and clients more fragile.

I was wondering what the API Working Group’s thoughts are on this?

Thanks,
Douglas Mendizábal

--------------------
Douglas Mendizábal
IRC: redrobot
PGP Key: 245C 7B6F 70E9 D8F3 F5D5  0CC9 AD14 1F30 2D58 923C



More information about the OpenStack-dev mailing list