swagger-api/swagger-codegen

[OBJC] type object is not cast correctly

Open

#4,866 建立於 2017年2月28日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)HTML (5,474 fork)batch import
Client: ObjcIssue: Bughelp wanted

倉庫指標

Star
 (12,701 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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

貢獻者指南