diff --git a/powershell/plugins/plugin-create-inline-properties.ts b/powershell/plugins/plugin-create-inline-properties.ts index f05e414f25..2d4227bd09 100644 --- a/powershell/plugins/plugin-create-inline-properties.ts +++ b/powershell/plugins/plugin-create-inline-properties.ts @@ -160,7 +160,7 @@ function createVirtualProperties(schema: ObjectSchema, stack: Array, thr // dolauli pay attention to the condition check const isDict = property.schema.type === SchemaType.Dictionary || (property.schema).parents?.immediate?.find((s) => s.type === SchemaType.Dictionary); const canInline = - // (!property.schema.details.default['skip-inline']) && + (!property.schema.language.default['skip-inline']) && (!property.schema.language.default.byReference) && (!isDict) && (property.schema).language.default.inline === 'yes'; diff --git a/powershell/plugins/plugin-tweak-m4-model.ts b/powershell/plugins/plugin-tweak-m4-model.ts index b9a7594206..3a50303699 100644 --- a/powershell/plugins/plugin-tweak-m4-model.ts +++ b/powershell/plugins/plugin-tweak-m4-model.ts @@ -7,11 +7,14 @@ import { serialize } from '@azure-tools/codegen'; import { PwshModel } from '../utils/PwshModel'; import { NewModelState } from '../utils/model-state'; import { StatusCodes } from '../utils/http-definitions'; +import { items, values, keys, Dictionary, length } from '@azure-tools/linq'; import { Host } from '@azure-tools/autorest-extension-base'; type State = NewModelState; +let directives: Array = []; + async function tweakModel(state: State): Promise { const model = state.model; @@ -21,9 +24,22 @@ async function tweakModel(state: State): Promise { removeM4DefaultDescription(model); + handleNoinlineDirective(state); + return model; } +function handleNoinlineDirective(state: State) { + var inlineModels: string[] = new Array; + for (const directive of directives.filter(each => each['no-inline'])) { + inlineModels = inlineModels.concat(>values(directive['no-inline']).toArray()); + } + for (const model of state.model.schemas.objects || []) { + if (inlineModels.includes(model.language.default.name)) { + model.language.default['skip-inline'] = true; + } + } +} function addResponseHeaderSchema(model: CodeModel) { // In remodeler, each operations response headers will has its own scheam. Each header will be schema's property. // But in m4, if 'schema' is not explicitly defined, even 'headers' is specified, there won't be a schema for headers. @@ -153,6 +169,8 @@ function recursiveRemoveM4DefaultDescription(schema: Schema, visited: Set(service).init(); service.WriteFile('code-model-v4-tweakm4codemodel.yaml', serialize(await tweakModel(state)), undefined, 'code-model-v4'); }