Closed pvdbosch closed 3 years ago
In GitLab by @pvdbosch on Nov 14, 2019, 14:37
changed the description
In GitLab by @pvdbosch on Nov 14, 2019, 14:38
changed title from {-environment-independent -}problem code to problem code
up for discussion in a next WG
on a related note: an instance not in URI format doesn't validate (in stoplight)
"instance": "d9e35127-e9b1-4201-a211-2b52e52508df"
I've changed the example in common-v1.yaml to the following to make it validate:
"instance": "urn:uuid:d9e35127-e9b1-4201-a211-2b52e52508df"
This is a standardized URN format for UUIDs
My proposal:
I think using URNs is better than using relative URIs like zalando recommends because relative URIs should need to be resolved to their full URI to be a unique identifier, and resolving the base URI to which they are relative is context-dependent.
Did some research about what the specs say about URI vs relative URI:
Sources:
discussed on WG of November 2020, but no conclusion yet. A summary of the discussion follows.
Points raised
For instance, when GET https://something.com/myapi/v1/employers/123
returns a Problem JSON with as "type":
Consumers MUST use the "type" string as the primary identifier for the problem type;
"type": A URI reference [RFC3986] that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type
Any 3rd party tooling that works with Problem JSON would search for "type".
However:
Using a stable but non-dereferenceable http(s) url as type, is confusing because users might try to dereference it
Compliance of definition of identifiers with ICEG URI standard
not investigated much yet
Also see unresolved discussion on ICEG URI standard and REST APIs in https://github.com/belgif/thematic/issues/31
Option 1
Example:
{ "type": "https://b2b-acpt.ksz-bcss.fgov.be/socialStatus/v1/refData/problems/ssinReplaced", "code": "ssinReplaced" }
Option 2
{ "type": "urn:problem-type:ksz-bcss.fgov.be:socialStatus:ssinReplaced", "typeHref": "https://b2b-acpt.ksz-bcss.fgov.be/socialStatus/v1/refData/problems/ssinReplaced" }
This option is similar to this blog but with typeHref added.
TBD:
Option 3
{ "type": "/socialStatus/problems/ssinReplaced", "typeHref": "https://b2b-acpt.ksz-bcss.fgov.be/socialStatus/v1/refData/problems/ssinReplaced" }
3a: relative link within base path This option is similar to Zalando REST guide.
3b: relative link includes full base path (without domain name) => increased dependency on technical URIs in application code
Option 4
"type": "https://b2b-acpt.ksz-bcss.fgov.be/socialStatus/v1/refData/problems/ssinReplaced"
type always has absolute URL (env-dependent) clients should parse type to retrieve identifier
My preference would be to maintain compliance with the Problem RFC and restrict our usage further to forbid relative URIs; avoiding complexity to resolve them correctly.
For problem type identifiers either:
Other issues:
type should be a URI or relative URI that is env-independent string and stable over time
If it's a relative URL (starting with /) or absolute one, it should be dereferenceable. If it's a URN, not dereferenceable.
type: type: string format: uri => format: uri-reference
not accepted yet ; decision deferred
summarized options in https://github.com/belgif/rest-guide/wiki/problem-type-identifiers , with trade-offs in the table at the end of the page
Results of dedicated meeting on problem type are on wiki:
WG agreed on chosen solution. We'll document it with rationale for deviation from RFC standard. We'll try to provide this feedback also to the RFC via appropriate channel.
PRs #80 and https://github.com/belgif/openapi-problem/pull/3 ready for review
Not discussed in WG yet: #80 specifies /refData/problemTypes/{problemType}
as URL-template for API-specific problem type doc
reviewed together in WG. Merged - will be part of next guide update.
In GitLab by @pvdbosch on Nov 14, 2019, 14:02
Proposal to add a standard "code" property to each Problem JSON.
This is inspired on the DigiPolis Antwerp REST guide, but we'd use a more human readable problem code.
possibilities:
The last option for "code" seemed to be preferred during last WG, i.e. take the last part of the type URL. There is some risk on a new generic gCloud standard problem code overlapping with already existing API-specific ones, but that risk might be small enough to ignore.