UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

36 lines (35 loc) 1.57 kB
import { isSchema } from "@scalar/workspace-store/schemas/v3.1/strict/type-guards"; //#region src/components/Content/Schema/helpers/get-property-description.ts var TYPE_DESCRIPTIONS = { integer: { _default: "Integer numbers.", int32: "Signed 32-bit integers (commonly used integer type).", int64: "Signed 64-bit integers (long type)." }, string: { "date": "full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21", "date-time": "the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z", "password": "a hint to UIs to mask the input", "base64": "base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==", "byte": "base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==", "binary": "binary data, used to describe files" } }; /** * Generate property description from type/format * * @param value - The schema object to generate description from * @returns Description string or null if no description available */ var getPropertyDescription = (value) => { if (!isSchema(value)) return null; /** Just grab the first type from the array if it's an array */ const type = Array.isArray(value.type) ? value.type[0] : value.type; if (!type) return null; const typeDescriptions = TYPE_DESCRIPTIONS[type]; if (!typeDescriptions) return null; return typeDescriptions["format" in value && value.format || "contentEncoding" in value && value.contentEncoding || "_default"] ?? null; }; //#endregion export { getPropertyDescription }; //# sourceMappingURL=get-property-description.js.map