in packages/typespec-powershell/src/utils/modelUtils.ts [1064:1126]
function applyIntrinsicDecorators(
dpgContext: SdkContext,
type: Scalar | ModelProperty,
target: any
): any {
const newTarget = { ...target };
const docStr = getDoc(dpgContext.program, type);
const isString = isStringType(dpgContext.program, getPropertyType(type));
const isNumeric = isNumericType(dpgContext.program, getPropertyType(type));
if (isString && !target?.documentation && docStr) {
newTarget.description = docStr;
}
if (type.kind === "ModelProperty") {
const wireName = getWireName(dpgContext, type);
if (wireName) {
newTarget.name = wireName;
}
}
const summaryStr = getSummary(dpgContext.program, type);
if (isString && !target.summary && summaryStr) {
newTarget.summary = summaryStr;
}
const formatStr = getFormat(dpgContext.program, type);
if (isString && !target.format && formatStr) {
newTarget.format = formatStr;
}
const pattern = getPattern(dpgContext.program, type);
if (isString && !target.pattern && pattern) {
newTarget.pattern = pattern;
}
const minLength = getMinLength(dpgContext.program, type);
if (isString && !target.minLength && minLength !== undefined) {
newTarget.minLength = minLength;
}
const maxLength = getMaxLength(dpgContext.program, type);
if (isString && !target.maxLength && maxLength !== undefined) {
newTarget.maxLength = maxLength;
}
const minValue = getMinValue(dpgContext.program, type);
if (isNumeric && !target.minimum && minValue !== undefined) {
newTarget.minimum = minValue;
}
const maxValue = getMaxValue(dpgContext.program, type);
if (isNumeric && !target.maximum && maxValue !== undefined) {
newTarget.maximum = maxValue;
}
if (isSecret(dpgContext.program, type)) {
newTarget.type = "credential";
newTarget["extensions"] = newTarget["extensions"] || {};
newTarget["extensions"]["x-ms-secret"] = true;
}
return newTarget;
}