forked from loafle/openapi-generator-original
added comments for objc client
This commit is contained in:
parent
b5429d9e8e
commit
86971ee752
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A key for `NSError` user info dictionaries.
|
* A key for `NSError` user info dictionaries.
|
||||||
*
|
*
|
||||||
* The corresponding value is the parsed response body for an HTTP error.
|
* The corresponding value is the parsed response body for an HTTP error.
|
||||||
*/
|
*/
|
||||||
extern NSString *const SWGResponseObjectErrorKey;
|
extern NSString *const SWGResponseObjectErrorKey;
|
||||||
@ -20,44 +20,104 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
@property(nonatomic, assign) BOOL logHTTP;
|
@property(nonatomic, assign) BOOL logHTTP;
|
||||||
@property(nonatomic, readonly) NSOperationQueue* queue;
|
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Api Client instance from pool
|
||||||
|
*/
|
||||||
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
|
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the operations queue
|
||||||
|
*/
|
||||||
+(NSOperationQueue*) sharedQueue;
|
+(NSOperationQueue*) sharedQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on logging
|
||||||
|
*/
|
||||||
+(void)setLoggingEnabled:(bool) state;
|
+(void)setLoggingEnabled:(bool) state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear Cache
|
||||||
|
*/
|
||||||
+(void)clearCache;
|
+(void)clearCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on cache
|
||||||
|
*/
|
||||||
+(void)setCacheEnabled:(BOOL) enabled;
|
+(void)setCacheEnabled:(BOOL) enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the request queue size
|
||||||
|
*/
|
||||||
+(unsigned long)requestQueueSize;
|
+(unsigned long)requestQueueSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the client unreachable
|
||||||
|
*/
|
||||||
+(void) setOfflineState:(BOOL) state;
|
+(void) setOfflineState:(BOOL) state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the client reachability
|
||||||
|
*/
|
||||||
+(AFNetworkReachabilityStatus) getReachabilityStatus;
|
+(AFNetworkReachabilityStatus) getReachabilityStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next request id
|
||||||
|
*/
|
||||||
+(NSNumber*) nextRequestId;
|
+(NSNumber*) nextRequestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate request id and add it to the queue
|
||||||
|
*/
|
||||||
+(NSNumber*) queueRequest;
|
+(NSNumber*) queueRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove request id from the queue
|
||||||
|
*/
|
||||||
+(void) cancelRequest:(NSNumber*)requestId;
|
+(void) cancelRequest:(NSNumber*)requestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL encode NSString
|
||||||
|
*/
|
||||||
+(NSString*) escape:(id)unescaped;
|
+(NSString*) escape:(id)unescaped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the client reachability
|
||||||
|
*/
|
||||||
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
|
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the client reachability strategy
|
||||||
|
*/
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Accept header from accepts NSArray
|
||||||
|
*/
|
||||||
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Content-Type header from contentTypes NSArray
|
||||||
|
*/
|
||||||
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set header for request
|
||||||
|
*/
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey;
|
forKey:(NSString*) forKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update header parameters and query parameters for authentication
|
||||||
|
*/
|
||||||
- (void) updateHeaderParams:(NSDictionary **)headers
|
- (void) updateHeaderParams:(NSDictionary **)headers
|
||||||
queryParams:(NSDictionary **)querys
|
queryParams:(NSDictionary **)querys
|
||||||
WithAuthSettings:(NSArray *)authSettings;
|
WithAuthSettings:(NSArray *)authSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform request
|
||||||
|
*
|
||||||
|
* @discussion Request with non-empty response
|
||||||
|
*/
|
||||||
-(NSNumber*) dictionary:(NSString*) path
|
-(NSNumber*) dictionary:(NSString*) path
|
||||||
method:(NSString*) method
|
method:(NSString*) method
|
||||||
queryParams:(NSDictionary*) queryParams
|
queryParams:(NSDictionary*) queryParams
|
||||||
@ -68,6 +128,11 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
responseContentType:(NSString*) responseContentType
|
responseContentType:(NSString*) responseContentType
|
||||||
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock;
|
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform request
|
||||||
|
*
|
||||||
|
* @discussion Request with empty response
|
||||||
|
*/
|
||||||
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
|
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
|
||||||
method:(NSString*) method
|
method:(NSString*) method
|
||||||
queryParams:(NSDictionary*) queryParams
|
queryParams:(NSDictionary*) queryParams
|
||||||
@ -78,13 +143,3 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
responseContentType:(NSString*) responseContentType
|
responseContentType:(NSString*) responseContentType
|
||||||
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
|
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A key for `NSError` user info dictionaries.
|
* A key for `NSError` user info dictionaries.
|
||||||
*
|
*
|
||||||
* The corresponding value is the parsed response body for an HTTP error.
|
* The corresponding value is the parsed response body for an HTTP error.
|
||||||
*/
|
*/
|
||||||
extern NSString *const SWGResponseObjectErrorKey;
|
extern NSString *const SWGResponseObjectErrorKey;
|
||||||
@ -20,44 +20,104 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
@property(nonatomic, assign) BOOL logHTTP;
|
@property(nonatomic, assign) BOOL logHTTP;
|
||||||
@property(nonatomic, readonly) NSOperationQueue* queue;
|
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Api Client instance from pool
|
||||||
|
*/
|
||||||
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
|
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the operations queue
|
||||||
|
*/
|
||||||
+(NSOperationQueue*) sharedQueue;
|
+(NSOperationQueue*) sharedQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on logging
|
||||||
|
*/
|
||||||
+(void)setLoggingEnabled:(bool) state;
|
+(void)setLoggingEnabled:(bool) state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear Cache
|
||||||
|
*/
|
||||||
+(void)clearCache;
|
+(void)clearCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on cache
|
||||||
|
*/
|
||||||
+(void)setCacheEnabled:(BOOL) enabled;
|
+(void)setCacheEnabled:(BOOL) enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the request queue size
|
||||||
|
*/
|
||||||
+(unsigned long)requestQueueSize;
|
+(unsigned long)requestQueueSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the client unreachable
|
||||||
|
*/
|
||||||
+(void) setOfflineState:(BOOL) state;
|
+(void) setOfflineState:(BOOL) state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the client reachability
|
||||||
|
*/
|
||||||
+(AFNetworkReachabilityStatus) getReachabilityStatus;
|
+(AFNetworkReachabilityStatus) getReachabilityStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next request id
|
||||||
|
*/
|
||||||
+(NSNumber*) nextRequestId;
|
+(NSNumber*) nextRequestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate request id and add it to the queue
|
||||||
|
*/
|
||||||
+(NSNumber*) queueRequest;
|
+(NSNumber*) queueRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove request id from the queue
|
||||||
|
*/
|
||||||
+(void) cancelRequest:(NSNumber*)requestId;
|
+(void) cancelRequest:(NSNumber*)requestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL encode NSString
|
||||||
|
*/
|
||||||
+(NSString*) escape:(id)unescaped;
|
+(NSString*) escape:(id)unescaped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the client reachability
|
||||||
|
*/
|
||||||
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
|
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the client reachability strategy
|
||||||
|
*/
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Accept header from accepts NSArray
|
||||||
|
*/
|
||||||
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Content-Type header from contentTypes NSArray
|
||||||
|
*/
|
||||||
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set header for request
|
||||||
|
*/
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey;
|
forKey:(NSString*) forKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update header parameters and query parameters for authentication
|
||||||
|
*/
|
||||||
- (void) updateHeaderParams:(NSDictionary **)headers
|
- (void) updateHeaderParams:(NSDictionary **)headers
|
||||||
queryParams:(NSDictionary **)querys
|
queryParams:(NSDictionary **)querys
|
||||||
WithAuthSettings:(NSArray *)authSettings;
|
WithAuthSettings:(NSArray *)authSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform request
|
||||||
|
*
|
||||||
|
* @discussion Request with non-empty response
|
||||||
|
*/
|
||||||
-(NSNumber*) dictionary:(NSString*) path
|
-(NSNumber*) dictionary:(NSString*) path
|
||||||
method:(NSString*) method
|
method:(NSString*) method
|
||||||
queryParams:(NSDictionary*) queryParams
|
queryParams:(NSDictionary*) queryParams
|
||||||
@ -68,6 +128,11 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
responseContentType:(NSString*) responseContentType
|
responseContentType:(NSString*) responseContentType
|
||||||
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock;
|
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform request
|
||||||
|
*
|
||||||
|
* @discussion Request with empty response
|
||||||
|
*/
|
||||||
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
|
-(NSNumber*) stringWithCompletionBlock:(NSString*) path
|
||||||
method:(NSString*) method
|
method:(NSString*) method
|
||||||
queryParams:(NSDictionary*) queryParams
|
queryParams:(NSDictionary*) queryParams
|
||||||
@ -78,13 +143,3 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
responseContentType:(NSString*) responseContentType
|
responseContentType:(NSString*) responseContentType
|
||||||
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
|
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,13 +78,6 @@
|
|||||||
@"value": [self getApiKeyWithPrefix:@"api_key"]
|
@"value": [self getApiKeyWithPrefix:@"api_key"]
|
||||||
},
|
},
|
||||||
|
|
||||||
@"basic_auth": @{
|
|
||||||
@"type": @"basic",
|
|
||||||
@"in": @"header",
|
|
||||||
@"key": @"Authorization",
|
|
||||||
@"value": [self getBasicAuthToken]
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
|
||||||
|
|
||||||
// Authentication setting
|
// Authentication setting
|
||||||
NSArray *authSettings = @[@"basic_auth"];
|
NSArray *authSettings = @[@"petstore_auth"];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user