Skip to content

Commit 699df00

Browse files
committed
updated comments for objc client.
1 parent 86971ee commit 699df00

File tree

6 files changed

+176
-8
lines changed

6 files changed

+176
-8
lines changed

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

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,24 @@ extern NSString *const SWGResponseObjectErrorKey;
2222

2323
/**
2424
* Get the Api Client instance from pool
25+
*
26+
* @param baseUrl The base url of api client.
27+
*
28+
* @return The SWGApiClient instance.
2529
*/
2630
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
2731

2832
/**
2933
* Get the operations queue
34+
*
35+
* @return The `shardQueue` static variable.
3036
*/
3137
+(NSOperationQueue*) sharedQueue;
3238

3339
/**
3440
* Turn on logging
41+
*
42+
* @param state logging state, must be `YES` or `NO`
3543
*/
3644
+(void)setLoggingEnabled:(bool) state;
3745

@@ -42,72 +50,109 @@ extern NSString *const SWGResponseObjectErrorKey;
4250

4351
/**
4452
* Turn on cache
53+
*
54+
* @param enabled If the cached is enable, must be `YES` or `NO`
4555
*/
4656
+(void)setCacheEnabled:(BOOL) enabled;
4757

4858
/**
4959
* Get the request queue size
60+
*
61+
* @return The size of `queuedRequests` static variable.
5062
*/
5163
+(unsigned long)requestQueueSize;
5264

5365
/**
5466
* Set the client unreachable
67+
*
68+
* @param state off line state, must be `YES` or `NO`
5569
*/
5670
+(void) setOfflineState:(BOOL) state;
5771

5872
/**
5973
* Get the client reachability
74+
*
75+
* @return The client reachability.
6076
*/
6177
+(AFNetworkReachabilityStatus) getReachabilityStatus;
6278

6379
/**
6480
* Get the next request id
81+
*
82+
* @return The next executed request id.
6583
*/
6684
+(NSNumber*) nextRequestId;
6785

6886
/**
6987
* Generate request id and add it to the queue
88+
*
89+
* @return The next executed request id.
7090
*/
7191
+(NSNumber*) queueRequest;
7292

7393
/**
7494
* Remove request id from the queue
95+
*
96+
* @param requestId The request which will be removed.
7597
*/
7698
+(void) cancelRequest:(NSNumber*)requestId;
7799

78100
/**
79101
* URL encode NSString
102+
*
103+
* @param unescaped The string which will be escaped.
104+
*
105+
* @return The escaped string.
80106
*/
81107
+(NSString*) escape:(id)unescaped;
82108

83109
/**
84-
* Set the client reachability
110+
* Customize the behavior when the reachability changed
111+
*
112+
* @param changeBlock The block will be executed when the reachability changed.
85113
*/
86114
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
87115

88116
/**
89117
* Set the client reachability strategy
118+
*
119+
* @param host The host of SWGApiClient.
90120
*/
91121
+(void) configureCacheReachibilityForHost:(NSString*)host;
92122

93123
/**
94124
* Detect Accept header from accepts NSArray
125+
*
126+
* @param accepts NSArray of header
127+
*
128+
* @return The Accept header
95129
*/
96130
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
97131

98132
/**
99133
* Detect Content-Type header from contentTypes NSArray
134+
*
135+
* @param contentTypes NSArray of header
136+
*
137+
* @return The Content-Type header
100138
*/
101139
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
102140

103141
/**
104142
* Set header for request
143+
*
144+
* @param value The header value
145+
* @param forKey The header key
105146
*/
106147
-(void)setHeaderValue:(NSString*) value
107-
forKey:(NSString*) forKey;
148+
forKey:(NSString*) forKey;
108149

109150
/**
110151
* Update header parameters and query parameters for authentication
152+
*
153+
* @param headers The header parameter will be udpated, passed by pointer to pointer.
154+
* @param querys The query parameters will be updated, passed by pointer to pointer.
155+
* @param authSettings The authentication names NSArray.
111156
*/
112157
- (void) updateHeaderParams:(NSDictionary **)headers
113158
queryParams:(NSDictionary **)querys
@@ -116,7 +161,19 @@ extern NSString *const SWGResponseObjectErrorKey;
116161
/**
117162
* Perform request
118163
*
119-
* @discussion Request with non-empty response
164+
* Request with non-empty response
165+
*
166+
* @param path Request url.
167+
* @param method Request method.
168+
* @param queryParams Request query parameters.
169+
* @param body Request body.
170+
* @param headerParams Request header parameters.
171+
* @param authSettings Request authentication names.
172+
* @param requestContentType Request content-type.
173+
* @param responseContentType Response content-type.
174+
* @param completionBlock The block will be executed when the request completed.
175+
*
176+
* @return The request id.
120177
*/
121178
-(NSNumber*) dictionary:(NSString*) path
122179
method:(NSString*) method
@@ -131,7 +188,19 @@ extern NSString *const SWGResponseObjectErrorKey;
131188
/**
132189
* Perform request
133190
*
134-
* @discussion Request with empty response
191+
* Request with empty response
192+
*
193+
* @param path Request url.
194+
* @param method Request method.
195+
* @param queryParams Request query parameters.
196+
* @param body Request body.
197+
* @param headerParams Request header parameters.
198+
* @param authSettings Request authentication names.
199+
* @param requestContentType Request content-type.
200+
* @param responseContentType Response content-type.
201+
* @param completionBlock The block will be executed when the request completed.
202+
*
203+
* @return The request id.
135204
*/
136205
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
137206
method:(NSString*) method
@@ -143,3 +212,5 @@ extern NSString *const SWGResponseObjectErrorKey;
143212
responseContentType:(NSString*) responseContentType
144213
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
145214
@end
215+
216+

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
}
4848
}
4949

50+
- (NSString *) getBasicAuthToken {
51+
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password];
52+
NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
53+
basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];
54+
55+
return basicAuthCredentials;
56+
}
57+
5058
#pragma mark - Setter Methods
5159

5260
- (void) setValue:(NSString *)value forApiKeyField:(NSString *)field {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
*/
4444
- (NSString *) getApiKeyWithPrefix:(NSString *) key;
4545

46+
/**
47+
* Get Basic Auth token
48+
*/
49+
- (NSString *) getBasicAuthToken;
50+
4651
/**
4752
* Get Authentication Setings
4853
*/

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

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,24 @@ extern NSString *const SWGResponseObjectErrorKey;
2222

2323
/**
2424
* Get the Api Client instance from pool
25+
*
26+
* @param baseUrl The base url of api client.
27+
*
28+
* @return The SWGApiClient instance.
2529
*/
2630
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
2731

2832
/**
2933
* Get the operations queue
34+
*
35+
* @return The `shardQueue` static variable.
3036
*/
3137
+(NSOperationQueue*) sharedQueue;
3238

3339
/**
3440
* Turn on logging
41+
*
42+
* @param state logging state, must be `YES` or `NO`
3543
*/
3644
+(void)setLoggingEnabled:(bool) state;
3745

@@ -42,72 +50,109 @@ extern NSString *const SWGResponseObjectErrorKey;
4250

4351
/**
4452
* Turn on cache
53+
*
54+
* @param enabled If the cached is enable, must be `YES` or `NO`
4555
*/
4656
+(void)setCacheEnabled:(BOOL) enabled;
4757

4858
/**
4959
* Get the request queue size
60+
*
61+
* @return The size of `queuedRequests` static variable.
5062
*/
5163
+(unsigned long)requestQueueSize;
5264

5365
/**
5466
* Set the client unreachable
67+
*
68+
* @param state off line state, must be `YES` or `NO`
5569
*/
5670
+(void) setOfflineState:(BOOL) state;
5771

5872
/**
5973
* Get the client reachability
74+
*
75+
* @return The client reachability.
6076
*/
6177
+(AFNetworkReachabilityStatus) getReachabilityStatus;
6278

6379
/**
6480
* Get the next request id
81+
*
82+
* @return The next executed request id.
6583
*/
6684
+(NSNumber*) nextRequestId;
6785

6886
/**
6987
* Generate request id and add it to the queue
88+
*
89+
* @return The next executed request id.
7090
*/
7191
+(NSNumber*) queueRequest;
7292

7393
/**
7494
* Remove request id from the queue
95+
*
96+
* @param requestId The request which will be removed.
7597
*/
7698
+(void) cancelRequest:(NSNumber*)requestId;
7799

78100
/**
79101
* URL encode NSString
102+
*
103+
* @param unescaped The string which will be escaped.
104+
*
105+
* @return The escaped string.
80106
*/
81107
+(NSString*) escape:(id)unescaped;
82108

83109
/**
84-
* Set the client reachability
110+
* Customize the behavior when the reachability changed
111+
*
112+
* @param changeBlock The block will be executed when the reachability changed.
85113
*/
86114
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
87115

88116
/**
89117
* Set the client reachability strategy
118+
*
119+
* @param host The host of SWGApiClient.
90120
*/
91121
+(void) configureCacheReachibilityForHost:(NSString*)host;
92122

93123
/**
94124
* Detect Accept header from accepts NSArray
125+
*
126+
* @param accepts NSArray of header
127+
*
128+
* @return The Accept header
95129
*/
96130
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
97131

98132
/**
99133
* Detect Content-Type header from contentTypes NSArray
134+
*
135+
* @param contentTypes NSArray of header
136+
*
137+
* @return The Content-Type header
100138
*/
101139
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
102140

103141
/**
104142
* Set header for request
143+
*
144+
* @param value The header value
145+
* @param forKey The header key
105146
*/
106147
-(void)setHeaderValue:(NSString*) value
107-
forKey:(NSString*) forKey;
148+
forKey:(NSString*) forKey;
108149

109150
/**
110151
* Update header parameters and query parameters for authentication
152+
*
153+
* @param headers The header parameter will be udpated, passed by pointer to pointer.
154+
* @param querys The query parameters will be updated, passed by pointer to pointer.
155+
* @param authSettings The authentication names NSArray.
111156
*/
112157
- (void) updateHeaderParams:(NSDictionary **)headers
113158
queryParams:(NSDictionary **)querys
@@ -116,7 +161,19 @@ extern NSString *const SWGResponseObjectErrorKey;
116161
/**
117162
* Perform request
118163
*
119-
* @discussion Request with non-empty response
164+
* Request with non-empty response
165+
*
166+
* @param path Request url.
167+
* @param method Request method.
168+
* @param queryParams Request query parameters.
169+
* @param body Request body.
170+
* @param headerParams Request header parameters.
171+
* @param authSettings Request authentication names.
172+
* @param requestContentType Request content-type.
173+
* @param responseContentType Response content-type.
174+
* @param completionBlock The block will be executed when the request completed.
175+
*
176+
* @return The request id.
120177
*/
121178
-(NSNumber*) dictionary:(NSString*) path
122179
method:(NSString*) method
@@ -131,7 +188,19 @@ extern NSString *const SWGResponseObjectErrorKey;
131188
/**
132189
* Perform request
133190
*
134-
* @discussion Request with empty response
191+
* Request with empty response
192+
*
193+
* @param path Request url.
194+
* @param method Request method.
195+
* @param queryParams Request query parameters.
196+
* @param body Request body.
197+
* @param headerParams Request header parameters.
198+
* @param authSettings Request authentication names.
199+
* @param requestContentType Request content-type.
200+
* @param responseContentType Response content-type.
201+
* @param completionBlock The block will be executed when the request completed.
202+
*
203+
* @return The request id.
135204
*/
136205
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
137206
method:(NSString*) method
@@ -143,3 +212,5 @@ extern NSString *const SWGResponseObjectErrorKey;
143212
responseContentType:(NSString*) responseContentType
144213
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
145214
@end
215+
216+

0 commit comments

Comments
 (0)