Skip to content

Commit

Permalink
Fix choice issue (#675)
Browse files Browse the repository at this point in the history
Co-authored-by: xichen <xichen@microsoft.com>
  • Loading branch information
shawncx and msxichen authored Aug 24, 2020
1 parent d4ce300 commit 078f32b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 4 additions & 2 deletions powershell/internal/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SchemaDetails>, LanguageDetails<PropertyDetails>>;

Expand Down Expand Up @@ -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 && (<ConstantSchema>schema).valueType.type === SchemaType.Boolean))) {
if (schema && (schema.type === SchemaType.Boolean
|| (schema.type === SchemaType.Constant && (<ConstantSchema>schema).valueType.type === SchemaType.Boolean)
|| (schema.type === SchemaType.Choice && (<any>schema).choiceType.type === SchemaType.Boolean))) {
return new NewPSSwitch(<BooleanSchema>schema, required);
}
}
Expand Down
6 changes: 1 addition & 5 deletions powershell/llcsharp/schema/schema-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,7 @@ export class NewSchemaDefinitionResolver {
return this.resolveTypeDeclaration((<ConstantSchema>schema).valueType, required, state);

case SchemaType.Choice: {
const choiceSchema = schema as ChoiceSchema;
if ((<any>choiceSchema.choiceType).type === SchemaType.DateTime && (<any>choiceSchema.choiceType).format === StringFormat.DateTimeRfc1123) {
return new NewDateTime1123(schema as DateTimeSchema, required);
}
return new NewString(schema, required);
return this.resolveTypeDeclaration((<ChoiceSchema>schema).choiceType, required, state);
}
case SchemaType.SealedChoice:
if (schema.language.default.skip === true) {
Expand Down

0 comments on commit 078f32b

Please sign in to comment.