- "ignore rule": clients ignore extra content they don't understand
- "variable order": clients shouldn't rely on a particular order within objs
- & "silent fail" - you can lead a server to water,
Adding a `Link: <{url}>, rel="help"` response header to point to docs is SO GOOD
Explicitly mentioned: comply with your org's privacy policy.
Implicitly recommended: HAVE A PRIVACY POLICY. Decide what info is sensitive UP FRONT.
Also: camelCase attributes. Good to have a recommendation here.
As expected, there is a fairly meaty treatise on how to error.
There's a lot of good stuff here: github.com/microsoft/api-…
Breaking it down a bit:
2. Errors should have a human-readable, dev-targeted message.
3. Errors should have a string "code", limited to about 20 possibilities.
4. Errors may have a "target" prop saying what input was wrong
They follow the "{serviceRoot}/{collection}/{id}" pattern - e.g., "sprockets․biz/v1.0/cogs/10" – "cogs" are the collection, "10" is the id.
(I personally like to nest further: "/cogs/cog/10", but w/e!)
Wishing for a bestiary of tokens & JSON props. Maybe later in the doc!
Section 11 has various safe handling recommendations for JSON, with some novel rules around Date that are worth checking out: github.com/microsoft/api-…
(Notably absent: the Accept-Version req header.)
"The state of the system SHOULD be discoverable and testable at all times. Clients SHOULD be able to determine the system state even if the operation tracking resource is no longer active."
yes, yes, yes.
(alright alright, it doesn't have to be bash. bash is just a forcing function for simplification here.)
Creating a resource may return an Operation-Location header in addition to a Location header.
They go on to give advice on setting up a push notification flow as well, but I love the idea of layering that on top of an existing visibility mechanism
"Services should respond quickly with an error when they are overloaded, rather than simply respond slowly."
YES
It continues by drawing distinctions between 429 "client can fix it" and 503 "out of client control" resps
(Sidenote: it's surprising that they go for a quota over a window of time, vs. something continuous like token-bucket ratelimiting!)
"For the overall name of a resource typically shown to users, services MUST use the property name 'displayName'."
Yes, yes, yes. Always make it clear _which_ name you want displayed in UI, or else you'll end up with identifiers looped through UI.
(I'd love a list of well-known sigil-names here, too – ﹫next, ﹩filter, etc)
However, your team has to read it, agree to it, and walk the walk.
Once you get buy-in, then build tooling around _that_.