swagger-api/swagger-codegen

[OBJC] type object is not cast correctly

Open

#4,866 opened on Feb 28, 2017

View on GitHub
 (2 comments) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Client: ObjcIssue: Bughelp wanted

Description

Description

Type "object" in swagger.json is cast as NSObject which produces a bug

Swagger-codegen version

2.2.2-SNAPSHOT

Swagger declaration file content or url
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate 
-i http://127.0.0.1:9000/swagger.json 
-l objc 
-o samples/client/CLIENT 
-c config.json
Steps to reproduce

JSONModel crash after HTTP request is sent

Related issues
Suggest a Fix

Restlet studio manages this type correctly with the Class ASKFields:

ASKFields.h

#import "ASKRepresentation.h"
@interface ASKFields : ASKRepresentation
+ (instancetype)representation;
@end

ASKFields.m

#import "ASKFields.h"
@implementation ASKFields
+ (instancetype)representation {
    return [[self alloc] init];
}

- (NSString *)description {
    NSMutableString *result = [NSMutableString string];
    return result;
}

#pragma mark - Dictionary Representation
- (NSDictionary *)toDictionary {
    return @{
            };
}
+ (instancetype)fromDictionary:(NSDictionary *)aDictionary {
    if (aDictionary == nil) {
        return nil;
    }
    ASKFields *result = [self representation];
    return result;
}
@end

Contributor guide