Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][OBJC] Missing discriminator mapping in generated OBJC Models #6587

Closed
onlymate opened this issue Jun 8, 2020 · 1 comment · Fixed by #7471
Closed

[BUG][OBJC] Missing discriminator mapping in generated OBJC Models #6587

onlymate opened this issue Jun 8, 2020 · 1 comment · Fixed by #7471

Comments

@onlymate
Copy link
Contributor

onlymate commented Jun 8, 2020

Description

The "discriminator mapping" in OpenApi (see my OpenApi declaration in the gist below) seems to be ignored in generated Objective-C Client.
Having a look at the generated source code of the model class "A":

/**
 * Maps "discriminator" value to the sub-class name, so that inheritance is supported.
 */
- (id)initWithDictionary:(NSDictionary *)dict error:(NSError *__autoreleasing *)err {
    NSString * discriminatedClassName = [dict valueForKey:@"aTypeString"];
    if(discriminatedClassName == nil ){
         return [super initWithDictionary:dict error:err];
    }
    Class class = NSClassFromString([@"OAI" stringByAppendingString:discriminatedClassName]);
    if(!class) {
        class = NSClassFromString([@"OAI" stringByAppendingString:[discriminatedClassName capitalizedString]]);
    }
    if([self class ] == class) {
        return [super initWithDictionary:dict error:err];
    }
    return [[class alloc] initWithDictionary:dict error: err];
}

Seems like the class name is just appended and no mapping value is considered.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

https://gist.github.com/onlymate/fbdf06ba849ebdbf64361aaeb8072f22

Command line used for generation

openapi-generator generate -i spec.json -o . -g objc

Related issues/PRs

Is this similar too:
#417
?

@t-beckmann
Copy link
Contributor

Should be fixed by #7471, @onlymate please verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants