Package-level declarations

Entry pointRole
problemJsonInside HttpResponseValidator { }: convert a recognized problem response into ProblemException.

Two behaviors here are decisions, not defaults, and each is pinned by a test:

  • application/problem+json and a plain application/json are not trusted equally. A response strictly labeled application/problem+json that fails to decode is a broken promise from the server and propagates loudly, as SerializationException. A response merely labeled application/json (matched only when acceptPlainJson = true) was never a promise about shape — a decode failure there falls back silently to Ktor's own ClientRequestException/ ServerResponseException. acceptPlainJson defaults to false, the opposite of problem-details-ktor's own acceptPlainJson = true default, because it now governs bodies from servers this project does not control, not this project's own well-formed output. Note that on this side the flag reads the response's Content-Type; it has nothing to do with the Accept header, which this module never sets.

  • A redirect answered with a problem document is replaced too. Every status Ktor raises a ResponseException for qualifies — 3xx included, not just 4xx/5xx. A server that explains a redirect it cannot perform gets the same treatment as one that explains a failure.

Functions

Link copied to clipboard
fun HttpCallValidatorConfig.problemJson(acceptPlainJson: Boolean = false, json: Json = Json)

Turns a recognized application/problem+json response into the same ProblemException that application code throws on the server side and problem-details-ktor answers.