Skip to content

Commit 7d0f5ad

Browse files
authored
tsp - Use clientname as property name if it is specified (#1523)
1 parent 6490e80 commit 7d0f5ad

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/typespec-powershell/src/utils/modelUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ function getSchemaForModel(
936936
};
937937
}
938938
for (const [propName, prop] of model.properties) {
939+
const clientName = getClientNameOverride(dpgContext, prop, "powershell");
939940
const encodedName = resolveEncodedName(program, prop, "application/json");
940941
const restApiName = getWireName(dpgContext, prop);
941942
const name = encodedName ?? restApiName ?? propName;
@@ -968,6 +969,10 @@ function getSchemaForModel(
968969
}
969970
// ToDo: need to confirm there is no duplicated properties.
970971
const property = new Property(name, getDoc(program, prop) || propSchema.language.default.description || "", propSchema || new ObjectSchema(name, ""));
972+
if (clientName) {
973+
// Use the client name as the property name if it is specified
974+
property.language.default.name = clientName;
975+
}
971976
if (!prop.optional) {
972977
property.required = true;
973978
}

0 commit comments

Comments
 (0)