From 86971ee752842bee8dba1bd5965e92168c690783 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Tue, 2 Jun 2015 11:50:47 +0800 Subject: [PATCH] added comments for objc client --- .../src/main/resources/objc/SWGApiClient.h | 77 ++++++++++++++++--- .../petstore/objc/client/SWGApiClient.h | 77 ++++++++++++++++--- .../petstore/objc/client/SWGConfiguration.m | 7 -- .../client/petstore/objc/client/SWGPetApi.m | 2 +- 4 files changed, 133 insertions(+), 30 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h index d1f9203f180..fa48aa70965 100644 --- a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h +++ b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h @@ -3,7 +3,7 @@ /** * A key for `NSError` user info dictionaries. - * + * * The corresponding value is the parsed response body for an HTTP error. */ extern NSString *const SWGResponseObjectErrorKey; @@ -20,44 +20,104 @@ extern NSString *const SWGResponseObjectErrorKey; @property(nonatomic, assign) BOOL logHTTP; @property(nonatomic, readonly) NSOperationQueue* queue; +/** + * Get the Api Client instance from pool + */ +(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl; +/** + * Get the operations queue + */ +(NSOperationQueue*) sharedQueue; +/** + * Turn on logging + */ +(void)setLoggingEnabled:(bool) state; +/** + * Clear Cache + */ +(void)clearCache; +/** + * Turn on cache + */ +(void)setCacheEnabled:(BOOL) enabled; +/** + * Get the request queue size + */ +(unsigned long)requestQueueSize; +/** + * Set the client unreachable + */ +(void) setOfflineState:(BOOL) state; +/** + * Get the client reachability + */ +(AFNetworkReachabilityStatus) getReachabilityStatus; +/** + * Get the next request id + */ +(NSNumber*) nextRequestId; +/** + * Generate request id and add it to the queue + */ +(NSNumber*) queueRequest; +/** + * Remove request id from the queue + */ +(void) cancelRequest:(NSNumber*)requestId; +/** + * URL encode NSString + */ +(NSString*) escape:(id)unescaped; +/** + * Set the client reachability + */ +(void) setReachabilityChangeBlock:(void(^)(int))changeBlock; +/** + * Set the client reachability strategy + */ +(void) configureCacheReachibilityForHost:(NSString*)host; +/** + * Detect Accept header from accepts NSArray + */ +(NSString *) selectHeaderAccept:(NSArray *)accepts; + +/** + * Detect Content-Type header from contentTypes NSArray + */ +(NSString *) selectHeaderContentType:(NSArray *)contentTypes; +/** + * Set header for request + */ -(void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey; +/** + * Update header parameters and query parameters for authentication + */ - (void) updateHeaderParams:(NSDictionary **)headers queryParams:(NSDictionary **)querys WithAuthSettings:(NSArray *)authSettings; +/** + * Perform request + * + * @discussion Request with non-empty response + */ -(NSNumber*) dictionary:(NSString*) path method:(NSString*) method queryParams:(NSDictionary*) queryParams @@ -68,6 +128,11 @@ extern NSString *const SWGResponseObjectErrorKey; responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock; +/** + * Perform request + * + * @discussion Request with empty response + */ -(NSNumber*) stringWithCompletionBlock:(NSString*) path method:(NSString*) method queryParams:(NSDictionary*) queryParams @@ -78,13 +143,3 @@ extern NSString *const SWGResponseObjectErrorKey; responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSString*, NSError *))completionBlock; @end - - - - - - - - - - diff --git a/samples/client/petstore/objc/client/SWGApiClient.h b/samples/client/petstore/objc/client/SWGApiClient.h index d1f9203f180..fa48aa70965 100644 --- a/samples/client/petstore/objc/client/SWGApiClient.h +++ b/samples/client/petstore/objc/client/SWGApiClient.h @@ -3,7 +3,7 @@ /** * A key for `NSError` user info dictionaries. - * + * * The corresponding value is the parsed response body for an HTTP error. */ extern NSString *const SWGResponseObjectErrorKey; @@ -20,44 +20,104 @@ extern NSString *const SWGResponseObjectErrorKey; @property(nonatomic, assign) BOOL logHTTP; @property(nonatomic, readonly) NSOperationQueue* queue; +/** + * Get the Api Client instance from pool + */ +(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl; +/** + * Get the operations queue + */ +(NSOperationQueue*) sharedQueue; +/** + * Turn on logging + */ +(void)setLoggingEnabled:(bool) state; +/** + * Clear Cache + */ +(void)clearCache; +/** + * Turn on cache + */ +(void)setCacheEnabled:(BOOL) enabled; +/** + * Get the request queue size + */ +(unsigned long)requestQueueSize; +/** + * Set the client unreachable + */ +(void) setOfflineState:(BOOL) state; +/** + * Get the client reachability + */ +(AFNetworkReachabilityStatus) getReachabilityStatus; +/** + * Get the next request id + */ +(NSNumber*) nextRequestId; +/** + * Generate request id and add it to the queue + */ +(NSNumber*) queueRequest; +/** + * Remove request id from the queue + */ +(void) cancelRequest:(NSNumber*)requestId; +/** + * URL encode NSString + */ +(NSString*) escape:(id)unescaped; +/** + * Set the client reachability + */ +(void) setReachabilityChangeBlock:(void(^)(int))changeBlock; +/** + * Set the client reachability strategy + */ +(void) configureCacheReachibilityForHost:(NSString*)host; +/** + * Detect Accept header from accepts NSArray + */ +(NSString *) selectHeaderAccept:(NSArray *)accepts; + +/** + * Detect Content-Type header from contentTypes NSArray + */ +(NSString *) selectHeaderContentType:(NSArray *)contentTypes; +/** + * Set header for request + */ -(void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey; +/** + * Update header parameters and query parameters for authentication + */ - (void) updateHeaderParams:(NSDictionary **)headers queryParams:(NSDictionary **)querys WithAuthSettings:(NSArray *)authSettings; +/** + * Perform request + * + * @discussion Request with non-empty response + */ -(NSNumber*) dictionary:(NSString*) path method:(NSString*) method queryParams:(NSDictionary*) queryParams @@ -68,6 +128,11 @@ extern NSString *const SWGResponseObjectErrorKey; responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock; +/** + * Perform request + * + * @discussion Request with empty response + */ -(NSNumber*) stringWithCompletionBlock:(NSString*) path method:(NSString*) method queryParams:(NSDictionary*) queryParams @@ -78,13 +143,3 @@ extern NSString *const SWGResponseObjectErrorKey; responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSString*, NSError *))completionBlock; @end - - - - - - - - - - diff --git a/samples/client/petstore/objc/client/SWGConfiguration.m b/samples/client/petstore/objc/client/SWGConfiguration.m index f98c5f081de..0c477edbfc5 100644 --- a/samples/client/petstore/objc/client/SWGConfiguration.m +++ b/samples/client/petstore/objc/client/SWGConfiguration.m @@ -78,13 +78,6 @@ @"value": [self getApiKeyWithPrefix:@"api_key"] }, - @"basic_auth": @{ - @"type": @"basic", - @"in": @"header", - @"key": @"Authorization", - @"value": [self getBasicAuthToken] - }, - }; } diff --git a/samples/client/petstore/objc/client/SWGPetApi.m b/samples/client/petstore/objc/client/SWGPetApi.m index 0b2c059fb3b..c14da125af5 100644 --- a/samples/client/petstore/objc/client/SWGPetApi.m +++ b/samples/client/petstore/objc/client/SWGPetApi.m @@ -225,7 +225,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[@"basic_auth"]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyDictionary = nil;