swagger-api/swagger-codegen

[OBJC] type object is not cast correctly

Open

#4 866 ouverte le 28 févr. 2017

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)HTML (5 474 forks)batch import
Client: ObjcIssue: Bughelp wanted

Métriques du dépôt

Stars
 (12 701 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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

Guide contributeur