Skip to content

Instantly share code, notes, and snippets.

@webstrand
Created June 28, 2024 18:07
Show Gist options
  • Select an option

  • Save webstrand/3f87de84f12acc689453e121c43b939c to your computer and use it in GitHub Desktop.

Select an option

Save webstrand/3f87de84f12acc689453e121c43b939c to your computer and use it in GitHub Desktop.
type RFC9457ProblemOccurrence = {
/**
* A string containing a URI reference that identifies the problem type.
*
* Consumers MUST use this URI (after resolution, if necessary) as the problem type's
* primary identifier.
*
* When this member is not present, its value is assumed to be "about:blank".
*
* If the URI is a locator (e.g., those with an "http" or "https" scheme),
* dereferencing it SHOULD provide human-readable documentation for the problem type.
*
* However, consumers SHOULD NOT automatically dereference the URI, unless they
* do so when providing information to developers (e.g., when a debugging tool is
* in use).
*
* When "type" contains a relative URI, it is resolved relative to the document's
* base URI. However, using relative URIs can cause confusion, and they might not
* be handled correctly by all implementations.
*
* The URI is allowed to be a non-resolvable URI. For example, the tag URI scheme can be used to uniquely identify problem types:
*
* tag:[email protected],2021-09-17:OutOfLuck
*
* However, resolvable type URIs are encouraged by this specification because it might
* become desirable to resolve the URI in the future. For example, if an API designer
* used the URI above and later adopted a tool that resolves type URIs to discover
* information about the error, taking advantage of that capability would require
* switching to a resolvable URI, creating a new identity for the problem type and
* thus introducing a breaking change.
*/
readonly type?: string;
/**
* A number indicating the HTTP status code generated by the origin server for this
* occurrence of the problem.
*
* The "status" member, if present, is only advisory; it conveys the HTTP status
* code used for the convenience of the consumer. Generators MUST use the same
* status code in the actual HTTP response, to assure that generic HTTP software
* that does not understand this format still behaves correctly.
*
* Consumers can use the status member to determine what the original status code
* used by the generator was when it has been changed (e.g., by an intermediary
* or cache) and when a message's content is persisted without HTTP information.
* Generic HTTP software will still use the HTTP status code.
*/
readonly status?: number
/**
* A short, human-readable summary of the problem type.
*
* It SHOULD NOT change from occurrence to occurrence of the problem, except for
* localization (e.g., using proactive content negotiation).
*
* This field is advisory and is included only for users who are unaware of and cannot
* discover the semantics of the type URI (e.g., during offline log analysis).
*/
readonly title?: string
/**
* A human-readable explanation specific to this occurrence of the problem.
*
* If present, this ought to focus on helping the client correct the problem, rather than giving
* diagnostic information useful to the administrator.
*
* Consumers SHOULD NOT parse the "detail" member for information; extensions are more suitable
* and less error-prone ways to obtain such information.
*/
readonly detail?: string
/**
* A string containing a URI reference that identifies the specific occurrence of the problem.
*
* When the URI is dereferenceable, the problem details object can be fetched from it. It
* might also return information about the problem occurrence in other formats through use
* of proactive content negotiation.
*
* When the URI is not dereferenceable, it serves as a unique identifier for the
* problem occurrence that may be of significance to the server but is opaque to the client.
*
* When the URI is relative, it is resolved relative to the document's base URI. However,
* using relative URIs can cause confusion, and they might not be handled correctly by
* all implementations.
*/
readonly instance?: string
}
type wat = RFC9457ProblemOccurrence["type"] extends string ? 1 : 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment