From bf1048168b2ee81a97b3ad36b204170717d7a0be Mon Sep 17 00:00:00 2001 From: dolauli Date: Fri, 2 Apr 2021 16:13:06 +0800 Subject: [PATCH] do not inline base model to support polymorphsim --- powershell/plugins/plugin-tweak-m4-model.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/powershell/plugins/plugin-tweak-m4-model.ts b/powershell/plugins/plugin-tweak-m4-model.ts index 858c6f5f0e..1797927e3a 100644 --- a/powershell/plugins/plugin-tweak-m4-model.ts +++ b/powershell/plugins/plugin-tweak-m4-model.ts @@ -26,6 +26,8 @@ async function tweakModel(state: State): Promise { handleNoinlineDirective(state); + handleDiscriminator(state); + return model; } @@ -40,6 +42,15 @@ function handleNoinlineDirective(state: State) { } } } + +function handleDiscriminator(state: State) { + for (const model of state.model.schemas.objects || []) { + if (model.discriminator) { + 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.