Skip to content

Commit

Permalink
split integer and float for literal value
Browse files Browse the repository at this point in the history
  • Loading branch information
AllyW committed Feb 6, 2025
1 parent f2974bd commit 6585b98
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/typespec-aaz/src/convertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function convert2CMDSchemaBase(context: AAZSchemaEmitterContext, type: Type): CM
case "Number":
case "String":
case "Boolean":
schema = convertLiteral2CMDSchemaBase(type);
schema = convertLiteral2CMDSchemaBase(context, type);
break;
// case "Tuple":
default:
Expand Down Expand Up @@ -1208,15 +1208,24 @@ function isAzureResourceOverall(context: AAZSchemaEmitterContext, model: Model):
return !!isResource;
}

function convertLiteral2CMDSchemaBase(type: Type): CMDStringSchemaBase | CMDIntegerSchemaBase | CMDBooleanSchemaBase | undefined {
function convertLiteral2CMDSchemaBase(context: AAZSchemaEmitterContext, type: Type): CMDStringSchemaBase | CMDIntegerSchemaBase | CMDFloatSchemaBase | CMDBooleanSchemaBase | undefined {
switch (type.kind) {
case "Number":
return {
type: "integer",
enum: {
items: [{value: type.value}]
}
};
if (type.numericValue.isInteger) {
return {
type: "integer",
enum: {
items: [{value: type.value}]
}
};
} else {
return {
type: "float",
enum: {
items: [{value: type.value}]
}
};
}
case "String":
return {
type: "string",
Expand Down

0 comments on commit 6585b98

Please sign in to comment.