Skip to content

Commit 2fac6e2

Browse files
committed
rebase
1 parent 1f05030 commit 2fac6e2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/typespec-aaz/src/convertor.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,6 @@ function convertModel2CMDObjectSchemaBase(
895895
properties[propertyName] = discriminatorProperty;
896896
}
897897

898-
const discProperty = properties[propertyName] as CMDStringSchema;
899-
900898
const derivedModels = payloadModel.derivedModels.filter(includeDerivedModel);
901899
for (const child of derivedModels) {
902900
const childDiscriminatorValue = getDiscriminatorInfo(context, child);
@@ -905,12 +903,6 @@ function convertModel2CMDObjectSchemaBase(
905903
if (disc) {
906904
object.discriminators ??= [];
907905
object.discriminators.push(disc);
908-
discProperty.enum ??= {
909-
items: [],
910-
};
911-
discProperty.enum.items.push({
912-
value: childDiscriminatorValue.value,
913-
});
914906
}
915907
}
916908
}
@@ -1008,6 +1000,10 @@ function convertModel2CMDObjectDiscriminator(
10081000
}
10091001

10101002
const jsonName = getJsonName(context, prop);
1003+
if (jsonName === discriminatorInfo.propertyName) {
1004+
// if this property is a discriminator property, remove it as autorest
1005+
continue;
1006+
}
10111007
let schema = convert2CMDSchema(
10121008
{
10131009
...context,
@@ -1016,6 +1012,7 @@ function convertModel2CMDObjectDiscriminator(
10161012
prop,
10171013
jsonName,
10181014
);
1015+
10191016
if (schema) {
10201017
if (isReadonlyProperty(context.program, prop)) {
10211018
schema.readOnly = true;

0 commit comments

Comments
 (0)