swagger-api / swagger-api/swagger-codegen

[OBJC] type object is not cast correctly

Open
#4,866 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Objc help wanted Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generation command with the supplied swagger.json URL using the objc generator and inspect the generated client under samples/client/CLIENT. Start from the generated model handling the Swagger type "object" and the JSONModel crash after the request. Done means object values are represented correctly and the generated client no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.