From 3565237912a2c1c1e87beb12b2cd0d5eae83344a Mon Sep 17 00:00:00 2001 From: Thomas Beckmann Date: Mon, 21 Sep 2020 15:18:02 +0200 Subject: [PATCH] update of Objective-C model-body.mustache to support discriminator.mappedModels --- .../src/main/resources/objc/model-body.mustache | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/objc/model-body.mustache b/modules/openapi-generator/src/main/resources/objc/model-body.mustache index 2d1150d080ed..398bba0e90c6 100644 --- a/modules/openapi-generator/src/main/resources/objc/model-body.mustache +++ b/modules/openapi-generator/src/main/resources/objc/model-body.mustache @@ -27,9 +27,19 @@ if(discriminatedClassName == nil ){ return [super initWithDictionary:dict error:err]; } - Class class = NSClassFromString([@"{{classPrefix}}" stringByAppendingString:discriminatedClassName]); - if(!class) { - class = NSClassFromString([@"{{classPrefix}}" stringByAppendingString:[discriminatedClassName capitalizedString]]); + + Class class = nil; +{{#discriminator.mappedModels}} + if ([discriminatedClassName isEqualToString:@"{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"]) { + class = NSClassFromString(@"{{modelName}}"); + } + else +{{/discriminator.mappedModels}} + { + class = NSClassFromString([@"{{classPrefix}}" stringByAppendingString:discriminatedClassName]); + if(!class) { + class = NSClassFromString([@"{{classPrefix}}" stringByAppendingString:[discriminatedClassName capitalizedString]]); + } } if([self class ] == class) { return [super initWithDictionary:dict error:err];