belgif / rest-guide

REST Guidelines of Belgian government institutions
https://www.belgif.be/specification/rest/api-guide/
Apache License 2.0
24 stars 4 forks source link

Including code descriptions in responses #101

Closed pvdbosch closed 11 months ago

pvdbosch commented 1 year ago

Formulate guidelines:

Related:

This discussion could be extended to other metadata for codes (e.g. validity period)

Guidelines could allow some options depending on clients that an API is targeting, e.g. backend-only (business data), or for a user interface (Backend For Frontend API).

pvdbosch commented 1 year ago

some notes from WG 2022-12:

pvdbosch commented 1 year ago

eHealth: no hrefs currently Smals: inconsistent between APIs, only hrefs within single API

JDMKSZ commented 1 year ago

It seems to me that adding hrefs only it the most RESTful? See this SO post + the link to the Fielding article

pvdbosch commented 1 year ago

Using only hyperlinks to look up and navigate between resources (HATEOS) is indeed part of the original REST principles of Roy Fielding, but in practice doesn't seems feasible with current technological state of REST APIs. Some more background on this can be found here in the zalando rest guide. REST clients tend to use URI templates or be hardcoded in another way to the API's URI space (i.e. with code generation from OpenAPI).

Using the href links from responses might be more common for JavaScript clients, but I think it's overall less used then constructing the URI from a URI template (which may be generated from OpenAPI).

I'd propose to amend to guide to limit the use of "href" linking (in combanation with the resource identifier) only for resources within the same API to ensure low coupling between different APIs (e.g. no impact when there's new major version of an API).

pvdbosch commented 1 year ago

agreed in WG to specify that "href" should only be used to refer within the same API. Further rules are difficult to generalize for every use case.