API Design Questions (3)

Gervase Markham gerv at mozilla.org
Thu Sep 24 10:44:19 UTC 2009


On 23/09/09 12:14, Gervase Markham wrote:
> Here are some things I've run into when designing the RESTful API.
> Perhaps people could tell me what they think the best option is.

Question 3:

Fields in Bugzilla bugs have varying levels of optionalness, from custom 
fields, which of course are never guaranteed to be present because they 
are product-specific, via those fields such as qa_contact which can be 
disabled in the Admin, through to assigned_to or status, which must 
always be present and set.

Question: when returning a representation of a bug, what do we do for 
fields which do not have a value set? Examples include an empty list of 
CCs or See Alsos, or resolution for open bugs, or a blank status whiteboard.

You could either:

A) omit them from the hash
B) provide them, but with a "" or [] value

B) has the advantage that people processing the JSON don't have to 
handle the non-existence case with an extra "if" test or "defined" test 
for each field. However, obviously, custom fields have to be in class A. 
And you could argue there's a simplicity to just putting everything in 
class A.

Do we do A) for everything, or do we try and divide the fields Bugzilla 
supports into "always supported" and "sometimes supported" and deal with 
the always ones (e.g. resolution, keywords) using method B)?

Gerv
_______________________________________________
dev-apps-bugzilla mailing list
dev-apps-bugzilla at lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-apps-bugzilla



More information about the developers mailing list