diff --git a/powershell/internal/project.ts b/powershell/internal/project.ts index 7724490d74..1d0feb10bb 100644 --- a/powershell/internal/project.ts +++ b/powershell/internal/project.ts @@ -17,7 +17,7 @@ import { codemodel, PropertyDetails, exportedModels as T, ModelState, JsonType, import { DeepPartial } from '@azure-tools/codegen'; import { PwshModel } from '../utils/PwshModel'; import { NewModelState } from '../utils/model-state'; -import { BooleanSchema, ConstantSchema, Schema as NewSchema, SchemaType } from '@azure-tools/codemodel'; +import { BooleanSchema, ChoiceSchema, ConstantSchema, Schema as NewSchema, SchemaType } from '@azure-tools/codemodel'; export type Schema = T.SchemaT, LanguageDetails>; @@ -72,7 +72,9 @@ export class NewPSSchemaResolver extends NewSchemaDefinitionResolver { try { if (!this.inResolve) { this.inResolve = true; - if (schema && (schema.type === SchemaType.Boolean || (schema.type === SchemaType.Constant && (schema).valueType.type === SchemaType.Boolean))) { + if (schema && (schema.type === SchemaType.Boolean + || (schema.type === SchemaType.Constant && (schema).valueType.type === SchemaType.Boolean) + || (schema.type === SchemaType.Choice && (schema).choiceType.type === SchemaType.Boolean))) { return new NewPSSwitch(schema, required); } } diff --git a/powershell/llcsharp/schema/schema-resolver.ts b/powershell/llcsharp/schema/schema-resolver.ts index 40e2504029..fe51afa73e 100644 --- a/powershell/llcsharp/schema/schema-resolver.ts +++ b/powershell/llcsharp/schema/schema-resolver.ts @@ -238,11 +238,7 @@ export class NewSchemaDefinitionResolver { return this.resolveTypeDeclaration((schema).valueType, required, state); case SchemaType.Choice: { - const choiceSchema = schema as ChoiceSchema; - if ((choiceSchema.choiceType).type === SchemaType.DateTime && (choiceSchema.choiceType).format === StringFormat.DateTimeRfc1123) { - return new NewDateTime1123(schema as DateTimeSchema, required); - } - return new NewString(schema, required); + return this.resolveTypeDeclaration((schema).choiceType, required, state); } case SchemaType.SealedChoice: if (schema.language.default.skip === true) {