@typespec/openapi3
Version:
TypeSpec library for emitting OpenAPI 3.0 and OpenAPI 3.1 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec
22 lines • 1.14 kB
JavaScript
import { getMaxValue, getMaxValueForScalar, getMinValue, getMinValueForScalar, serializeValueAsJson, } from "@typespec/compiler";
export function getMinValueAsJson(program, type) {
const numericValue = getMinValue(program, type);
if (numericValue !== undefined)
return numericValue;
const scalarValue = getMinValueForScalar(program, type);
if (scalarValue === undefined)
return undefined;
const result = serializeValueAsJson(program, scalarValue, type);
return typeof result === "number" ? result : undefined; // json schema/openapi3 can only define min/max for numeric types
}
export function getMaxValueAsJson(program, type) {
const numericValue = getMaxValue(program, type);
if (numericValue !== undefined)
return numericValue;
const scalarValue = getMaxValueForScalar(program, type);
if (scalarValue === undefined)
return undefined;
const result = serializeValueAsJson(program, scalarValue, type);
return typeof result === "number" ? result : undefined; // json schema/openapi3 can only define min/max for numeric types
}
//# sourceMappingURL=range.js.map