Docs@skmtc/core

OpenAPI document

FUNCTION

toJsonContent

@skmtc/core 0.63.4

Choose the media type a body is read from: application/json exactly when it is a key, else the first JSON-like key in document order (see isJsonMediaType), else the *\/* key when its schema is an object, array, union, intersection or $ref. *\/* admits JSON, and documents use it for JSON bodies (springdoc writes it for every response); the parser logs WILDCARD_MEDIA_TYPE for every body read this way. undefined otherwise: there is no fall back to a specific non-JSON type, to a narrower range such as application/*, or to a scalar schema under *\/*, since a consumer would read that body as JSON.

Signature

import { toJsonContent } from '@skmtc/core'

toJsonContent(
  content: Record<string, OasMediaType> | undefined
): JsonContent | undefined

Parameters

content, Record<string, OasMediaType> | undefined required

Returns

JsonContent | undefined