Skip to content

Commit 27faa21

Browse files
committed
Merge pull request swagger-api#2426 from Stuart-campbell/master
Updates to objc api to address issue swagger-api#2422
2 parents 1855e96 + 2bea297 commit 27faa21

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ static void (^reachabilityChangeBlock)(int);
5353
cacheEnabled = enabled;
5454
}
5555

56+
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status {
57+
reachabilityStatus = status;
58+
}
59+
5660
- (void)setHeaderValue:(NSString*) value
5761
forKey:(NSString*) forKey {
5862
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
@@ -238,6 +242,10 @@ static void (^reachabilityChangeBlock)(int);
238242
return reachabilityStatus;
239243
}
240244

245+
+(bool) getOfflineState {
246+
return offlineState;
247+
}
248+
241249
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock {
242250
reachabilityChangeBlock = changeBlock;
243251
}

modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
6464
*/
6565
+(void) setOfflineState:(BOOL) state;
6666

67+
/**
68+
* Gets if the client is unreachable
69+
*
70+
* @return The client offline state
71+
*/
72+
+(bool) getOfflineState;
73+
74+
/**
75+
* Sets the client reachability, this may be overridden by the reachability manager if reachability changes
76+
*
77+
* @param The client reachability.
78+
*/
79+
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
80+
6781
/**
6882
* Gets the client reachability
6983
*

samples/client/petstore/objc/SwaggerClient/SWGApiClient.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ extern NSString *const SWGResponseObjectErrorKey;
7373
*/
7474
+(void) setOfflineState:(BOOL) state;
7575

76+
/**
77+
* Gets if the client is unreachable
78+
*
79+
* @return The client offline state
80+
*/
81+
+(bool) getOfflineState;
82+
83+
/**
84+
* Sets the client reachability, this may be override by the reachability manager if reachability changes
85+
*
86+
* @param The client reachability.
87+
*/
88+
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
89+
7690
/**
7791
* Gets the client reachability
7892
*

samples/client/petstore/objc/SwaggerClient/SWGApiClient.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ + (void) setCacheEnabled:(BOOL)enabled {
5353
cacheEnabled = enabled;
5454
}
5555

56+
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status {
57+
reachabilityStatus = status;
58+
}
59+
5660
- (void)setHeaderValue:(NSString*) value
5761
forKey:(NSString*) forKey {
5862
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
@@ -238,6 +242,10 @@ +(AFNetworkReachabilityStatus) getReachabilityStatus {
238242
return reachabilityStatus;
239243
}
240244

245+
+(bool) getOfflineState {
246+
return offlineState;
247+
}
248+
241249
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock {
242250
reachabilityChangeBlock = changeBlock;
243251
}

samples/client/petstore/objc/SwaggerClient/SWGName.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717

1818
@property(nonatomic) NSNumber* name;
1919

20+
@property(nonatomic) NSNumber* snakeCase;
21+
2022
@end

samples/client/petstore/objc/SwaggerClient/SWGName.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ - (instancetype)init {
2020
*/
2121
+ (JSONKeyMapper *)keyMapper
2222
{
23-
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name" }];
23+
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name", @"snake_case": @"snakeCase" }];
2424
}
2525

2626
/**
@@ -30,7 +30,7 @@ + (JSONKeyMapper *)keyMapper
3030
*/
3131
+ (BOOL)propertyIsOptional:(NSString *)propertyName
3232
{
33-
NSArray *optionalProperties = @[@"name"];
33+
NSArray *optionalProperties = @[@"name", @"snakeCase"];
3434

3535
if ([optionalProperties containsObject:propertyName]) {
3636
return YES;

0 commit comments

Comments
 (0)