Skip to content

Commit 86971ee

Browse files
committed
added comments for objc client
1 parent b5429d9 commit 86971ee

File tree

4 files changed

+133
-30
lines changed

4 files changed

+133
-30
lines changed

modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/**
55
* A key for `NSError` user info dictionaries.
6-
*
6+
*
77
* The corresponding value is the parsed response body for an HTTP error.
88
*/
99
extern NSString *const SWGResponseObjectErrorKey;
@@ -20,44 +20,104 @@ extern NSString *const SWGResponseObjectErrorKey;
2020
@property(nonatomic, assign) BOOL logHTTP;
2121
@property(nonatomic, readonly) NSOperationQueue* queue;
2222

23+
/**
24+
* Get the Api Client instance from pool
25+
*/
2326
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
2427

28+
/**
29+
* Get the operations queue
30+
*/
2531
+(NSOperationQueue*) sharedQueue;
2632

33+
/**
34+
* Turn on logging
35+
*/
2736
+(void)setLoggingEnabled:(bool) state;
2837

38+
/**
39+
* Clear Cache
40+
*/
2941
+(void)clearCache;
3042

43+
/**
44+
* Turn on cache
45+
*/
3146
+(void)setCacheEnabled:(BOOL) enabled;
3247

48+
/**
49+
* Get the request queue size
50+
*/
3351
+(unsigned long)requestQueueSize;
3452

53+
/**
54+
* Set the client unreachable
55+
*/
3556
+(void) setOfflineState:(BOOL) state;
3657

58+
/**
59+
* Get the client reachability
60+
*/
3761
+(AFNetworkReachabilityStatus) getReachabilityStatus;
3862

63+
/**
64+
* Get the next request id
65+
*/
3966
+(NSNumber*) nextRequestId;
4067

68+
/**
69+
* Generate request id and add it to the queue
70+
*/
4171
+(NSNumber*) queueRequest;
4272

73+
/**
74+
* Remove request id from the queue
75+
*/
4376
+(void) cancelRequest:(NSNumber*)requestId;
4477

78+
/**
79+
* URL encode NSString
80+
*/
4581
+(NSString*) escape:(id)unescaped;
4682

83+
/**
84+
* Set the client reachability
85+
*/
4786
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
4887

88+
/**
89+
* Set the client reachability strategy
90+
*/
4991
+(void) configureCacheReachibilityForHost:(NSString*)host;
5092

93+
/**
94+
* Detect Accept header from accepts NSArray
95+
*/
5196
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
97+
98+
/**
99+
* Detect Content-Type header from contentTypes NSArray
100+
*/
52101
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
53102

103+
/**
104+
* Set header for request
105+
*/
54106
-(void)setHeaderValue:(NSString*) value
55107
forKey:(NSString*) forKey;
56108

109+
/**
110+
* Update header parameters and query parameters for authentication
111+
*/
57112
- (void) updateHeaderParams:(NSDictionary **)headers
58113
queryParams:(NSDictionary **)querys
59114
WithAuthSettings:(NSArray *)authSettings;
60115

116+
/**
117+
* Perform request
118+
*
119+
* @discussion Request with non-empty response
120+
*/
61121
-(NSNumber*) dictionary:(NSString*) path
62122
method:(NSString*) method
63123
queryParams:(NSDictionary*) queryParams
@@ -68,6 +128,11 @@ extern NSString *const SWGResponseObjectErrorKey;
68128
responseContentType:(NSString*) responseContentType
69129
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock;
70130

131+
/**
132+
* Perform request
133+
*
134+
* @discussion Request with empty response
135+
*/
71136
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
72137
method:(NSString*) method
73138
queryParams:(NSDictionary*) queryParams
@@ -78,13 +143,3 @@ extern NSString *const SWGResponseObjectErrorKey;
78143
responseContentType:(NSString*) responseContentType
79144
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
80145
@end
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-

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

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/**
55
* A key for `NSError` user info dictionaries.
6-
*
6+
*
77
* The corresponding value is the parsed response body for an HTTP error.
88
*/
99
extern NSString *const SWGResponseObjectErrorKey;
@@ -20,44 +20,104 @@ extern NSString *const SWGResponseObjectErrorKey;
2020
@property(nonatomic, assign) BOOL logHTTP;
2121
@property(nonatomic, readonly) NSOperationQueue* queue;
2222

23+
/**
24+
* Get the Api Client instance from pool
25+
*/
2326
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
2427

28+
/**
29+
* Get the operations queue
30+
*/
2531
+(NSOperationQueue*) sharedQueue;
2632

33+
/**
34+
* Turn on logging
35+
*/
2736
+(void)setLoggingEnabled:(bool) state;
2837

38+
/**
39+
* Clear Cache
40+
*/
2941
+(void)clearCache;
3042

43+
/**
44+
* Turn on cache
45+
*/
3146
+(void)setCacheEnabled:(BOOL) enabled;
3247

48+
/**
49+
* Get the request queue size
50+
*/
3351
+(unsigned long)requestQueueSize;
3452

53+
/**
54+
* Set the client unreachable
55+
*/
3556
+(void) setOfflineState:(BOOL) state;
3657

58+
/**
59+
* Get the client reachability
60+
*/
3761
+(AFNetworkReachabilityStatus) getReachabilityStatus;
3862

63+
/**
64+
* Get the next request id
65+
*/
3966
+(NSNumber*) nextRequestId;
4067

68+
/**
69+
* Generate request id and add it to the queue
70+
*/
4171
+(NSNumber*) queueRequest;
4272

73+
/**
74+
* Remove request id from the queue
75+
*/
4376
+(void) cancelRequest:(NSNumber*)requestId;
4477

78+
/**
79+
* URL encode NSString
80+
*/
4581
+(NSString*) escape:(id)unescaped;
4682

83+
/**
84+
* Set the client reachability
85+
*/
4786
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
4887

88+
/**
89+
* Set the client reachability strategy
90+
*/
4991
+(void) configureCacheReachibilityForHost:(NSString*)host;
5092

93+
/**
94+
* Detect Accept header from accepts NSArray
95+
*/
5196
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
97+
98+
/**
99+
* Detect Content-Type header from contentTypes NSArray
100+
*/
52101
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
53102

103+
/**
104+
* Set header for request
105+
*/
54106
-(void)setHeaderValue:(NSString*) value
55107
forKey:(NSString*) forKey;
56108

109+
/**
110+
* Update header parameters and query parameters for authentication
111+
*/
57112
- (void) updateHeaderParams:(NSDictionary **)headers
58113
queryParams:(NSDictionary **)querys
59114
WithAuthSettings:(NSArray *)authSettings;
60115

116+
/**
117+
* Perform request
118+
*
119+
* @discussion Request with non-empty response
120+
*/
61121
-(NSNumber*) dictionary:(NSString*) path
62122
method:(NSString*) method
63123
queryParams:(NSDictionary*) queryParams
@@ -68,6 +128,11 @@ extern NSString *const SWGResponseObjectErrorKey;
68128
responseContentType:(NSString*) responseContentType
69129
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock;
70130

131+
/**
132+
* Perform request
133+
*
134+
* @discussion Request with empty response
135+
*/
71136
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
72137
method:(NSString*) method
73138
queryParams:(NSDictionary*) queryParams
@@ -78,13 +143,3 @@ extern NSString *const SWGResponseObjectErrorKey;
78143
responseContentType:(NSString*) responseContentType
79144
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
80145
@end
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-

samples/client/petstore/objc/client/SWGConfiguration.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ - (NSDictionary *) authSettings {
7878
@"value": [self getApiKeyWithPrefix:@"api_key"]
7979
},
8080

81-
@"basic_auth": @{
82-
@"type": @"basic",
83-
@"in": @"header",
84-
@"key": @"Authorization",
85-
@"value": [self getBasicAuthToken]
86-
},
87-
8881
};
8982
}
9083

samples/client/petstore/objc/client/SWGPetApi.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ -(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
225225
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
226226

227227
// Authentication setting
228-
NSArray *authSettings = @[@"basic_auth"];
228+
NSArray *authSettings = @[@"petstore_auth"];
229229

230230
id bodyDictionary = nil;
231231

0 commit comments

Comments
 (0)