From 67d17b0f28d5f8bcddcc1e45464bf4ad53b8ec0e Mon Sep 17 00:00:00 2001 From: xichen Date: Thu, 30 Jul 2020 13:14:55 +0800 Subject: [PATCH] fix enum (#88) * fix enum * fix test * add null check * change type check * change default value location * update test * add required * add parameter process Co-authored-by: xichen --- src/dumper.ts | 9 +- src/flattenHelper.ts | 12 +- src/helper.ts | 265 ++++++++++++++++-- src/nodeHelper.ts | 24 +- src/plugins/complexMarker.ts | 77 ++--- src/plugins/flattenModifier.ts | 2 +- src/plugins/flattenSetter/flattenSetter.ts | 62 ++-- src/plugins/flattenSetter/flattenValidator.ts | 6 +- src/plugins/modelerPostProcessor.ts | 46 ++- src/plugins/polyAsParamModifier.ts | 8 +- src/plugins/polyAsResourceModifier.ts | 2 +- src/plugins/visibilityCleaner.ts | 14 +- ...odeler-post-processor-post-simplified.yaml | 2 + ...on-000100-modeler-post-processor-post.yaml | 2 + ...00110-poly-as-resource-pre-simplified.yaml | 2 + ...clicommon-000110-poly-as-resource-pre.yaml | 2 + ...0120-poly-as-resource-post-simplified.yaml | 2 + ...licommon-000120-poly-as-resource-post.yaml | 2 + ...icommon-000130-flatten-pre-simplified.yaml | 2 + .../output/clicommon-000130-flatten-pre.yaml | 2 + ...common-000140-flatten-post-simplified.yaml | 2 + .../output/clicommon-000140-flatten-post.yaml | 2 + ...common-000150-modifier-pre-simplified.yaml | 2 + .../output/clicommon-000150-modifier-pre.yaml | 2 + ...ommon-000160-modifier-post-simplified.yaml | 2 + .../clicommon-000160-modifier-post.yaml | 2 + ...licommon-000170-namer-post-simplified.yaml | 2 + .../output/clicommon-000170-namer-post.yaml | 2 + ...-000180-complex-marker-pre-simplified.yaml | 2 + .../clicommon-000180-complex-marker-pre.yaml | 2 + ...000190-complex-marker-post-simplified.yaml | 2 + .../clicommon-000190-complex-marker-post.yaml | 2 + ...odeler-post-processor-post-simplified.yaml | 2 + ...on-000100-modeler-post-processor-post.yaml | 2 + ...00110-poly-as-resource-pre-simplified.yaml | 2 + ...clicommon-000110-poly-as-resource-pre.yaml | 2 + ...0120-poly-as-resource-post-simplified.yaml | 2 + ...licommon-000120-poly-as-resource-post.yaml | 2 + ...icommon-000130-flatten-pre-simplified.yaml | 2 + .../output/clicommon-000130-flatten-pre.yaml | 2 + ...common-000140-flatten-post-simplified.yaml | 2 + .../output/clicommon-000140-flatten-post.yaml | 2 + ...common-000150-modifier-pre-simplified.yaml | 2 + .../output/clicommon-000150-modifier-pre.yaml | 2 + ...ommon-000160-modifier-post-simplified.yaml | 2 + .../clicommon-000160-modifier-post.yaml | 2 + ...licommon-000170-namer-post-simplified.yaml | 2 + .../output/clicommon-000170-namer-post.yaml | 2 + ...-000180-complex-marker-pre-simplified.yaml | 2 + .../clicommon-000180-complex-marker-pre.yaml | 2 + ...000190-complex-marker-post-simplified.yaml | 2 + .../clicommon-000190-complex-marker-post.yaml | 2 + 52 files changed, 489 insertions(+), 118 deletions(-) diff --git a/src/dumper.ts b/src/dumper.ts index 18414be..c3b5dc6 100644 --- a/src/dumper.ts +++ b/src/dumper.ts @@ -4,6 +4,7 @@ import { CodeModel, Info, ObjectSchema, Operation, Parameter, OperationGroup, Pr import { isNullOrUndefined, isString, isArray, isObject, isUndefined, isNull } from 'util'; import { keys } from '@azure-tools/linq'; import { NodeExtensionHelper, NodeHelper, NodeCliHelper } from './nodeHelper'; +import { Helper } from './helper'; export class Dumper { private debugEnabled = false; @@ -163,7 +164,7 @@ export class Dumper { output.push(Dumper.tab(indent + 1) + 'readOnly: true'); } - if (parameter.schema instanceof ObjectSchema && NodeHelper.HasSubClass(parameter.schema)) { + if (Helper.isObjectSchema(parameter.schema) && NodeHelper.HasSubClass(parameter.schema as ObjectSchema)) { output.push(Dumper.tab(indent + 1) + NodeHelper.DISCRIMINATOR_FLAG + ': true'); } @@ -203,7 +204,7 @@ export class Dumper { output.push(Dumper.tab(indent + 1) + 'readOnly: true'); } - if (parameter.schema instanceof ObjectSchema && NodeHelper.HasSubClass(parameter.schema)) { + if (Helper.isObjectSchema(parameter.schema) && NodeHelper.HasSubClass(parameter.schema as ObjectSchema)) { output.push(Dumper.tab(indent + 1) + NodeHelper.DISCRIMINATOR_FLAG + ': true'); } @@ -313,9 +314,9 @@ export class Dumper { return o; else if (isArray(o)) return o.map(v => Dumper.NEW_LINE + Dumper.tab(indent) + "- " + Dumper.formatValue(v, indent + 2/* one more indent for array*/)).join(''); - else if (o instanceof ObjectSchema) + else if (Helper.isObjectSchema(o)) return `<${(o as ObjectSchema).language.default.name}>`; - else if (o instanceof Operation) + else if (Helper.isOperation(o)) return `<${(o as Operation).language.default.name}>`; else if (isObject(o)) return keys(o).select(k => Dumper.NEW_LINE + Dumper.tab(indent) + `${k}: ${Dumper.formatValue(o[k], indent + 1)}`).join(''); diff --git a/src/flattenHelper.ts b/src/flattenHelper.ts index 5ed3cbe..ed66055 100644 --- a/src/flattenHelper.ts +++ b/src/flattenHelper.ts @@ -1,12 +1,13 @@ import { getAllProperties, ImplementationLocation, ObjectSchema, Parameter, Property, Request, VirtualParameter } from "@azure-tools/codemodel"; import { values } from "@azure-tools/linq"; import { isNullOrUndefined } from "util"; +import { Helper } from "./helper"; import { NodeExtensionHelper, NodeCliHelper } from "./nodeHelper"; export class FlattenHelper { public static flattenParameter(req: Request, param: Parameter, path: Property[], prefix: string): void { - if (!(param.schema instanceof ObjectSchema)) + if (!Helper.isObjectSchema(param.schema)) throw Error(`Try to flatten non-object schema: param = '${param.language.default.name}', schema= '${param.schema.language.default.name}'`); FlattenHelper.flattenPorperties(req, param, param.schema as ObjectSchema, path, prefix); @@ -48,6 +49,15 @@ export class FlattenHelper { (vp.extensions = vp.extensions || {})['x-ms-parameter-grouping'] = parameter.extensions?.['x-ms-parameter-grouping']; } + vp.required = parameter.required && property.required; + if (NodeCliHelper.getHidden(property.schema, false)) { + NodeCliHelper.setHidden(vp, true); + } + const cliDefaultValue = NodeCliHelper.getCliDefaultValue(property.schema); + if (cliDefaultValue !== undefined) { + NodeCliHelper.setCliDefaultValue(vp, cliDefaultValue); + } + yield vp; } diff --git a/src/helper.ts b/src/helper.ts index 5b83723..0b85d78 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -1,4 +1,4 @@ -import { codeModelSchema, ChoiceSchema, ChoiceValue, CodeModel, ObjectSchema, Operation, OperationGroup, Parameter, Property, SealedChoiceSchema, Schema, ConstantSchema, SchemaType, StringSchema } from "@azure-tools/codemodel"; +import { codeModelSchema, ChoiceSchema, ChoiceValue, CodeModel, ObjectSchema, Operation, OperationGroup, Parameter, Property, SealedChoiceSchema, Schema, ConstantSchema, SchemaType, StringSchema, DictionarySchema, ArraySchema, AnySchema } from "@azure-tools/codemodel"; import { isArray, isNullOrUndefined, isString } from "util"; import { CliConst, M4Node, M4NodeType, NamingType, CliCommonSchema } from "./schema"; import { EnglishPluralizationService, guid } from '@azure-tools/codegen'; @@ -118,49 +118,49 @@ export class Helper { public static ToNamingType(node: M4Node): NamingType | null { - if (node instanceof OperationGroup) + if (Helper.isOperationGroup(node)) return CliConst.NamingType.operationGroup; - else if (node instanceof Operation) + else if (Helper.isOperation(node)) return CliConst.NamingType.operation; - else if (node instanceof Parameter) { + else if (Helper.isParameter(node)) { // workaround for modelerfour's bug, the naming convention is not applied to flattened parameter // https://github.com/Azure/autorest.modelerfour/issues/195 if (node['flattened'] === true) return null; - return node.schema?.type === SchemaType.Constant ? CliConst.NamingType.constant : CliConst.NamingType.parameter; + return (node).schema?.type === SchemaType.Constant ? CliConst.NamingType.constant : CliConst.NamingType.parameter; } - else if (node instanceof ChoiceSchema) + else if (Helper.isChoiceSchema(node)) return CliConst.NamingType.choice; - else if (node instanceof SealedChoiceSchema) + else if (Helper.isSealedChoiceSchema(node)) return CliConst.NamingType.choice; - else if (node instanceof ConstantSchema) + else if (Helper.isConstantSchema(node)) return CliConst.NamingType.constant; - else if (node instanceof ChoiceValue) + else if (Helper.isChoiceValue(node)) return CliConst.NamingType.choiceValue; // Treat other schema type as 'type' like 'string, 'number', 'array', 'dictionary', 'object'... - else if (node instanceof Schema) + else if (Helper.isSchema(node)) return CliConst.NamingType.type; - else if (node instanceof Property) + else if (Helper.isProperty(node)) return CliConst.NamingType.property; return null; } public static ToM4NodeType(node: M4Node): M4NodeType { - if (node instanceof OperationGroup) + if (Helper.isOperationGroup(node)) return CliConst.SelectType.operationGroup; - else if (node instanceof Operation) + else if (Helper.isOperation(node)) return CliConst.SelectType.operation; - else if (node instanceof Parameter) + else if (Helper.isParameter(node)) return CliConst.SelectType.parameter; - else if (node instanceof ObjectSchema) + else if (Helper.isObjectSchema(node)) return CliConst.SelectType.objectSchema; - else if (node instanceof Property) + else if (Helper.isProperty(node)) return CliConst.SelectType.property; - else if (node instanceof ChoiceSchema) + else if (Helper.isChoiceSchema(node)) return CliConst.SelectType.choiceSchema; - else if (node instanceof SealedChoiceSchema) + else if (Helper.isSealedChoiceSchema(node)) return CliConst.SelectType.choiceSchema; - else if (node instanceof ChoiceValue) + else if (Helper.isChoiceValue(node)) return CliConst.SelectType.choiceValue; throw Error(`Unsupported node type: ${typeof (node)}`); } @@ -568,4 +568,231 @@ export class Helper { } } + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isOperationGroup(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof OperationGroup) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + const props = Object.getOwnPropertyNames(o); + if (props.find((prop) => prop === '$key') && props.find((prop) => prop === 'operations')) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isOperation(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof Operation) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + const props = Object.getOwnPropertyNames(o); + if (props.find((prop) => prop === 'responses') || props.find((prop) => prop === 'parameters')) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isParameter(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof Parameter) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + const props = Object.getOwnPropertyNames(o); + if (props.find((prop) => prop === 'implementation') || props.find((prop) => prop === 'flattened') || props.find((prop) => prop === 'groupedBy')) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isObjectSchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof ObjectSchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.Object) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isDictionarySchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof DictionarySchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.Dictionary) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isArraySchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof ArraySchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.Array) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isAnySchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof AnySchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.Any) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isChoiceSchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof ChoiceSchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.Choice) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isSealedChoiceSchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof SealedChoiceSchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.SealedChoice) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isConstantSchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof ConstantSchema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + if (o.type === SchemaType.Constant) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isChoiceValue(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof ChoiceValue) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + const props = Object.getOwnPropertyNames(o); + if (props.find((prop) => prop === 'language') && props.find((prop) => prop === 'value')) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isSchema(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof Schema) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + const props = Object.getOwnPropertyNames(o); + if (props.find((prop) => prop === 'type')) { + return true; + } + return false; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + public static isProperty(o: any): boolean { + if (isNullOrUndefined(o)) { + return false; + } + if (o instanceof Property) { + return true; + } + if (o.prototype !== Object.prototype) { + return false; + } + const props = Object.getOwnPropertyNames(o); + if (props.find((prop) => prop === 'serializedName')) { + return true; + } + return false; + } + } \ No newline at end of file diff --git a/src/nodeHelper.ts b/src/nodeHelper.ts index 3c3927c..6bb2d4d 100644 --- a/src/nodeHelper.ts +++ b/src/nodeHelper.ts @@ -10,7 +10,7 @@ export class NodeCliHelper { public static readonly POLY_RESOURCE: string = 'poly-resource'; public static readonly CLI_FLATTEN: string = 'cli-flatten'; public static readonly SPLIT_OPERATION_NAMES = 'split-operation-names'; - + private static readonly CLI: string = "cli"; private static readonly NAME: string = "name"; private static readonly DESCRIPTION: string = "description"; @@ -23,7 +23,8 @@ export class NodeCliHelper { private static readonly CLI_MARK: string = "cli-mark"; private static readonly CLI_IS_VISIBLE: string = "cli-is-visible"; private static readonly CLI_OPERATION_SPLITTED = 'cli-operation-splitted'; - private static readonly JSON: string = "json"; + private static readonly CLI_DEFAULT_VALUE: string = "default-value"; + private static readonly POLY_AS_PARAM_EXPANDED = 'cli-poly-as-param-expanded'; @@ -147,6 +148,15 @@ export class NodeCliHelper { return NodeCliHelper.getCliProperty(node, NodeCliHelper.CLI_IS_VISIBLE, () => undefined); } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + public static setCliDefaultValue(node: M4Node, value: any): void { + NodeCliHelper.setCliProperty(node, NodeCliHelper.CLI_DEFAULT_VALUE, value); + } + + public static getCliDefaultValue(node: M4Node): any { + return NodeCliHelper.getCliProperty(node, NodeCliHelper.CLI_DEFAULT_VALUE, () => undefined); + } + /** * set node.language.cli.key = value * @param node @@ -410,15 +420,15 @@ export class NodeHelper { for (const key in allSubs) { const subClass = allSubs[key]; - if (!(subClass instanceof ObjectSchema)) { + if (!Helper.isObjectSchema(subClass)) { Helper.logWarning("subclass is not ObjectSchema: " + subClass.language.default.name); continue; } - if (NodeHelper.HasSubClass(subClass) && leafOnly) { + if (NodeHelper.HasSubClass(subClass as ObjectSchema) && leafOnly) { Helper.logWarning("skip subclass which also has subclass: " + subClass.language.default.name); continue; } - yield subClass; + yield subClass as ObjectSchema; } } @@ -435,7 +445,9 @@ export class NodeHelper { } public static getDefaultNameWithType(node: ObjectSchema | DictionarySchema | ArraySchema): string { - return `${node.language.default.name}(${node instanceof ObjectSchema ? node.type : node instanceof DictionarySchema ? (node.elementType.language.default.name + '^dictionary') : (node.elementType.language.default.name + '^array')})`; + return `${node.language.default.name}(${Helper.isObjectSchema(node) ? node.type : + Helper.isDictionarySchema(node) ? ((node).elementType.language.default.name + '^dictionary') : + ((node).elementType.language.default.name + '^array')})`; } public static checkVisibility(prop: Property): boolean { diff --git a/src/plugins/complexMarker.ts b/src/plugins/complexMarker.ts index 6f80f1c..ce469bd 100644 --- a/src/plugins/complexMarker.ts +++ b/src/plugins/complexMarker.ts @@ -1,5 +1,5 @@ import { Host, Session } from "@azure-tools/autorest-extension-base"; -import { CodeModel, isObjectSchema, ArraySchema, DictionarySchema, AnySchema, ConstantSchema, getAllProperties, ObjectSchema } from "@azure-tools/codemodel"; +import { CodeModel, ArraySchema, DictionarySchema, getAllProperties, ObjectSchema } from "@azure-tools/codemodel"; import { isNullOrUndefined } from "util"; import { Helper } from "../helper"; import { CliCommonSchema } from "../schema"; @@ -22,10 +22,10 @@ class ComplexMarker { } NodeCliHelper.setComplex(dict, CliCommonSchema.CodeModel.Complexity.unknown); - if (dict.elementType instanceof ObjectSchema || - dict.elementType instanceof ArraySchema || - dict.elementType instanceof DictionarySchema || - dict.elementType instanceof AnySchema) { + if (Helper.isObjectSchema(dict.elementType) || + Helper.isArraySchema(dict) || + Helper.isDictionarySchema(dict.elementType) || + Helper.isAnySchema(dict.elementType)) { NodeCliHelper.setComplex(dict, CliCommonSchema.CodeModel.Complexity.dictionary_complex); return CliCommonSchema.CodeModel.Complexity.dictionary_complex; } @@ -47,10 +47,10 @@ class ComplexMarker { } NodeCliHelper.setComplex(arr, CliCommonSchema.CodeModel.Complexity.unknown); - if (arr.elementType instanceof ObjectSchema || - arr.elementType instanceof ArraySchema || - arr.elementType instanceof DictionarySchema || - arr.elementType instanceof AnySchema) { + if (Helper.isObjectSchema(arr.elementType) || + Helper.isArraySchema(arr.elementType) || + Helper.isDictionarySchema(arr.elementType) || + Helper.isAnySchema(arr.elementType)) { NodeCliHelper.setComplex(arr, CliCommonSchema.CodeModel.Complexity.array_complex); return CliCommonSchema.CodeModel.Complexity.array_complex; } @@ -80,21 +80,21 @@ class ComplexMarker { complexity = CliCommonSchema.CodeModel.Complexity.object_simple; if (obj.properties && obj.properties.length > 0) { for (const prop of obj.properties) { - if (isObjectSchema(prop.schema)) { - this.calculateObject(prop.schema); + if (Helper.isObjectSchema(prop.schema)) { + this.calculateObject(prop.schema as ObjectSchema); return NodeCliHelper.setComplex(obj, CliCommonSchema.CodeModel.Complexity.object_complex); } - else if (prop.schema instanceof ArraySchema) { - const c = this.calculateArray(prop.schema); + else if (Helper.isArraySchema(prop.schema)) { + const c = this.calculateArray(prop.schema as ArraySchema); if (c === CliCommonSchema.CodeModel.Complexity.array_complex) { return NodeCliHelper.setComplex(obj, CliCommonSchema.CodeModel.Complexity.object_complex); } } - else if (prop.schema instanceof DictionarySchema) { - this.calculateDict(prop.schema); + else if (Helper.isDictionarySchema(prop.schema)) { + this.calculateDict(prop.schema as DictionarySchema); return NodeCliHelper.setComplex(obj, CliCommonSchema.CodeModel.Complexity.object_complex); } - else if (prop.schema instanceof AnySchema) { + else if (Helper.isAnySchema(prop.schema)) { return NodeCliHelper.setComplex(obj, CliCommonSchema.CodeModel.Complexity.object_complex); } } @@ -131,18 +131,18 @@ class ComplexMarker { for (const p of getAllProperties(schema)) { if (p.readOnly) continue; - if (p.schema instanceof ConstantSchema) + if (Helper.isConstantSchema(p.schema)) continue; - if (p.schema instanceof AnySchema || - p.schema instanceof ArraySchema || - p.schema instanceof DictionarySchema) { + if (Helper.isAnySchema(p.schema) || + Helper.isArraySchema(p.schema) || + Helper.isDictionarySchema(p.schema)) { return NodeCliHelper.setSimplifyIndicator(schema, impossible); } - else if (p.schema instanceof ObjectSchema) { - if (NodeHelper.HasSubClass(p.schema)) { + else if (Helper.isObjectSchema(p.schema)) { + if (NodeHelper.HasSubClass(p.schema as ObjectSchema)) { return NodeCliHelper.setSimplifyIndicator(schema, impossible); } - const pi = this.setSimplifyIndicator(p.schema); + const pi = this.setSimplifyIndicator(p.schema as ObjectSchema); if (pi.simplifiable === true) { if (NodeCliHelper.getComplexity(p.schema) === CliCommonSchema.CodeModel.Complexity.object_simple) indicator.propertyCountIfSimplifyWithoutSimpleObject++; @@ -185,22 +185,23 @@ class ComplexMarker { else { NodeCliHelper.setMark(schema, tag); - if (schema instanceof ArraySchema || schema instanceof DictionarySchema) { - if (schema.elementType instanceof ObjectSchema || - schema.elementType instanceof DictionarySchema || - schema.elementType instanceof ArraySchema) { + if (Helper.isArraySchema(schema) || Helper.isDictionarySchema(schema)) { + if (Helper.isObjectSchema((schema).elementType) || + Helper.isDictionarySchema((schema).elementType) || + Helper.isArraySchema((schema).elementType)) { stack.push(schema); - this.setInCircle(schema.elementType, stack, tag); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this.setInCircle(( | DictionarySchema>schema).elementType, stack, tag); stack.splice(stack.length - 1, 1); } } - else if (schema instanceof ObjectSchema) { - for (const prop of getAllProperties(schema)) { - if (prop.schema instanceof ObjectSchema || - prop.schema instanceof DictionarySchema || - prop.schema instanceof ArraySchema) { + else if (Helper.isObjectSchema(schema)) { + for (const prop of getAllProperties(schema as ObjectSchema)) { + if (Helper.isObjectSchema(prop.schema) || + Helper.isDictionarySchema(prop.schema) || + Helper.isArraySchema(prop.schema)) { stack.push(schema); - this.setInCircle(prop.schema, stack, tag); + this.setInCircle(prop.schema as ObjectSchema, stack, tag); stack.splice(stack.length - 1, 1); } } @@ -211,7 +212,7 @@ class ComplexMarker { public process(): void { - this.session.model.schemas.objects.forEach(obj => { + this.session.model.schemas.objects?.forEach(obj => { NodeCliHelper.clearComplex(obj); NodeCliHelper.clearSimplifyIndicator(obj); NodeCliHelper.clearMark(obj); @@ -228,7 +229,7 @@ class ComplexMarker { }); let tag = 1; - this.session.model.schemas.objects.forEach(obj => { + this.session.model.schemas.objects?.forEach(obj => { this.calculateObject(obj); tag++; }); @@ -241,12 +242,12 @@ class ComplexMarker { tag++; }); - this.session.model.schemas.objects.forEach(obj => { + this.session.model.schemas.objects?.forEach(obj => { this.setSimplifyIndicator(obj); tag++; }); - this.session.model.schemas.objects.forEach(obj => { + this.session.model.schemas.objects?.forEach(obj => { this.setInCircle(obj, [], tag.toString()); tag++; }); diff --git a/src/plugins/flattenModifier.ts b/src/plugins/flattenModifier.ts index 5b9875d..4dade3f 100644 --- a/src/plugins/flattenModifier.ts +++ b/src/plugins/flattenModifier.ts @@ -109,7 +109,7 @@ export class FlattenModifier { private flattenNormalOperationParam(request: Request, index: number): boolean { const parameter = request.parameters[index]; const paramSchema = parameter.schema; - if (!(paramSchema instanceof ObjectSchema)) { + if (!Helper.isObjectSchema(paramSchema)) { Helper.logWarning(`flatten param ${NodeCliHelper.getCliKey(parameter, null)} is not object! Skip flatten`); return false; } diff --git a/src/plugins/flattenSetter/flattenSetter.ts b/src/plugins/flattenSetter/flattenSetter.ts index fdd3e9d..666b43b 100644 --- a/src/plugins/flattenSetter/flattenSetter.ts +++ b/src/plugins/flattenSetter/flattenSetter.ts @@ -1,5 +1,5 @@ import { Host, Session } from "@azure-tools/autorest-extension-base"; -import { CodeModel, ObjectSchema, isObjectSchema, getAllProperties, Parameter, DictionarySchema, Schema, ArraySchema, ConstantSchema, AnySchema } from "@azure-tools/codemodel"; +import { CodeModel, ObjectSchema, getAllProperties, Parameter, Schema, ArraySchema } from "@azure-tools/codemodel"; import { isNullOrUndefined, isArray } from "util"; import { Helper } from "../../helper"; import { NodeHelper, NodeCliHelper, NodeExtensionHelper } from "../../nodeHelper"; @@ -50,16 +50,16 @@ export class FlattenSetter { } private canArrayObjectSimplified(schema: Schema, maxArrayObjProp: number) { - if (schema instanceof ObjectSchema && !NodeHelper.HasSubClass(schema)) { - const sim = NodeCliHelper.getSimplifyIndicator(schema); + if (Helper.isObjectSchema(schema) && !NodeHelper.HasSubClass(schema as ObjectSchema)) { + const sim = NodeCliHelper.getSimplifyIndicator(schema as ObjectSchema); return ((!isNullOrUndefined(sim)) && sim.simplifiable === true && sim.propertyCountIfSimplify <= maxArrayObjProp); } return false; } private canSubclassSimplified(schema: Schema, flattenConfig: FlattenConfig, isPolyAsResource: boolean) { - if (schema instanceof ObjectSchema && !isNullOrUndefined(schema.discriminatorValue) && !NodeHelper.HasSubClass(schema)) { - const sim = NodeCliHelper.getSimplifyIndicator(schema); + if (Helper.isObjectSchema(schema) && !isNullOrUndefined((schema).discriminatorValue) && !NodeHelper.HasSubClass(schema as ObjectSchema)) { + const sim = NodeCliHelper.getSimplifyIndicator(schema as ObjectSchema); if (isPolyAsResource) return ((!isNullOrUndefined(sim)) && sim.simplifiable === true && sim.propertyCountIfSimplifyWithoutSimpleObject <= flattenConfig.maxPolyAsResourcePropCount); else @@ -90,27 +90,27 @@ export class FlattenSetter { let r = level; - if (schema instanceof ArraySchema) { + if (Helper.isArraySchema(schema)) { increasePropCount(); if (NodeCliHelper.getComplexity(schema) === CliCommonSchema.CodeModel.Complexity.array_complex) { if (!this.canArrayObjectSimplified(schema, flattenConfig.maxArrayPropCount)) increaseComplexity(); } } - else if (schema instanceof DictionarySchema) { + else if (Helper.isDictionarySchema(schema)) { increasePropCount(); if (NodeCliHelper.getComplexity(schema) === CliCommonSchema.CodeModel.Complexity.dictionary_complex) increaseComplexity(); } - else if (schema instanceof AnySchema) { + else if (Helper.isAnySchema(schema)) { increasePropCount(); increaseComplexity(); } // eslint-disable-next-line no-empty - else if (schema instanceof ConstantSchema) { + else if (Helper.isConstantSchema(schema)) { } - else if (schema instanceof ObjectSchema) { - if (NodeHelper.HasSubClass(schema)) { + else if (Helper.isObjectSchema(schema)) { + if (NodeHelper.HasSubClass(schema as ObjectSchema)) { increasePropCount(); increaseComplexity(); } @@ -120,7 +120,7 @@ export class FlattenSetter { else { info[level].propCount++; info[level].complexity += weight; - for (const prop of getAllProperties(schema)) { + for (const prop of getAllProperties(schema as ObjectSchema)) { if (prop.readOnly) continue; if (level + 1 < info.length) { @@ -191,39 +191,39 @@ export class FlattenSetter { private flattenSchemaFromPayload(schema: Schema, curLevel: number, flattenSimpleObject: boolean, flattenConfig: FlattenConfig) { - if (!(schema instanceof ObjectSchema)) + if (!Helper.isObjectSchema(schema)) return; if (curLevel >= flattenConfig.maxLevel) { - const indicator = NodeCliHelper.getSimplifyIndicator(schema); + const indicator = NodeCliHelper.getSimplifyIndicator(schema as ObjectSchema); // Continue flatten if there is only one property even when we hit the max level if (indicator.simplifiable !== true || indicator.propertyCountIfSimplify !== 1) return; Helper.logDebug(`continue flatten ${schema.language.default.name} when maxLevel is met because it's simplifiyIndicator.propertyCountIfSimplify is ${indicator.propertyCountIfSimplify}`); } - for (const prop of getAllProperties(schema)) { + for (const prop of getAllProperties(schema as ObjectSchema)) { if (prop.readOnly) continue; - if (prop.schema instanceof ObjectSchema) { - if (NodeHelper.HasSubClass(prop.schema)) { - this.flattenPolySchema(prop.schema, NodeCliHelper.getCliKey(prop, "noParamCliKey"), curLevel, flattenSimpleObject, flattenConfig); + if (Helper.isObjectSchema(prop.schema)) { + if (NodeHelper.HasSubClass(prop.schema as ObjectSchema)) { + this.flattenPolySchema(prop.schema as ObjectSchema, NodeCliHelper.getCliKey(prop, "noParamCliKey"), curLevel, flattenSimpleObject, flattenConfig); } - else if (NodeCliHelper.getInCircle(prop.schema) !== true) { + else if (NodeCliHelper.getInCircle(prop.schema as ObjectSchema) !== true) { if (flattenSimpleObject || NodeCliHelper.getComplexity(prop.schema) !== CliCommonSchema.CodeModel.Complexity.object_simple || - NodeCliHelper.getSimplifyIndicator(prop.schema).propertyCountIfSimplify == 1) { + NodeCliHelper.getSimplifyIndicator(prop.schema as ObjectSchema).propertyCountIfSimplify == 1) { NodeExtensionHelper.setFlatten(prop, true, flattenConfig.overwriteSwagger); } } } - else if (prop.schema instanceof ArraySchema) { - if (this.canArrayObjectSimplified(prop.schema.elementType, flattenConfig.maxArrayPropCount)) { + else if (Helper.isArraySchema(prop.schema)) { + if (this.canArrayObjectSimplified((prop.schema).elementType, flattenConfig.maxArrayPropCount)) { // put 32 as max flatten level for array object flatten here just in case, // it should be big enough value for array object flattening, but handle unexpected circle // situation though it's not expected const config = cloneFlattenConfig(flattenConfig); config.maxLevel = Math.max(32, config.maxLevel); - this.flattenSchemaFromPayload(prop.schema.elementType, curLevel, true, config); + this.flattenSchemaFromPayload((prop.schema).elementType, curLevel, true, config); } } this.flattenSchemaFromPayload(prop.schema, curLevel + 1, flattenSimpleObject, flattenConfig); @@ -231,10 +231,10 @@ export class FlattenSetter { } private flattenPayload(param: Parameter, flattenConfig: FlattenConfig): void { - if (!(param.schema instanceof ObjectSchema)) + if (!Helper.isObjectSchema(param.schema)) return; - if (NodeHelper.HasSubClass(param.schema)) { - this.flattenPolySchema(param.schema, NodeCliHelper.getCliKey(param, "noParamCliKey"), 0, true, flattenConfig); + if (NodeHelper.HasSubClass(param.schema as ObjectSchema)) { + this.flattenPolySchema(param.schema as ObjectSchema, NodeCliHelper.getCliKey(param, "noParamCliKey"), 0, true, flattenConfig); } else { const r = this.calcPayloadFlatten(param.schema, flattenConfig); @@ -256,10 +256,10 @@ export class FlattenSetter { // by default on when the flatten_all flag is one if (flattenSchema === true || flattenAll === true) { - this.codeModel.schemas.objects.forEach(o => { + this.codeModel.schemas.objects?.forEach(o => { if (!NodeHelper.HasSubClass(o)) { for (const p of getAllProperties(o)) { - if (isObjectSchema(p.schema)) { + if (Helper.isObjectSchema(p.schema)) { NodeExtensionHelper.setFlatten(p, !NodeHelper.HasSubClass(p.schema as ObjectSchema), overwriteSwagger); } } @@ -301,12 +301,12 @@ export class FlattenSetter { }; if (flattenPayload === true || flattenAll === true) { - this.codeModel.operationGroups.forEach(group => { + this.codeModel.operationGroups?.forEach(group => { group.operations.forEach(operation => { values(operation.parameters) .where(p => p.protocol.http?.in === 'body' && p.implementation === 'Method') .forEach((p) => { - if (p.schema instanceof ObjectSchema) { + if (Helper.isObjectSchema(p.schema)) { Helper.logDebug(`Try to set flatten for ${group.language.default.name}/${operation.language.default.name}/${p.language.default.name}`); flattenConfig.nodeDescripter = { @@ -326,7 +326,7 @@ export class FlattenSetter { values(request.parameters) .where(p => p.protocol.http?.in === 'body' && p.implementation === 'Method') .forEach(p => { - if (p.schema instanceof ObjectSchema) { + if (Helper.isObjectSchema(p.schema)) { Helper.logDebug(`Try to set flatten for ${group.language.default.name}/${operation.language.default.name}/${p.language.default.name}`); flattenConfig.nodeDescripter = { diff --git a/src/plugins/flattenSetter/flattenValidator.ts b/src/plugins/flattenSetter/flattenValidator.ts index 72aa6f7..fd1b1a9 100644 --- a/src/plugins/flattenSetter/flattenValidator.ts +++ b/src/plugins/flattenSetter/flattenValidator.ts @@ -1,5 +1,5 @@ import { Session } from "@azure-tools/autorest-extension-base"; -import { CodeModel, isObjectSchema, ObjectSchema, Property } from "@azure-tools/codemodel"; +import { CodeModel, ObjectSchema, Property } from "@azure-tools/codemodel"; import { isNullOrUndefined } from "util"; import { Helper } from "../../helper"; import { NodeHelper, NodeExtensionHelper } from "../../nodeHelper"; @@ -51,7 +51,7 @@ class NodeInfo { if (!isNullOrUndefined(this.node.properties) && this.node.properties.length > 0) { for (let i = 0; i < this.node.properties.length; i++) { const p = this.node.properties[i]; - if (isObjectSchema(p.schema)) { + if (Helper.isObjectSchema(p.schema)) { NodeExtensionHelper.isFlattened(p) ? this.flattenProperty.push(new PropertyInfo(p)) : this.unflattenProperty.push(new PropertyInfo(p)); } } @@ -125,7 +125,7 @@ export class FlattenValidator { const result: NodePath[] = []; const visited = new Set(); - objects.forEach(o => { + objects?.forEach(o => { const ni = new NodeInfo(o); if (!visited.has(ni.key)) this.visitNode(ni, [], result, visited); diff --git a/src/plugins/modelerPostProcessor.ts b/src/plugins/modelerPostProcessor.ts index d751d18..9a1a61a 100644 --- a/src/plugins/modelerPostProcessor.ts +++ b/src/plugins/modelerPostProcessor.ts @@ -1,8 +1,10 @@ import { Host, Session } from "@azure-tools/autorest-extension-base"; -import { CodeModel } from "@azure-tools/codemodel"; +import { ChoiceSchema, CodeModel, Parameter, SealedChoiceSchema, StringSchema } from "@azure-tools/codemodel"; import { isNullOrUndefined } from "util"; import { Helper } from "../helper"; import { CopyHelper } from "../copyHelper"; +import { CliCommonSchema } from "../schema"; +import { NodeCliHelper } from "../nodeHelper"; export class ModelerPostProcessor { @@ -10,14 +12,52 @@ export class ModelerPostProcessor { } public process(): void { - Helper.enumerateCodeModel(this.session.model, (n) => { + const model = this.session.model; - // In case cli is shared by multiple instances during modelerfour, do deep copy + this.removeCliShare(model); + + this.adjustChoiceschema(model); + } + + private removeCliShare(model: CodeModel): void { + // In case cli is shared by multiple instances during modelerfour, do deep copy + Helper.enumerateCodeModel(model, (n) => { if (!isNullOrUndefined(n.target.language['cli'])) { n.target.language['cli'] = CopyHelper.deepCopy(n.target.language['cli']); } }); } + + private adjustChoiceschema(model: CodeModel): void { + // For m4 change: https://github.com/Azure/autorest.modelerfour/pull/310/files + // If `modelAsString` is not true, it will no longer be regarded as constant, but choice. + // To make it backward compatiable, for those choices which are constant before(choice.length === 1), + // we give it a default value and set hidden as true. + // The following codegen should handle this case. + + // Set schema + Helper.enumerateCodeModel(model, (n) => { + const schema = | SealedChoiceSchema>n.target; + if (!isNullOrUndefined(schema.choices) && schema.choices.length === 1) { + NodeCliHelper.setCliDefaultValue(schema, schema.choices[0].value); + NodeCliHelper.setHidden(schema, true); + } + }, CliCommonSchema.CodeModel.NodeTypeFlag.choiceSchema); + + // Set parameter according to schema + Helper.enumerateCodeModel(model, (n) => { + const parameter = n.target; + if (!isNullOrUndefined(parameter) && (Helper.isChoiceSchema(parameter.schema) || Helper.isChoiceSchema(parameter.schema))) { + if (NodeCliHelper.getHidden(parameter.schema, false)) { + NodeCliHelper.setHidden(parameter, true); + } + const cliDefaultValue = NodeCliHelper.getCliDefaultValue(parameter.schema); + if (cliDefaultValue !== undefined) { + NodeCliHelper.setCliDefaultValue(parameter, cliDefaultValue); + } + } + }, CliCommonSchema.CodeModel.NodeTypeFlag.parameter); + } } export async function processRequest(host: Host): Promise { diff --git a/src/plugins/polyAsParamModifier.ts b/src/plugins/polyAsParamModifier.ts index 2589442..201919d 100644 --- a/src/plugins/polyAsParamModifier.ts +++ b/src/plugins/polyAsParamModifier.ts @@ -62,7 +62,7 @@ export class PolyAsParamModifier { if (isNullOrUndefined(request.parameters)) return; const allPolyParam: Parameter[] = request.parameters.filter(p => - p.schema instanceof ObjectSchema && + Helper.isObjectSchema(p.schema) && (p.schema as ObjectSchema).discriminator); if (allPolyParam.length == 0) return; @@ -83,16 +83,16 @@ export class PolyAsParamModifier { for (const key in allSubClass) { const subClass = allSubClass[key]; - if (!(subClass instanceof ObjectSchema)) { + if (!Helper.isObjectSchema(subClass)) { Helper.logWarning("subclass is not ObjectSchema: " + subClass.language.default.name); continue; } - if (NodeHelper.HasSubClass(subClass)) { + if (NodeHelper.HasSubClass(subClass as ObjectSchema)) { Helper.logWarning("skip subclass which also has subclass: " + subClass.language.default.name); continue; } - const param2: Parameter = this.cloneParamForSubclass(polyParam, this.buildSubclassParamName(polyParam, key), subClass); + const param2: Parameter = this.cloneParamForSubclass(polyParam, this.buildSubclassParamName(polyParam, key), subClass as ObjectSchema); NodeExtensionHelper.setPolyAsParamOriginalParam(param2, polyParam); request.addParameter(param2); } diff --git a/src/plugins/polyAsResourceModifier.ts b/src/plugins/polyAsResourceModifier.ts index c83634d..4ec785c 100644 --- a/src/plugins/polyAsResourceModifier.ts +++ b/src/plugins/polyAsResourceModifier.ts @@ -129,7 +129,7 @@ export class PolyAsResourceModifier { return []; } return request.parameters?.filter(p => - p.schema instanceof ObjectSchema && (p.schema as ObjectSchema).discriminator && NodeCliHelper.isPolyAsResource(p)); + Helper.isObjectSchema(p.schema) && (p.schema as ObjectSchema).discriminator && NodeCliHelper.isPolyAsResource(p)); } private getDefaultRequest(operation: Operation): Request { diff --git a/src/plugins/visibilityCleaner.ts b/src/plugins/visibilityCleaner.ts index 5d84bc1..5f21059 100644 --- a/src/plugins/visibilityCleaner.ts +++ b/src/plugins/visibilityCleaner.ts @@ -1,5 +1,5 @@ import { Host, Session } from "@azure-tools/autorest-extension-base"; -import { CodeModel, ObjectSchema, isObjectSchema, Parameter, ArraySchema, DictionarySchema, ConstantSchema } from "@azure-tools/codemodel"; +import { CodeModel, ObjectSchema, Parameter } from "@azure-tools/codemodel"; import { Helper } from "../helper"; import { CliCommonSchema } from "../schema"; import { NodeHelper, NodeCliHelper } from "../nodeHelper"; @@ -32,14 +32,14 @@ class VisibilityCleaner { for (const prop of schema.properties) { if (!NodeHelper.checkVisibility(prop)) continue; - if (isObjectSchema(prop.schema)) { - if (this.calcObject(prop.schema) === CliCommonSchema.CodeModel.Visibility.true) + if (Helper.isObjectSchema(prop.schema)) { + if (this.calcObject(prop.schema as ObjectSchema) === CliCommonSchema.CodeModel.Visibility.true) visible = CliCommonSchema.CodeModel.Visibility.true; } - else if ((prop.schema instanceof ArraySchema || prop.schema instanceof DictionarySchema)) { + else if (Helper.isArraySchema(prop.schema) || Helper.isDictionarySchema(prop.schema)) { visible = CliCommonSchema.CodeModel.Visibility.true; } - else if (prop.schema instanceof ConstantSchema) { + else if (Helper.isConstantSchema(prop.schema)) { // do nothing here } else { @@ -71,8 +71,8 @@ class VisibilityCleaner { }); Helper.enumerateCodeModel(this.session.model, (descriptor) => { - if (descriptor.target instanceof Parameter) { - if (NodeCliHelper.getIsVisibleFlag(descriptor.target.schema) === CliCommonSchema.CodeModel.Visibility.false) { + if (Helper.isParameter(descriptor.target)) { + if (NodeCliHelper.getIsVisibleFlag((descriptor.target).schema) === CliCommonSchema.CodeModel.Visibility.false) { NodeCliHelper.setHidden(descriptor.target, true); NodeCliHelper.setIsVisibleFlag(descriptor.target, CliCommonSchema.CodeModel.Visibility.false); } diff --git a/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post.yaml b/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post.yaml index 730f255..8197903 100644 --- a/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post.yaml +++ b/test/scenarios/datafactory/output/clicommon-000100-modeler-post-processor-post.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre.yaml b/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre.yaml index eb015b1..b398d7b 100644 --- a/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre.yaml +++ b/test/scenarios/datafactory/output/clicommon-000110-poly-as-resource-pre.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post.yaml b/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post.yaml index df714fc..1fd8112 100644 --- a/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post.yaml +++ b/test/scenarios/datafactory/output/clicommon-000120-poly-as-resource-post.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000130-flatten-pre-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000130-flatten-pre-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000130-flatten-pre-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000130-flatten-pre-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000130-flatten-pre.yaml b/test/scenarios/datafactory/output/clicommon-000130-flatten-pre.yaml index c097eb4..7983381 100644 --- a/test/scenarios/datafactory/output/clicommon-000130-flatten-pre.yaml +++ b/test/scenarios/datafactory/output/clicommon-000130-flatten-pre.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000140-flatten-post-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000140-flatten-post-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000140-flatten-post-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000140-flatten-post-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000140-flatten-post.yaml b/test/scenarios/datafactory/output/clicommon-000140-flatten-post.yaml index 6036ad8..9f41db4 100644 --- a/test/scenarios/datafactory/output/clicommon-000140-flatten-post.yaml +++ b/test/scenarios/datafactory/output/clicommon-000140-flatten-post.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000150-modifier-pre-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000150-modifier-pre-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000150-modifier-pre-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000150-modifier-pre-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000150-modifier-pre.yaml b/test/scenarios/datafactory/output/clicommon-000150-modifier-pre.yaml index 76876db..9a6fa1f 100644 --- a/test/scenarios/datafactory/output/clicommon-000150-modifier-pre.yaml +++ b/test/scenarios/datafactory/output/clicommon-000150-modifier-pre.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000160-modifier-post-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000160-modifier-post-simplified.yaml index ffb1a74..af74f00 100644 --- a/test/scenarios/datafactory/output/clicommon-000160-modifier-post-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000160-modifier-post-simplified.yaml @@ -2984,6 +2984,8 @@ schemas: - choiceName: factory_identity_type cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: system_assigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000160-modifier-post.yaml b/test/scenarios/datafactory/output/clicommon-000160-modifier-post.yaml index 9677a4d..9fc8118 100644 --- a/test/scenarios/datafactory/output/clicommon-000160-modifier-post.yaml +++ b/test/scenarios/datafactory/output/clicommon-000160-modifier-post.yaml @@ -1713,6 +1713,8 @@ schemas: description: The identity type. Currently the only supported type is 'SystemAssigned'. cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000170-namer-post-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000170-namer-post-simplified.yaml index 7eca9ef..89490b4 100644 --- a/test/scenarios/datafactory/output/clicommon-000170-namer-post-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000170-namer-post-simplified.yaml @@ -3020,6 +3020,8 @@ schemas: - choiceName: FactoryIdentityType cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: SystemAssigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000170-namer-post.yaml b/test/scenarios/datafactory/output/clicommon-000170-namer-post.yaml index f0e007b..2dc09b7 100644 --- a/test/scenarios/datafactory/output/clicommon-000170-namer-post.yaml +++ b/test/scenarios/datafactory/output/clicommon-000170-namer-post.yaml @@ -2264,6 +2264,8 @@ schemas: name: FactoryIdentityType description: The identity type. Currently the only supported type is 'SystemAssigned'. cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre-simplified.yaml index dd82db1..a34aee4 100644 --- a/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre-simplified.yaml @@ -3020,6 +3020,8 @@ schemas: - choiceName: FactoryIdentityType cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: SystemAssigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre.yaml b/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre.yaml index be0ec5a..899bdca 100644 --- a/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre.yaml +++ b/test/scenarios/datafactory/output/clicommon-000180-complex-marker-pre.yaml @@ -2264,6 +2264,8 @@ schemas: name: FactoryIdentityType description: The identity type. Currently the only supported type is 'SystemAssigned'. cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post-simplified.yaml b/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post-simplified.yaml index 05a0455..1bc3c80 100644 --- a/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post-simplified.yaml +++ b/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post-simplified.yaml @@ -3020,6 +3020,8 @@ schemas: - choiceName: FactoryIdentityType cli: cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true choiceValues: - choiceValue: SystemAssigned cli: diff --git a/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post.yaml b/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post.yaml index 160b773..bab2e33 100644 --- a/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post.yaml +++ b/test/scenarios/datafactory/output/clicommon-000190-complex-marker-post.yaml @@ -2264,6 +2264,8 @@ schemas: name: FactoryIdentityType description: The identity type. Currently the only supported type is 'SystemAssigned'. cliKey: FactoryIdentityType + default-value: SystemAssigned + hidden: true protocol: {} - &ref_180 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post.yaml b/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post.yaml index 7f88cdf..54cd5d5 100644 --- a/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post.yaml +++ b/test/scenarios/managed-network/output/clicommon-000100-modeler-post-processor-post.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre.yaml b/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre.yaml index fbf715d..497cd7d 100644 --- a/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre.yaml +++ b/test/scenarios/managed-network/output/clicommon-000110-poly-as-resource-pre.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post.yaml b/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post.yaml index ad64158..88927f1 100644 --- a/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post.yaml +++ b/test/scenarios/managed-network/output/clicommon-000120-poly-as-resource-post.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000130-flatten-pre-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000130-flatten-pre-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000130-flatten-pre-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000130-flatten-pre-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000130-flatten-pre.yaml b/test/scenarios/managed-network/output/clicommon-000130-flatten-pre.yaml index 79b1682..dd4e77a 100644 --- a/test/scenarios/managed-network/output/clicommon-000130-flatten-pre.yaml +++ b/test/scenarios/managed-network/output/clicommon-000130-flatten-pre.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000140-flatten-post-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000140-flatten-post-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000140-flatten-post-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000140-flatten-post-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000140-flatten-post.yaml b/test/scenarios/managed-network/output/clicommon-000140-flatten-post.yaml index 40fab7c..fff3172 100644 --- a/test/scenarios/managed-network/output/clicommon-000140-flatten-post.yaml +++ b/test/scenarios/managed-network/output/clicommon-000140-flatten-post.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000150-modifier-pre-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000150-modifier-pre-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000150-modifier-pre-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000150-modifier-pre-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000150-modifier-pre.yaml b/test/scenarios/managed-network/output/clicommon-000150-modifier-pre.yaml index 3a4a70d..9d03c1f 100644 --- a/test/scenarios/managed-network/output/clicommon-000150-modifier-pre.yaml +++ b/test/scenarios/managed-network/output/clicommon-000150-modifier-pre.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000160-modifier-post-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000160-modifier-post-simplified.yaml index 896ddbf..2f84a3e 100644 --- a/test/scenarios/managed-network/output/clicommon-000160-modifier-post-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000160-modifier-post-simplified.yaml @@ -851,6 +851,8 @@ schemas: - choiceName: kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000160-modifier-post.yaml b/test/scenarios/managed-network/output/clicommon-000160-modifier-post.yaml index 4e84900..e07e22a 100644 --- a/test/scenarios/managed-network/output/clicommon-000160-modifier-post.yaml +++ b/test/scenarios/managed-network/output/clicommon-000160-modifier-post.yaml @@ -263,6 +263,8 @@ schemas: description: Responsibility role under which this Managed Network Group will be created cli: cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000170-namer-post-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000170-namer-post-simplified.yaml index bcf2390..e317682 100644 --- a/test/scenarios/managed-network/output/clicommon-000170-namer-post-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000170-namer-post-simplified.yaml @@ -859,6 +859,8 @@ schemas: - choiceName: Kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: Connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000170-namer-post.yaml b/test/scenarios/managed-network/output/clicommon-000170-namer-post.yaml index 274c68c..23450a2 100644 --- a/test/scenarios/managed-network/output/clicommon-000170-namer-post.yaml +++ b/test/scenarios/managed-network/output/clicommon-000170-namer-post.yaml @@ -340,6 +340,8 @@ schemas: name: Kind description: Responsibility role under which this Managed Network Group will be created cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre-simplified.yaml index 3c14aec..744eb27 100644 --- a/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre-simplified.yaml @@ -859,6 +859,8 @@ schemas: - choiceName: Kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: Connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre.yaml b/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre.yaml index 590eec7..33b7dbe 100644 --- a/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre.yaml +++ b/test/scenarios/managed-network/output/clicommon-000180-complex-marker-pre.yaml @@ -340,6 +340,8 @@ schemas: name: Kind description: Responsibility role under which this Managed Network Group will be created cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: diff --git a/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post-simplified.yaml b/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post-simplified.yaml index e77e48f..5362cc3 100644 --- a/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post-simplified.yaml +++ b/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post-simplified.yaml @@ -859,6 +859,8 @@ schemas: - choiceName: Kind cli: cliKey: Kind + default-value: Connectivity + hidden: true choiceValues: - choiceValue: Connectivity cli: diff --git a/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post.yaml b/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post.yaml index 24e70ae..985e884 100644 --- a/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post.yaml +++ b/test/scenarios/managed-network/output/clicommon-000190-complex-marker-post.yaml @@ -340,6 +340,8 @@ schemas: name: Kind description: Responsibility role under which this Managed Network Group will be created cliKey: Kind + default-value: Connectivity + hidden: true protocol: {} - &ref_9 choices: