Skip to content

Commit 078f32b

Browse files
shawncxmsxichen
andauthored
Fix choice issue (#675)
Co-authored-by: xichen <[email protected]>
1 parent d4ce300 commit 078f32b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

powershell/internal/project.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { codemodel, PropertyDetails, exportedModels as T, ModelState, JsonType,
1717
import { DeepPartial } from '@azure-tools/codegen';
1818
import { PwshModel } from '../utils/PwshModel';
1919
import { NewModelState } from '../utils/model-state';
20-
import { BooleanSchema, ConstantSchema, Schema as NewSchema, SchemaType } from '@azure-tools/codemodel';
20+
import { BooleanSchema, ChoiceSchema, ConstantSchema, Schema as NewSchema, SchemaType } from '@azure-tools/codemodel';
2121

2222
export type Schema = T.SchemaT<LanguageDetails<SchemaDetails>, LanguageDetails<PropertyDetails>>;
2323

@@ -72,7 +72,9 @@ export class NewPSSchemaResolver extends NewSchemaDefinitionResolver {
7272
try {
7373
if (!this.inResolve) {
7474
this.inResolve = true;
75-
if (schema && (schema.type === SchemaType.Boolean || (schema.type === SchemaType.Constant && (<ConstantSchema>schema).valueType.type === SchemaType.Boolean))) {
75+
if (schema && (schema.type === SchemaType.Boolean
76+
|| (schema.type === SchemaType.Constant && (<ConstantSchema>schema).valueType.type === SchemaType.Boolean)
77+
|| (schema.type === SchemaType.Choice && (<any>schema).choiceType.type === SchemaType.Boolean))) {
7678
return new NewPSSwitch(<BooleanSchema>schema, required);
7779
}
7880
}

powershell/llcsharp/schema/schema-resolver.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ export class NewSchemaDefinitionResolver {
238238
return this.resolveTypeDeclaration((<ConstantSchema>schema).valueType, required, state);
239239

240240
case SchemaType.Choice: {
241-
const choiceSchema = schema as ChoiceSchema;
242-
if ((<any>choiceSchema.choiceType).type === SchemaType.DateTime && (<any>choiceSchema.choiceType).format === StringFormat.DateTimeRfc1123) {
243-
return new NewDateTime1123(schema as DateTimeSchema, required);
244-
}
245-
return new NewString(schema, required);
241+
return this.resolveTypeDeclaration((<ChoiceSchema>schema).choiceType, required, state);
246242
}
247243
case SchemaType.SealedChoice:
248244
if (schema.language.default.skip === true) {

0 commit comments

Comments
 (0)