replaced SWG by classPrefix and ran tests (#4871)

This commit is contained in:
patulacci 2017-03-03 10:29:16 +01:00 committed by wing328
parent 39a42d014b
commit e23a24c138
38 changed files with 432 additions and 918 deletions

View File

@ -75,8 +75,8 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
_downloadTaskResponseTypes = @[@"NSURL*", @"NSURL"]; _downloadTaskResponseTypes = @[@"NSURL*", @"NSURL"];
AFHTTPRequestSerializer* afhttpRequestSerializer = [AFHTTPRequestSerializer serializer]; AFHTTPRequestSerializer* afhttpRequestSerializer = [AFHTTPRequestSerializer serializer];
SWGJSONRequestSerializer * swgjsonRequestSerializer = [SWGJSONRequestSerializer serializer]; {{classPrefix}}JSONRequestSerializer * swgjsonRequestSerializer = [{{classPrefix}}JSONRequestSerializer serializer];
_requestSerializerForContentType = @{kSWGApplicationJSONType : swgjsonRequestSerializer, _requestSerializerForContentType = @{k{{classPrefix}}ApplicationJSONType : swgjsonRequestSerializer,
@"application/x-www-form-urlencoded": afhttpRequestSerializer, @"application/x-www-form-urlencoded": afhttpRequestSerializer,
@"multipart/form-data": afhttpRequestSerializer @"multipart/form-data": afhttpRequestSerializer
}; };
@ -89,7 +89,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
#pragma mark - Task Methods #pragma mark - Task Methods
- (NSURLSessionDataTask*) taskWithCompletionBlock: (NSURLRequest *)request completionBlock: (void (^)(id, NSError *))completionBlock { - (NSURLSessionDataTask*) taskWithCompletionBlock: (NSURLRequest *)request completionBlock: (void (^)(id, NSError *))completionBlock {
NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
{{classPrefix}}DebugLogResponse(response, responseObject,request,error); {{classPrefix}}DebugLogResponse(response, responseObject,request,error);
if(!error) { if(!error) {
@ -104,7 +104,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
completionBlock(nil, augmentedError); completionBlock(nil, augmentedError);
}]; }];
return task; return task;
} }
@ -135,7 +135,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
completionBlock(file, nil); completionBlock(file, nil);
}]; }];
return task; return task;
} }
@ -157,7 +157,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer = [self requestSerializerForRequestContentType:requestContentType]; AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer = [self requestSerializerForRequestContentType:requestContentType];
__weak id<SWGSanitizer> sanitizer = self.sanitizer; __weak id<{{classPrefix}}Sanitizer> sanitizer = self.sanitizer;
// sanitize parameters // sanitize parameters
pathParams = [sanitizer sanitizeForSerialization:pathParams]; pathParams = [sanitizer sanitizeForSerialization:pathParams];
@ -222,7 +222,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
[self postProcessRequest:request]; [self postProcessRequest:request];
NSURLSessionTask *task = nil; NSURLSessionTask *task = nil;
if ([self.downloadTaskResponseTypes containsObject:responseType]) { if ([self.downloadTaskResponseTypes containsObject:responseType]) {
@ -241,9 +241,9 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
completionBlock(response, error); completionBlock(response, error);
}]; }];
} }
[task resume]; [task resume];
return task; return task;
} }
@ -330,7 +330,7 @@ static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response)
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
id<{{classPrefix}}Configuration> config = self.configuration; id<{{classPrefix}}Configuration> config = self.configuration;
for (NSString *auth in authSettings) { for (NSString *auth in authSettings) {
NSDictionary *authSetting = config.authSettings[auth]; NSDictionary *authSetting = config.authSettings[auth];

View File

@ -54,7 +54,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
* @param url The base url * @param url The base url
* @param configuration The configuration implementation * @param configuration The configuration implementation
*/ */
- (instancetype)initWithBaseURL:(NSURL *)url configuration:(id<SWGConfiguration>)configuration; - (instancetype)initWithBaseURL:(NSURL *)url configuration:(id<{{classPrefix}}Configuration>)configuration;
/** /**
* Performs request * Performs request

View File

@ -1,13 +1,12 @@
# SwaggerClient # SwaggerClient
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r - API version: 1.0.0 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
- Package version: - Package version:
- Build date: 2016-07-12T17:06:42.405+08:00 - Build package: io.swagger.codegen.languages.ObjcClientCodegen
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen
## Requirements ## Requirements
@ -40,7 +39,7 @@ Import the following:
```objc ```objc
#import <SwaggerClient/SWGApiClient.h> #import <SwaggerClient/SWGApiClient.h>
#import <SwaggerClient/SWGConfiguration.h> #import <SwaggerClient/SWGDefaultConfiguration.h>
// load models // load models
#import <SwaggerClient/SWGReturn.h> #import <SwaggerClient/SWGReturn.h>
// load API classes for accessing endpoints // load API classes for accessing endpoints
@ -50,7 +49,7 @@ Import the following:
## Recommendation ## Recommendation
It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue. It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issues.
## Getting Started ## Getting Started
@ -59,11 +58,11 @@ Please follow the [installation procedure](#installation--usage) and then run th
```objc ```objc
NSString* *testCodeInjectEndRnNR = @"testCodeInjectEndRnNR_example"; // To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional) NSString* *testCodeInjectEndRnNR = @"testCodeInjectEndRnNR_example"; // To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
SWGFakeApi *apiInstance = [[SWGFakeApi alloc] init]; SWGFakeApi *apiInstance = [[SWGFakeApi alloc] init];
// To test code injection *_/ ' \" =end \\r\\n \\n \\r // To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
[apiInstance testCodeInjectEndRnNRWithTestCodeInjectEndRnNR:testCodeInjectEndRnNR [apiInstance testCodeInjectEndRnNRWithTestCodeInjectEndRnNR:testCodeInjectEndRnNR
completionHandler: ^(NSError* error) { completionHandler: ^(NSError* error) {
if (error) { if (error) {
@ -75,11 +74,11 @@ SWGFakeApi *apiInstance = [[SWGFakeApi alloc] init];
## Documentation for API Endpoints ## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r* All URIs are relative to *https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*SWGFakeApi* | [**testCodeInjectEndRnNR**](docs/SWGFakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r *SWGFakeApi* | [**testCodeInjectEndRnNR**](docs/SWGFakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
## Documentation For Models ## Documentation For Models
@ -93,7 +92,7 @@ Class | Method | HTTP request | Description
## api_key ## api_key
- **Type**: API key - **Type**: API key
- **API key parameter name**: api_key */ ' " =end \r\n \n \r - **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
- **Location**: HTTP header - **Location**: HTTP header
## petstore_auth ## petstore_auth
@ -102,12 +101,12 @@ Class | Method | HTTP request | Description
- **Flow**: implicit - **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**: - **Scopes**:
- **write:pets**: modify pets in your account */ ' " =end \r\n \n \r - **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r
- **read:pets**: read your pets */ ' " =end \r\n \n \r - **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r
## Author ## Author
apiteam@swagger.io *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r apiteam@swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r

View File

@ -11,9 +11,9 @@ Pod::Spec.new do |s|
s.name = "SwaggerClient" s.name = "SwaggerClient"
s.version = "1.0.0" s.version = "1.0.0"
s.summary = "Swagger Petstore *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r" s.summary = "Swagger Petstore *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r"
s.description = <<-DESC s.description = <<-DESC
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
DESC DESC
s.platform = :ios, '7.0' s.platform = :ios, '7.0'
@ -22,7 +22,7 @@ Pod::Spec.new do |s|
s.framework = 'SystemConfiguration' s.framework = 'SystemConfiguration'
s.homepage = "https://github.com/swagger-api/swagger-codegen" s.homepage = "https://github.com/swagger-api/swagger-codegen"
s.license = "Apache License, Version 2.0" s.license = "Proprietary"
s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" } s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" }
s.author = { "Swagger" => "apiteam@swagger.io" } s.author = { "Swagger" => "apiteam@swagger.io" }
@ -32,6 +32,6 @@ Pod::Spec.new do |s|
s.dependency 'AFNetworking', '~> 3' s.dependency 'AFNetworking', '~> 3'
s.dependency 'JSONModel', '~> 1.2' s.dependency 'JSONModel', '~> 1.2'
s.dependency 'ISO8601', '~> 0.5' s.dependency 'ISO8601', '~> 0.6'
end end

View File

@ -2,46 +2,35 @@
#import "SWGApi.h" #import "SWGApi.h"
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGFakeApi: NSObject <SWGApi> @interface SWGFakeApi: NSObject <SWGApi>
extern NSString* kSWGFakeApiErrorDomain; extern NSString* kSWGFakeApiErrorDomain;
extern NSInteger kSWGFakeApiMissingParamErrorCode; extern NSInteger kSWGFakeApiMissingParamErrorCode;
+(instancetype) sharedAPI; -(instancetype) initWithApiClient:(SWGApiClient *)apiClient NS_DESIGNATED_INITIALIZER;
/// To test code injection *_/ ' \" =end \\r\\n \\n \\r /// To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
/// ///
/// ///
/// @param testCodeInjectEndRnNR To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r (optional) /// @param testCodeInjectEndRnNR To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
/// ///
/// code:400 message:"To test code injection *_/ ' \" =end \\r\\n \\n \\r" /// code:400 message:"To test code injection *_/ ' \" =end -- \\r\\n \\n \\r"
/// ///
/// @return /// @return
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR -(NSURLSessionTask*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
completionHandler: (void (^)(NSError* error)) handler; completionHandler: (void (^)(NSError* error)) handler;

View File

@ -1,10 +1,11 @@
#import "SWGFakeApi.h" #import "SWGFakeApi.h"
#import "SWGQueryParamCollection.h" #import "SWGQueryParamCollection.h"
#import "SWGApiClient.h"
@interface SWGFakeApi () @interface SWGFakeApi ()
@property (nonatomic, strong) NSMutableDictionary *defaultHeaders; @property (nonatomic, strong, readwrite) NSMutableDictionary *mutableDefaultHeaders;
@end @end
@ -18,64 +19,43 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
#pragma mark - Initialize methods #pragma mark - Initialize methods
- (instancetype) init { - (instancetype) init {
self = [super init]; return [self initWithApiClient:[SWGApiClient sharedClient]];
if (self) {
SWGConfiguration *config = [SWGConfiguration sharedConfig];
if (config.apiClient == nil) {
config.apiClient = [[SWGApiClient alloc] init];
}
_apiClient = config.apiClient;
_defaultHeaders = [NSMutableDictionary dictionary];
}
return self;
} }
- (id) initWithApiClient:(SWGApiClient *)apiClient {
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient {
self = [super init]; self = [super init];
if (self) { if (self) {
_apiClient = apiClient; _apiClient = apiClient;
_defaultHeaders = [NSMutableDictionary dictionary]; _mutableDefaultHeaders = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
#pragma mark - #pragma mark -
+ (instancetype)sharedAPI {
static SWGFakeApi *sharedAPI;
static dispatch_once_t once;
dispatch_once(&once, ^{
sharedAPI = [[self alloc] init];
});
return sharedAPI;
}
-(NSString*) defaultHeaderForKey:(NSString*)key { -(NSString*) defaultHeaderForKey:(NSString*)key {
return self.defaultHeaders[key]; return self.mutableDefaultHeaders[key];
}
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
[self setDefaultHeaderValue:value forKey:key];
} }
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key { -(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key]; [self.mutableDefaultHeaders setValue:value forKey:key];
} }
-(NSUInteger) requestQueueSize { -(NSDictionary *)defaultHeaders {
return [SWGApiClient requestQueueSize]; return self.mutableDefaultHeaders;
} }
#pragma mark - Api Methods #pragma mark - Api Methods
/// ///
/// To test code injection *_/ ' \" =end \\r\\n \\n \\r /// To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
/// ///
/// @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional) /// @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
/// ///
/// @returns void /// @returns void
/// ///
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR -(NSURLSessionTask*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
completionHandler: (void (^)(NSError* error)) handler { completionHandler: (void (^)(NSError* error)) handler {
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/fake"]; NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/fake"];
@ -88,9 +68,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders]; NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders];
[headerParams addEntriesFromDictionary:self.defaultHeaders]; [headerParams addEntriesFromDictionary:self.defaultHeaders];
// HTTP header `Accept` // HTTP header `Accept`
NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"*/ ' =end NSString *acceptHeader = [self.apiClient.sanitizer selectHeaderAccept:@[@"application/json", @"*_/ ' =end -- "]];
"]];
if(acceptHeader.length > 0) { if(acceptHeader.length > 0) {
headerParams[@"Accept"] = acceptHeader; headerParams[@"Accept"] = acceptHeader;
} }
@ -99,9 +77,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @""; NSString *responseContentType = [[acceptHeader componentsSeparatedByString:@", "] firstObject] ?: @"";
// request content type // request content type
NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[@"application/json", @"*/ ' =end NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[@"application/json", @"*_/ ' =end -- "]];
"]];
// Authentication setting // Authentication setting
NSArray *authSettings = @[]; NSArray *authSettings = @[];
@ -110,7 +86,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
if (testCodeInjectEndRnNR) { if (testCodeInjectEndRnNR) {
formParams[@"test code inject */ &#39; &quot; &#x3D;end \r\n \n \r"] = testCodeInjectEndRnNR; formParams[@"test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r"] = testCodeInjectEndRnNR;
} }
return [self.apiClient requestWithPath: resourcePath return [self.apiClient requestWithPath: resourcePath
@ -129,8 +105,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
if(handler) { if(handler) {
handler(error); handler(error);
} }
} }];
];
} }

View File

@ -1,31 +1,19 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <ISO8601/ISO8601.h>
#import <JSONModel/JSONValueTransformer.h> #import <JSONModel/JSONValueTransformer.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface JSONValueTransformer (ISO8601) @interface JSONValueTransformer (ISO8601)
@end @end

View File

@ -1,3 +1,4 @@
#import <ISO8601/NSDate+ISO8601.h>
#import "JSONValueTransformer+ISO8601.h" #import "JSONValueTransformer+ISO8601.h"
@implementation JSONValueTransformer (ISO8601) @implementation JSONValueTransformer (ISO8601)

View File

@ -1,42 +1,29 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "SWGObject.h"
#import "SWGApiClient.h" @class SWGApiClient;
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@protocol SWGApi <NSObject> @protocol SWGApi <NSObject>
@property(nonatomic, assign) SWGApiClient *apiClient; @property(readonly, nonatomic, strong) SWGApiClient *apiClient;
-(id) initWithApiClient:(SWGApiClient *)apiClient; -(instancetype) initWithApiClient:(SWGApiClient *)apiClient;
-(void) addHeader:(NSString*)value forKey:(NSString*)key DEPRECATED_MSG_ATTRIBUTE("setDefaultHeaderValue:forKey:");
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key; -(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
-(NSString*) defaultHeaderForKey:(NSString*)key; -(NSString*) defaultHeaderForKey:(NSString*)key;
-(NSUInteger) requestQueueSize; -(NSDictionary *)defaultHeaders;
@end @end

View File

@ -1,43 +1,20 @@
#import <Foundation/Foundation.h>
#import <ISO8601/ISO8601.h>
#import <AFNetworking/AFNetworking.h> #import <AFNetworking/AFNetworking.h>
#import "SWGJSONResponseSerializer.h"
#import "SWGJSONRequestSerializer.h"
#import "SWGQueryParamCollection.h"
#import "SWGConfiguration.h" #import "SWGConfiguration.h"
#import "SWGResponseDeserializer.h" #import "SWGResponseDeserializer.h"
#import "SWGSanitizer.h" #import "SWGSanitizer.h"
#import "SWGLogger.h"
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
#import "SWGReturn.h"
@class SWGConfiguration;
/** /**
* A key for `NSError` user info dictionaries. * A key for `NSError` user info dictionaries.
@ -46,117 +23,49 @@
*/ */
extern NSString *const SWGResponseObjectErrorKey; extern NSString *const SWGResponseObjectErrorKey;
@interface SWGApiClient : AFHTTPSessionManager @interface SWGApiClient : AFHTTPSessionManager
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy; @property (nonatomic, strong, readonly) id<SWGConfiguration> configuration;
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
@property(nonatomic, readonly) NSOperationQueue* queue;
/// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one SWGApiClient instance per thread. @property(nonatomic, assign) NSTimeInterval timeoutInterval;
@property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders;
@property(nonatomic, strong) id<SWGResponseDeserializer> responseDeserializer; @property(nonatomic, strong) id<SWGResponseDeserializer> responseDeserializer;
@property(nonatomic, strong) id<SWGSanitizer> sanitizer; @property(nonatomic, strong) id<SWGSanitizer> sanitizer;
/**
* Clears Cache @property (nonatomic, strong) NSDictionary< NSString *, AFHTTPRequestSerializer <AFURLRequestSerialization> *>* requestSerializerForContentType;
*/
+(void)clearCache;
/** /**
* Turns on cache * Gets client singleton instance
*
* @param enabled If the cached is enable, must be `YES` or `NO`
*/ */
+(void)setCacheEnabled:(BOOL) enabled; + (instancetype) sharedClient;
/**
* Gets the request queue size
*
* @return The size of `queuedRequests` static variable.
*/
+(NSUInteger)requestQueueSize;
/**
* Sets the client unreachable
*
* @param state off line state, must be `YES` or `NO`
*/
+(void) setOfflineState:(BOOL) state;
/**
* Gets if the client is unreachable
*
* @return The client offline state
*/
+(BOOL) getOfflineState;
/**
* Sets the client reachability, this may be overridden by the reachability manager if reachability changes
*
* @param The client reachability.
*/
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
/**
* Gets the client reachability
*
* @return The client reachability.
*/
+(AFNetworkReachabilityStatus) getReachabilityStatus;
/**
* Gets the next request id
*
* @return The next executed request id.
*/
+(NSNumber*) nextRequestId;
/**
* Generates request id and add it to the queue
*
* @return The next executed request id.
*/
+(NSNumber*) queueRequest;
/**
* Removes request id from the queue
*
* @param requestId The request which will be removed.
*/
+(void) cancelRequest:(NSNumber*)requestId;
/**
* Customizes the behavior when the reachability changed
*
* @param changeBlock The block will be executed when the reachability changed.
*/
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
/**
* Sets the api client reachability strategy
*/
- (void)configureCacheReachibility;
/**
* Sets header for request
*
* @param value The header value
* @param forKey The header key
*/
-(void)setHeaderValue:(NSString*) value
forKey:(NSString*) forKey;
/** /**
* Updates header parameters and query parameters for authentication * Updates header parameters and query parameters for authentication
* *
* @param headers The header parameter will be updated, passed by pointer to pointer. * @param headers The header parameter will be udpated, passed by pointer to pointer.
* @param querys The query parameters will be updated, passed by pointer to pointer. * @param querys The query parameters will be updated, passed by pointer to pointer.
* @param authSettings The authentication names NSArray. * @param authSettings The authentication names NSArray.
*/ */
- (void) updateHeaderParams:(NSDictionary **)headers - (void) updateHeaderParams:(NSDictionary **)headers queryParams:(NSDictionary **)querys WithAuthSettings:(NSArray *)authSettings;
queryParams:(NSDictionary **)querys
WithAuthSettings:(NSArray *)authSettings;
/**
* Initializes the session manager with a configuration.
*
* @param configuration The configuration implementation
*/
- (instancetype)initWithConfiguration:(id<SWGConfiguration>)configuration;
/**
* Initializes the session manager with a configuration and url
*
* @param url The base url
* @param configuration The configuration implementation
*/
- (instancetype)initWithBaseURL:(NSURL *)url configuration:(id<SWGConfiguration>)configuration;
/** /**
* Performs request * Performs request
@ -172,35 +81,20 @@ extern NSString *const SWGResponseObjectErrorKey;
* @param responseContentType Response content-type. * @param responseContentType Response content-type.
* @param completionBlock The block will be executed when the request completed. * @param completionBlock The block will be executed when the request completed.
* *
* @return The request id. * @return The created session task.
*/ */
-(NSNumber*) requestWithPath:(NSString*) path - (NSURLSessionTask*) requestWithPath: (NSString*) path
method:(NSString*) method method: (NSString*) method
pathParams:(NSDictionary *) pathParams pathParams: (NSDictionary *) pathParams
queryParams:(NSDictionary*) queryParams queryParams: (NSDictionary*) queryParams
formParams:(NSDictionary *) formParams formParams: (NSDictionary *) formParams
files:(NSDictionary *) files files: (NSDictionary *) files
body:(id) body body: (id) body
headerParams:(NSDictionary*) headerParams headerParams: (NSDictionary*) headerParams
authSettings:(NSArray *) authSettings authSettings: (NSArray *) authSettings
requestContentType:(NSString*) requestContentType requestContentType: (NSString*) requestContentType
responseContentType:(NSString*) responseContentType responseContentType: (NSString*) responseContentType
responseType:(NSString *) responseType responseType: (NSString *) responseType
completionBlock:(void (^)(id, NSError *))completionBlock; completionBlock: (void (^)(id, NSError *))completionBlock;
/**
* Custom security policy
*
* @return AFSecurityPolicy
*/
- (AFSecurityPolicy *) customSecurityPolicy;
/**
* SWGConfiguration return sharedConfig
*
* @return SWGConfiguration
*/
- (SWGConfiguration*) configuration;
@end @end

View File

@ -1,14 +1,13 @@
#import "SWGLogger.h"
#import "SWGApiClient.h" #import "SWGApiClient.h"
#import "SWGJSONRequestSerializer.h"
#import "SWGQueryParamCollection.h"
#import "SWGDefaultConfiguration.h"
NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject"; NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject";
static NSUInteger requestId = 0; static NSString * const kSWGContentDispositionKey = @"Content-Disposition";
static bool offlineState = false;
static NSMutableSet * queuedRequests = nil;
static bool cacheEnabled = false;
static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilityStatusNotReachable;
static void (^reachabilityChangeBlock)(int);
static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) { static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) {
if(![response isKindOfClass:[NSHTTPURLResponse class]]) { if(![response isKindOfClass:[NSHTTPURLResponse class]]) {
@ -19,179 +18,80 @@ static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) {
static NSString * SWG__fileNameForResponse(NSURLResponse *response) { static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
NSDictionary * headers = SWG__headerFieldsForResponse(response); NSDictionary * headers = SWG__headerFieldsForResponse(response);
if(!headers[@"Content-Disposition"]) { if(!headers[kSWGContentDispositionKey]) {
return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]];
} }
NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?"; NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?";
NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil];
options:NSRegularExpressionCaseInsensitive NSString *contentDispositionHeader = headers[kSWGContentDispositionKey];
error:nil]; NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader options:0 range:NSMakeRange(0, [contentDispositionHeader length])];
NSString *contentDispositionHeader = headers[@"Content-Disposition"];
NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader
options:0
range:NSMakeRange(0, [contentDispositionHeader length])];
return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]]; return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]];
} }
@interface SWGApiClient () @interface SWGApiClient ()
@property (nonatomic, strong) NSDictionary* HTTPResponseHeaders; @property (nonatomic, strong, readwrite) id<SWGConfiguration> configuration;
@property (nonatomic, strong) NSArray<NSString*>* downloadTaskResponseTypes;
@end @end
@implementation SWGApiClient @implementation SWGApiClient
#pragma mark - Singleton Methods
+ (instancetype) sharedClient {
static SWGApiClient *sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedClient = [[self alloc] init];
});
return sharedClient;
}
#pragma mark - Initialize Methods
- (instancetype)init { - (instancetype)init {
NSString *baseUrl = [[SWGConfiguration sharedConfig] host]; return [self initWithConfiguration:[SWGDefaultConfiguration sharedConfig]];
return [self initWithBaseURL:[NSURL URLWithString:baseUrl]];
} }
- (instancetype)initWithBaseURL:(NSURL *)url { - (instancetype)initWithBaseURL:(NSURL *)url {
return [self initWithBaseURL:url configuration:[SWGDefaultConfiguration sharedConfig]];
}
- (instancetype)initWithConfiguration:(id<SWGConfiguration>)configuration {
return [self initWithBaseURL:[NSURL URLWithString:configuration.host] configuration:configuration];
}
- (instancetype)initWithBaseURL:(NSURL *)url configuration:(id<SWGConfiguration>)configuration {
self = [super initWithBaseURL:url]; self = [super initWithBaseURL:url];
if (self) { if (self) {
self.timeoutInterval = 60; _configuration = configuration;
self.requestSerializer = [AFJSONRequestSerializer serializer]; _timeoutInterval = 60;
self.responseSerializer = [AFJSONResponseSerializer serializer]; _responseDeserializer = [[SWGResponseDeserializer alloc] init];
self.securityPolicy = [self customSecurityPolicy]; _sanitizer = [[SWGSanitizer alloc] init];
self.responseDeserializer = [[SWGResponseDeserializer alloc] init];
self.sanitizer = [[SWGSanitizer alloc] init]; _downloadTaskResponseTypes = @[@"NSURL*", @"NSURL"];
// configure reachability
[self configureCacheReachibility]; AFHTTPRequestSerializer* afhttpRequestSerializer = [AFHTTPRequestSerializer serializer];
SWGJSONRequestSerializer * swgjsonRequestSerializer = [SWGJSONRequestSerializer serializer];
_requestSerializerForContentType = @{kSWGApplicationJSONType : swgjsonRequestSerializer,
@"application/x-www-form-urlencoded": afhttpRequestSerializer,
@"multipart/form-data": afhttpRequestSerializer
};
self.securityPolicy = [self createSecurityPolicy];
self.responseSerializer = [AFHTTPResponseSerializer serializer];
} }
return self; return self;
} }
+ (void)initialize { #pragma mark - Task Methods
if (self == [SWGApiClient class]) {
queuedRequests = [[NSMutableSet alloc] init];
// initialize URL cache
[self configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024];
}
}
#pragma mark - Setter Methods - (NSURLSessionDataTask*) taskWithCompletionBlock: (NSURLRequest *)request completionBlock: (void (^)(id, NSError *))completionBlock {
+ (void) setOfflineState:(BOOL) state { NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
offlineState = state;
}
+ (void) setCacheEnabled:(BOOL)enabled {
cacheEnabled = enabled;
}
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status {
reachabilityStatus = status;
}
- (void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey {
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
}
- (void)setRequestSerializer:(AFHTTPRequestSerializer<AFURLRequestSerialization> *)requestSerializer {
[super setRequestSerializer:requestSerializer];
requestSerializer.timeoutInterval = self.timeoutInterval;
}
#pragma mark - Cache Methods
+(void)clearCache {
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
+(void)configureCacheWithMemoryAndDiskCapacity: (unsigned long) memorySize
diskSize: (unsigned long) diskSize {
NSAssert(memorySize > 0, @"invalid in-memory cache size");
NSAssert(diskSize >= 0, @"invalid disk cache size");
NSURLCache *cache =
[[NSURLCache alloc]
initWithMemoryCapacity:memorySize
diskCapacity:diskSize
diskPath:@"swagger_url_cache"];
[NSURLCache setSharedURLCache:cache];
}
#pragma mark - Request Methods
+(NSUInteger)requestQueueSize {
return [queuedRequests count];
}
+(NSNumber*) nextRequestId {
@synchronized(self) {
return @(++requestId);
}
}
+(NSNumber*) queueRequest {
NSNumber* requestId = [[self class] nextRequestId];
SWGDebugLog(@"added %@ to request queue", requestId);
[queuedRequests addObject:requestId];
return requestId;
}
+(void) cancelRequest:(NSNumber*)requestId {
[queuedRequests removeObject:requestId];
}
-(Boolean) executeRequestWithId:(NSNumber*) requestId {
NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) {
return [obj intValue] == [requestId intValue];
}];
if (matchingItems.count == 1) {
SWGDebugLog(@"removed request id %@", requestId);
[queuedRequests removeObject:requestId];
return YES;
} else {
return NO;
}
}
#pragma mark - Reachability Methods
+(AFNetworkReachabilityStatus) getReachabilityStatus {
return reachabilityStatus;
}
+(BOOL) getOfflineState {
return offlineState;
}
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock {
reachabilityChangeBlock = changeBlock;
}
- (void) configureCacheReachibility {
[self.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
reachabilityStatus = status;
SWGDebugLog(@"reachability changed to %@",AFStringFromNetworkReachabilityStatus(status));
[SWGApiClient setOfflineState:status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable];
// call the reachability block, if configured
if (reachabilityChangeBlock != nil) {
reachabilityChangeBlock(status);
}
}];
[self.reachabilityManager startMonitoring];
}
#pragma mark - Operation Methods
- (void) operationWithCompletionBlock: (NSURLRequest *)request
requestId: (NSNumber *) requestId
completionBlock: (void (^)(id, NSError *))completionBlock {
__weak __typeof(self)weakSelf = self;
NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (![strongSelf executeRequestWithId:requestId]) {
return;
}
SWGDebugLogResponse(response, responseObject,request,error); SWGDebugLogResponse(response, responseObject,request,error);
strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response);
if(!error) { if(!error) {
completionBlock(responseObject, nil); completionBlock(responseObject, nil);
return; return;
@ -204,20 +104,17 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
completionBlock(nil, augmentedError); completionBlock(nil, augmentedError);
}]; }];
[op resume];
return task;
} }
- (void) downloadOperationWithCompletionBlock: (NSURLRequest *)request - (NSURLSessionDataTask*) downloadTaskWithCompletionBlock: (NSURLRequest *)request completionBlock: (void (^)(id, NSError *))completionBlock {
requestId: (NSNumber *) requestId
completionBlock: (void (^)(id, NSError *))completionBlock { __block NSString * tempFolderPath = [self.configuration.tempFolderPath copy];
__weak __typeof(self)weakSelf = self;
NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { NSURLSessionDataTask* task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (![strongSelf executeRequestWithId:requestId]) {
return;
}
strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response);
SWGDebugLogResponse(response, responseObject,request,error); SWGDebugLogResponse(response, responseObject,request,error);
if(error) { if(error) {
NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
if (responseObject) { if (responseObject) {
@ -225,9 +122,11 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
} }
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
completionBlock(nil, augmentedError); completionBlock(nil, augmentedError);
return;
} }
NSString *directory = [self configuration].tempFolderPath ?: NSTemporaryDirectory();
NSString * filename = SWG__fileNameForResponse(response); NSString *directory = tempFolderPath ?: NSTemporaryDirectory();
NSString *filename = SWG__fileNameForResponse(response);
NSString *filepath = [directory stringByAppendingPathComponent:filename]; NSString *filepath = [directory stringByAppendingPathComponent:filename];
NSURL *file = [NSURL fileURLWithPath:filepath]; NSURL *file = [NSURL fileURLWithPath:filepath];
@ -236,53 +135,37 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
completionBlock(file, nil); completionBlock(file, nil);
}]; }];
[op resume];
return task;
} }
#pragma mark - Perform Request Methods #pragma mark - Perform Request Methods
-(NSNumber*) requestWithPath: (NSString*) path - (NSURLSessionTask*) requestWithPath: (NSString*) path
method: (NSString*) method method: (NSString*) method
pathParams: (NSDictionary *) pathParams pathParams: (NSDictionary *) pathParams
queryParams: (NSDictionary*) queryParams queryParams: (NSDictionary*) queryParams
formParams: (NSDictionary *) formParams formParams: (NSDictionary *) formParams
files: (NSDictionary *) files files: (NSDictionary *) files
body: (id) body body: (id) body
headerParams: (NSDictionary*) headerParams headerParams: (NSDictionary*) headerParams
authSettings: (NSArray *) authSettings authSettings: (NSArray *) authSettings
requestContentType: (NSString*) requestContentType requestContentType: (NSString*) requestContentType
responseContentType: (NSString*) responseContentType responseContentType: (NSString*) responseContentType
responseType: (NSString *) responseType responseType: (NSString *) responseType
completionBlock: (void (^)(id, NSError *))completionBlock { completionBlock: (void (^)(id, NSError *))completionBlock {
// setting request serializer
if ([requestContentType isEqualToString:@"application/json"]) {
self.requestSerializer = [SWGJSONRequestSerializer serializer];
}
else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) {
self.requestSerializer = [AFHTTPRequestSerializer serializer];
}
else if ([requestContentType isEqualToString:@"multipart/form-data"]) {
self.requestSerializer = [AFHTTPRequestSerializer serializer];
}
else {
self.requestSerializer = [AFHTTPRequestSerializer serializer];
NSAssert(NO, @"Unsupported request type %@", requestContentType);
}
// setting response serializer AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer = [self requestSerializerForRequestContentType:requestContentType];
if ([responseContentType isEqualToString:@"application/json"]) {
self.responseSerializer = [SWGJSONResponseSerializer serializer]; __weak id<SWGSanitizer> sanitizer = self.sanitizer;
} else {
self.responseSerializer = [AFHTTPResponseSerializer serializer];
}
// sanitize parameters // sanitize parameters
pathParams = [self.sanitizer sanitizeForSerialization:pathParams]; pathParams = [sanitizer sanitizeForSerialization:pathParams];
queryParams = [self.sanitizer sanitizeForSerialization:queryParams]; queryParams = [sanitizer sanitizeForSerialization:queryParams];
headerParams = [self.sanitizer sanitizeForSerialization:headerParams]; headerParams = [sanitizer sanitizeForSerialization:headerParams];
formParams = [self.sanitizer sanitizeForSerialization:formParams]; formParams = [sanitizer sanitizeForSerialization:formParams];
if(![body isKindOfClass:[NSData class]]) { if(![body isKindOfClass:[NSData class]]) {
body = [self.sanitizer sanitizeForSerialization:body]; body = [sanitizer sanitizeForSerialization:body];
} }
// auth setting // auth setting
@ -295,22 +178,19 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
[resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"{%@}", key]] withString:safeString]; [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"{%@}", key]] withString:safeString];
}]; }];
NSMutableURLRequest * request = nil;
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams]; NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams];
if ([pathWithQueryParams hasPrefix:@"/"]) { if ([pathWithQueryParams hasPrefix:@"/"]) {
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1]; pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
} }
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString]; NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
NSError *requestCreateError = nil;
NSMutableURLRequest * request = nil;
if (files.count > 0) { if (files.count > 0) {
__weak __typeof(self)weakSelf = self; request = [requestSerializer multipartFormRequestWithMethod:@"POST" URLString:urlString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
URLString:urlString
parameters:nil
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
NSString *objString = [weakSelf.sanitizer parameterToString:obj]; NSString *objString = [sanitizer parameterToString:obj];
NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding]; NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding];
[formData appendPartWithFormData:data name:key]; [formData appendPartWithFormData:data name:key];
}]; }];
@ -318,76 +198,73 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
NSURL *filePath = (NSURL *)obj; NSURL *filePath = (NSURL *)obj;
[formData appendPartWithFileURL:filePath name:key error:nil]; [formData appendPartWithFileURL:filePath name:key error:nil];
}]; }];
} error:nil]; } error:&requestCreateError];
} }
else { else {
if (formParams) { if (formParams) {
request = [self.requestSerializer requestWithMethod:method request = [requestSerializer requestWithMethod:method URLString:urlString parameters:formParams error:&requestCreateError];
URLString:urlString
parameters:formParams
error:nil];
} }
if (body) { if (body) {
request = [self.requestSerializer requestWithMethod:method request = [requestSerializer requestWithMethod:method URLString:urlString parameters:body error:&requestCreateError];
URLString:urlString
parameters:body
error:nil];
} }
} }
if(!request) {
// request cache completionBlock(nil, requestCreateError);
BOOL hasHeaderParams = [headerParams count] > 0; return nil;
if (offlineState) {
SWGDebugLog(@"%@ cache forced", resourcePath);
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
}
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
SWGDebugLog(@"%@ cache enabled", resourcePath);
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
}
else {
SWGDebugLog(@"%@ cache disabled", resourcePath);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
} }
if (hasHeaderParams){ if ([headerParams count] > 0){
for(NSString * key in [headerParams keyEnumerator]){ for(NSString * key in [headerParams keyEnumerator]){
[request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key]; [request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key];
} }
} }
[self.requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"]; [requestSerializer setValue:responseContentType forHTTPHeaderField:@"Accept"];
[self postProcessRequest:request]; [self postProcessRequest:request];
NSNumber* requestId = [SWGApiClient queueRequest];
if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) { NSURLSessionTask *task = nil;
[self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
if ([self.downloadTaskResponseTypes containsObject:responseType]) {
task = [self downloadTaskWithCompletionBlock:request completionBlock:^(id data, NSError *error) {
completionBlock(data, error); completionBlock(data, error);
}]; }];
} } else {
else { __weak typeof(self) weakSelf = self;
[self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { task = [self taskWithCompletionBlock:request completionBlock:^(id data, NSError *error) {
NSError * serializationError; NSError * serializationError;
id response = [self.responseDeserializer deserialize:data class:responseType error:&serializationError]; id response = [weakSelf.responseDeserializer deserialize:data class:responseType error:&serializationError];
if(!response && !error){ if(!response && !error){
error = serializationError; error = serializationError;
} }
completionBlock(response, error); completionBlock(response, error);
}]; }];
} }
return requestId;
[task resume];
return task;
}
-(AFHTTPRequestSerializer <AFURLRequestSerialization> *)requestSerializerForRequestContentType:(NSString *)requestContentType {
AFHTTPRequestSerializer <AFURLRequestSerialization> * serializer = self.requestSerializerForContentType[requestContentType];
if(!serializer) {
NSAssert(NO, @"Unsupported request content type %@", requestContentType);
serializer = [AFHTTPRequestSerializer serializer];
}
serializer.timeoutInterval = self.timeoutInterval;
return serializer;
} }
//Added for easier override to modify request //Added for easier override to modify request
-(void)postProcessRequest:(NSMutableURLRequest *)request { -(void)postProcessRequest:(NSMutableURLRequest *)request {
// Always disable cookies!
[request setHTTPShouldHandleCookies:NO];
} }
#pragma mark - #pragma mark -
- (NSString*) pathWithQueryParamsToString:(NSString*) path - (NSString*) pathWithQueryParamsToString:(NSString*) path queryParams:(NSDictionary*) queryParams {
queryParams:(NSDictionary*) queryParams {
if(queryParams.count == 0) { if(queryParams.count == 0) {
return path; return path;
} }
@ -445,9 +322,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
/** /**
* Update header and query params based on authentication settings * Update header and query params based on authentication settings
*/ */
- (void) updateHeaderParams:(NSDictionary *__autoreleasing *)headers - (void) updateHeaderParams:(NSDictionary * *)headers queryParams:(NSDictionary * *)querys WithAuthSettings:(NSArray *)authSettings {
queryParams:(NSDictionary *__autoreleasing *)querys
WithAuthSettings:(NSArray *)authSettings {
if ([authSettings count] == 0) { if ([authSettings count] == 0) {
return; return;
@ -456,9 +331,10 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
NSDictionary* configurationAuthSettings = [[self configuration] authSettings]; id<SWGConfiguration> config = self.configuration;
for (NSString *auth in authSettings) { for (NSString *auth in authSettings) {
NSDictionary *authSetting = configurationAuthSettings[auth]; NSDictionary *authSetting = config.authSettings[auth];
if(!authSetting) { // auth setting is set only if the key is non-empty if(!authSetting) { // auth setting is set only if the key is non-empty
continue; continue;
} }
@ -476,14 +352,14 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
} }
- (AFSecurityPolicy *) customSecurityPolicy { - (AFSecurityPolicy *) createSecurityPolicy {
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]; AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
SWGConfiguration *config = [self configuration]; id<SWGConfiguration> config = self.configuration;
if (config.sslCaCert) { if (config.sslCaCert) {
NSData *certData = [NSData dataWithContentsOfFile:config.sslCaCert]; NSData *certData = [NSData dataWithContentsOfFile:config.sslCaCert];
[securityPolicy setPinnedCertificates:@[certData]]; [securityPolicy setPinnedCertificates:[NSSet setWithObject:certData]];
} }
if (config.verifySSL) { if (config.verifySSL) {
@ -497,8 +373,4 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
return securityPolicy; return securityPolicy;
} }
- (SWGConfiguration*) configuration {
return [SWGConfiguration sharedConfig];
}
@end @end

View File

@ -1,182 +1,89 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "SWGApiClient.h"
#import "SWGLogger.h" @class SWGLogger;
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@class SWGApiClient;
@interface SWGConfiguration : NSObject static NSString * const kSWGAPIVersion = @"1.0.0";
@protocol SWGConfiguration <NSObject>
/** /**
* Default api logger * Api logger
*/ */
@property (nonatomic, strong) SWGLogger * logger; @property (readonly, nonatomic) SWGLogger *logger;
/** /**
* Default api client * Base url
*/ */
@property (nonatomic) SWGApiClient *apiClient; @property (readonly, nonatomic) NSString *host;
/**
* Default base url
*/
@property (nonatomic) NSString *host;
/** /**
* Api key values for Api Key type Authentication * Api key values for Api Key type Authentication
*
* To add or remove api key, use `setApiKey:forApiKeyIdentifier:`.
*/ */
@property (readonly, nonatomic, strong) NSDictionary *apiKey; @property (readonly, nonatomic) NSDictionary *apiKey;
/** /**
* Api key prefix values to be prepend to the respective api key * Api key prefix values to be prepend to the respective api key
*
* To add or remove prefix, use `setApiKeyPrefix:forApiKeyPrefixIdentifier:`.
*/ */
@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; @property (readonly, nonatomic) NSDictionary *apiKeyPrefix;
/** /**
* Username for HTTP Basic Authentication * Username for HTTP Basic Authentication
*/ */
@property (nonatomic) NSString *username; @property (readonly, nonatomic) NSString *username;
/** /**
* Password for HTTP Basic Authentication * Password for HTTP Basic Authentication
*/ */
@property (nonatomic) NSString *password; @property (readonly, nonatomic) NSString *password;
/** /**
* Access token for OAuth * Access token for OAuth
*/ */
@property (nonatomic) NSString *accessToken; @property (readonly, nonatomic) NSString *accessToken;
/** /**
* Temp folder for file download * Temp folder for file download
*/ */
@property (nonatomic) NSString *tempFolderPath; @property (readonly, nonatomic) NSString *tempFolderPath;
/** /**
* Debug switch, default false * Debug switch, default false
*/ */
@property (nonatomic) BOOL debug; @property (readonly, nonatomic) BOOL debug;
/**
* Gets configuration singleton instance
*/
+ (instancetype) sharedConfig;
/** /**
* SSL/TLS verification * SSL/TLS verification
* Set this to NO to skip verifying SSL certificate when calling API from https server * Set this to NO to skip verifying SSL certificate when calling API from https server
*/ */
@property (nonatomic) BOOL verifySSL; @property (readonly, nonatomic) BOOL verifySSL;
/** /**
* SSL/TLS verification * SSL/TLS verification
* Set this to customize the certificate file to verify the peer * Set this to customize the certificate file to verify the peer
*/ */
@property (nonatomic) NSString *sslCaCert; @property (readonly, nonatomic) NSString *sslCaCert;
/** /**
* Sets API key * Authentication Settings
*
* To remove a apiKey for an identifier, just set the apiKey to nil.
*
* @param apiKey API key or token.
* @param identifier API key identifier (authentication schema).
*
*/ */
- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier; @property (readonly, nonatomic) NSDictionary *authSettings;
/**
* Removes api key
*
* @param identifier API key identifier.
*/
- (void) removeApiKey:(NSString *)identifier;
/**
* Sets the prefix for API key
*
* @param apiKeyPrefix API key prefix.
* @param identifier API key identifier.
*/
- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier;
/**
* Removes api key prefix
*
* @param identifier API key identifier.
*/
- (void) removeApiKeyPrefix:(NSString *)identifier;
/**
* Gets API key (with prefix if set)
*/
- (NSString *) getApiKeyWithPrefix:(NSString *) key;
/**
* Gets Basic Auth token
*/
- (NSString *) getBasicAuthToken;
/**
* Gets OAuth access token
*/
- (NSString *) getAccessToken;
/**
* Gets Authentication Settings
*/
- (NSDictionary *) authSettings;
/** /**
* Default headers for all services * Default headers for all services
*/ */
@property (readonly, nonatomic, strong) NSDictionary *defaultHeaders; @property (readonly, nonatomic, strong) NSDictionary *defaultHeaders;
/** @end
* Removes header from defaultHeaders
*
* @param Header name.
*/
-(void) removeDefaultHeaderForKey:(NSString*)key;
/**
* Sets the header for key
*
* @param value Value for header name
* @param key Header name
*/
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
/**
* @param Header key name.
*/
-(NSString*) defaultHeaderForKey:(NSString*)key;
@end

View File

@ -2,28 +2,17 @@
#import <AFNetworking/AFURLRequestSerialization.h> #import <AFNetworking/AFURLRequestSerialization.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGJSONRequestSerializer : AFJSONRequestSerializer @interface SWGJSONRequestSerializer : AFJSONRequestSerializer
@end @end

View File

@ -1,29 +1,18 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
#ifndef SWGDebugLogResponse #ifndef SWGDebugLogResponse
#define SWGDebugLogResponse(response, responseObject,request, error) [[SWGLogger sharedLogger] logResponse:response responseObject:responseObject request:request error:error]; #define SWGDebugLogResponse(response, responseObject,request, error) [[SWGLogger sharedLogger] logResponse:response responseObject:responseObject request:request error:error];
#endif #endif

View File

@ -17,8 +17,7 @@
#pragma mark - Log Methods #pragma mark - Log Methods
- (void)debugLog:(NSString *)method - (void)debugLog:(NSString *)method message:(NSString *)format, ... {
message:(NSString *)format, ... {
if (!self.isEnabled) { if (!self.isEnabled) {
return; return;
} }

View File

@ -2,29 +2,18 @@
#import <JSONModel/JSONModel.h> #import <JSONModel/JSONModel.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGObject : JSONModel @interface SWGObject : JSONModel
@end @end

View File

@ -2,6 +2,35 @@
@implementation SWGObject @implementation SWGObject
/**
* Workaround for JSONModel multithreading issues
* https://github.com/icanzilb/JSONModel/issues/441
*/
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError **)err {
static NSMutableSet *classNames;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
classNames = [NSMutableSet new];
});
BOOL initSync;
@synchronized([self class])
{
NSString *className = NSStringFromClass([self class]);
initSync = ![classNames containsObject:className];
if(initSync)
{
[classNames addObject:className];
self = [super initWithDictionary:dict error:err];
}
}
if(!initSync)
{
self = [super initWithDictionary:dict error:err];
}
return self;
}
/** /**
* Gets the string presentation of the object. * Gets the string presentation of the object.
* This method will be called when logging model object using `NSLog`. * This method will be called when logging model object using `NSLog`.

View File

@ -1,29 +1,18 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGQueryParamCollection : NSObject @interface SWGQueryParamCollection : NSObject
@property(nonatomic, readonly) NSArray* values; @property(nonatomic, readonly) NSArray* values;

View File

@ -5,11 +5,15 @@
@synthesize values = _values; @synthesize values = _values;
@synthesize format = _format; @synthesize format = _format;
- (id) initWithValuesAndFormat: (NSArray*) values - (id)initWithValuesAndFormat:(NSArray *)values
format: (NSString*) format { format:(NSString *)format {
_values = values;
_format = format;
self = [super init];
if (self) {
_values = values;
_format = format;
}
return self; return self;
} }

View File

@ -1,29 +1,18 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
/** /**
* A key for deserialization ErrorDomain * A key for deserialization ErrorDomain
*/ */
@ -50,7 +39,7 @@ extern NSInteger const SWGUnknownResponseObjectErrorCode;
* Deserializes the given data to Objective-C object. * Deserializes the given data to Objective-C object.
* *
* @param data The data will be deserialized. * @param data The data will be deserialized.
* @param class The type of objective-c object. * @param className The type of objective-c object.
* @param error The error * @param error The error
*/ */
- (id) deserialize:(id) data class:(NSString *) className error:(NSError**)error; - (id) deserialize:(id) data class:(NSString *) className error:(NSError**)error;

View File

@ -16,6 +16,7 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
@property (nonatomic, strong) NSNumberFormatter* numberFormatter; @property (nonatomic, strong) NSNumberFormatter* numberFormatter;
@property (nonatomic, strong) NSArray *primitiveTypes; @property (nonatomic, strong) NSArray *primitiveTypes;
@property (nonatomic, strong) NSArray *basicReturnTypes; @property (nonatomic, strong) NSArray *basicReturnTypes;
@property (nonatomic, strong) NSArray *dataReturnTypes;
@property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression; @property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression;
@property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression; @property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression;
@ -33,7 +34,9 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
formatter.numberStyle = NSNumberFormatterDecimalStyle; formatter.numberStyle = NSNumberFormatterDecimalStyle;
_numberFormatter = formatter; _numberFormatter = formatter;
_primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"];
_basicReturnTypes = @[@"NSObject", @"id", @"NSData"]; _basicReturnTypes = @[@"NSObject", @"id"];
_dataReturnTypes = @[@"NSData"];
_arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>" _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>"
options:NSRegularExpressionCaseInsensitive options:NSRegularExpressionCaseInsensitive
error:nil]; error:nil];
@ -53,23 +56,36 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
#pragma mark - Deserialize methods #pragma mark - Deserialize methods
- (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error { - (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error {
// return nil if data is nil or className is nil if (!data || !className) {
if (!data || !className || [data isKindOfClass:[NSNull class]]) {
return nil; return nil;
} }
// remove "*" from className, if ends with "*"
if ([className hasSuffix:@"*"]) { if ([className hasSuffix:@"*"]) {
className = [className substringToIndex:[className length] - 1]; className = [className substringToIndex:[className length] - 1];
} }
if([self.dataReturnTypes containsObject:className]) {
return data;
}
id jsonData = nil;
if([data isKindOfClass:[NSData class]]) {
jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:error];
} else {
jsonData = data;
}
if(!jsonData) {
jsonData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
} else if([jsonData isKindOfClass:[NSNull class]]) {
return nil;
}
// pure object // pure object
if ([self.basicReturnTypes containsObject:className]) { if ([self.basicReturnTypes containsObject:className]) {
return data; return jsonData;
} }
// primitives // primitives
if ([self.primitiveTypes containsObject:className]) { if ([self.primitiveTypes containsObject:className]) {
return [self deserializePrimitiveValue:data class:className error:error]; return [self deserializePrimitiveValue:jsonData class:className error:error];
} }
NSTextCheckingResult *match = nil; NSTextCheckingResult *match = nil;
@ -78,37 +94,37 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range]; match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range];
if (match) { if (match) {
NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]];
return [self deserializeArrayValue:data innerType:innerType error:error]; return [self deserializeArrayValue:jsonData innerType:innerType error:error];
} }
// list of primitives // list of primitives
match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range]; match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range];
if (match) { if (match) {
NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]];
return [self deserializeArrayValue:data innerType:innerType error:error]; return [self deserializeArrayValue:jsonData innerType:innerType error:error];
} }
// map // map
match = [self.dictPatExpression firstMatchInString:className options:0 range:range]; match = [self.dictPatExpression firstMatchInString:className options:0 range:range];
if (match) { if (match) {
NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]];
return [self deserializeDictionaryValue:data valueType:valueType error:error]; return [self deserializeDictionaryValue:jsonData valueType:valueType error:error];
} }
match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range]; match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range];
if (match) { if (match) {
NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]];
return [self deserializeDictionaryValue:data valueType:valueType error:error]; return [self deserializeDictionaryValue:jsonData valueType:valueType error:error];
} }
// model // model
Class ModelClass = NSClassFromString(className); Class ModelClass = NSClassFromString(className);
if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) {
return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; return [(JSONModel *) [ModelClass alloc] initWithDictionary:jsonData error:error];
} }
if(error) { if(error) {
*error = [self unknownResponseErrorWithExpectedType:className data:data]; *error = [self unknownResponseErrorWithExpectedType:className data:jsonData];
} }
return nil; return nil;
} }
@ -172,7 +188,7 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
- (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error { - (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error {
if ([className isEqualToString:@"NSString"]) { if ([className isEqualToString:@"NSString"]) {
return [NSString stringWithString:data]; return [NSString stringWithFormat:@"%@",data];
} }
else if ([className isEqualToString:@"NSDate"]) { else if ([className isEqualToString:@"NSDate"]) {
return [self deserializeDateValue:data error:error]; return [self deserializeDateValue:data error:error];

View File

@ -1,31 +1,22 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
extern NSString * SWGPercentEscapedStringFromString(NSString *string); extern NSString * SWGPercentEscapedStringFromString(NSString *string);
extern NSString * const kSWGApplicationJSONType;
@protocol SWGSanitizer <NSObject> @protocol SWGSanitizer <NSObject>
/** /**

View File

@ -3,6 +3,8 @@
#import "SWGQueryParamCollection.h" #import "SWGQueryParamCollection.h"
#import <ISO8601/ISO8601.h> #import <ISO8601/ISO8601.h>
NSString * const kSWGApplicationJSONType = @"application/json";
NSString * SWGPercentEscapedStringFromString(NSString *string) { NSString * SWGPercentEscapedStringFromString(NSString *string) {
static NSString * const kSWGCharactersGeneralDelimitersToEncode = @":#[]@"; static NSString * const kSWGCharactersGeneralDelimitersToEncode = @":#[]@";
static NSString * const kSWGCharactersSubDelimitersToEncode = @"!$&'()*+,;="; static NSString * const kSWGCharactersSubDelimitersToEncode = @"!$&'()*+,;=";
@ -43,8 +45,6 @@ NSString * SWGPercentEscapedStringFromString(NSString *string) {
@implementation SWGSanitizer @implementation SWGSanitizer
static NSString * kApplicationJSONType = @"application/json";
-(instancetype)init { -(instancetype)init {
self = [super init]; self = [super init];
if ( !self ) { if ( !self ) {
@ -141,7 +141,7 @@ static NSString * kApplicationJSONType = @"application/json";
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]]; NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
for (NSString *string in accepts) { for (NSString *string in accepts) {
if ([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0) { if ([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0) {
return kApplicationJSONType; return kSWGApplicationJSONType;
} }
[lowerAccepts addObject:[string lowercaseString]]; [lowerAccepts addObject:[string lowercaseString]];
} }
@ -153,12 +153,12 @@ static NSString * kApplicationJSONType = @"application/json";
*/ */
- (NSString *) selectHeaderContentType:(NSArray *)contentTypes { - (NSString *) selectHeaderContentType:(NSArray *)contentTypes {
if (contentTypes.count == 0) { if (contentTypes.count == 0) {
return kApplicationJSONType; return kSWGApplicationJSONType;
} }
NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]]; NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]];
for (NSString *string in contentTypes) { for (NSString *string in contentTypes) {
if([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0){ if([self.jsonHeaderTypeExpression matchesInString:string options:0 range:NSMakeRange(0, [string length])].count > 0){
return kApplicationJSONType; return kSWGApplicationJSONType;
} }
[lowerContentTypes addObject:[string lowercaseString]]; [lowerContentTypes addObject:[string lowercaseString]];
} }

View File

@ -2,37 +2,26 @@
#import "SWGObject.h" #import "SWGObject.h"
/** /**
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
* *
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@protocol SWGReturn @protocol SWGReturn
@end @end
@interface SWGReturn : SWGObject @interface SWGReturn : SWGObject
/* property description *_/ ' \" =end \\r\\n \\n \\r [optional] /* property description *_/ ' \" =end -- \\r\\n \\n \\r [optional]
*/ */
@property(nonatomic) NSNumber* _return; @property(nonatomic) NSNumber* _return;

View File

@ -17,7 +17,7 @@
* This method is used by `JSONModel`. * This method is used by `JSONModel`.
*/ */
+ (JSONKeyMapper *)keyMapper { + (JSONKeyMapper *)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"return": @"_return" }]; return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ @"_return": @"return" }];
} }
/** /**

View File

@ -1,28 +1,28 @@
# SWGFakeApi # SWGFakeApi
All URIs are relative to *https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r* All URIs are relative to *https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**testCodeInjectEndRnNR**](SWGFakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r [**testCodeInjectEndRnNR**](SWGFakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
# **testCodeInjectEndRnNR** # **testCodeInjectEndRnNR**
```objc ```objc
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR -(NSURLSessionTask*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
completionHandler: (void (^)(NSError* error)) handler; completionHandler: (void (^)(NSError* error)) handler;
``` ```
To test code injection *_/ ' \" =end \\r\\n \\n \\r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
### Example ### Example
```objc ```objc
NSString* testCodeInjectEndRnNR = @"testCodeInjectEndRnNR_example"; // To test code injection *_/ ' \" =end \\r\\n \\n \\r (optional) NSString* testCodeInjectEndRnNR = @"testCodeInjectEndRnNR_example"; // To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
SWGFakeApi*apiInstance = [[SWGFakeApi alloc] init]; SWGFakeApi*apiInstance = [[SWGFakeApi alloc] init];
// To test code injection *_/ ' \" =end \\r\\n \\n \\r // To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
[apiInstance testCodeInjectEndRnNRWithTestCodeInjectEndRnNR:testCodeInjectEndRnNR [apiInstance testCodeInjectEndRnNRWithTestCodeInjectEndRnNR:testCodeInjectEndRnNR
completionHandler: ^(NSError* error) { completionHandler: ^(NSError* error) {
if (error) { if (error) {
@ -35,7 +35,7 @@ SWGFakeApi*apiInstance = [[SWGFakeApi alloc] init];
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**testCodeInjectEndRnNR** | **NSString***| To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r | [optional] **testCodeInjectEndRnNR** | **NSString***| To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
### Return type ### Return type
@ -47,12 +47,8 @@ No authorization required
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json, */ ' =end - **Content-Type**: application/json, *_/ ' =end --
- **Accept**: application/json, *_/ ' =end --
- **Accept**: application/json, */ ' =end
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -3,7 +3,7 @@
## Properties ## Properties
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**_return** | **NSNumber*** | property description *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r | [optional] **_return** | **NSNumber*** | property description *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -6,8 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi
- API version: 1.0.0 - API version: 1.0.0
- Package version: - Package version:
- Build date: 2016-08-23T10:56:26.470+02:00 - Build package: io.swagger.codegen.languages.ObjcClientCodegen
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen
## Requirements ## Requirements
@ -56,7 +55,7 @@ Import the following:
## Recommendation ## Recommendation
It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue. It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issues.
## Getting Started ## Getting Started
@ -124,6 +123,12 @@ Class | Method | HTTP request | Description
## Documentation For Authorization ## Documentation For Authorization
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## petstore_auth ## petstore_auth
- **Type**: OAuth - **Type**: OAuth
@ -133,12 +138,6 @@ Class | Method | HTTP request | Description
- **write:pets**: modify pets in your account - **write:pets**: modify pets in your account
- **read:pets**: read your pets - **read:pets**: read your pets
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Author ## Author

View File

@ -22,7 +22,7 @@ Pod::Spec.new do |s|
s.framework = 'SystemConfiguration' s.framework = 'SystemConfiguration'
s.homepage = "https://github.com/swagger-api/swagger-codegen" s.homepage = "https://github.com/swagger-api/swagger-codegen"
s.license = "Apache License, Version 2.0" s.license = "Proprietary"
s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" } s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" }
s.author = { "Swagger" => "apiteam@swagger.io" } s.author = { "Swagger" => "apiteam@swagger.io" }

View File

@ -12,21 +12,10 @@
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGPetApi: NSObject <SWGApi> @interface SWGPetApi: NSObject <SWGApi>
extern NSString* kSWGPetApiErrorDomain; extern NSString* kSWGPetApiErrorDomain;
@ -61,7 +50,7 @@ extern NSInteger kSWGPetApiMissingParamErrorCode;
/// Finds Pets by status /// Finds Pets by status
/// Multiple status values can be provided with comma seperated strings /// Multiple status values can be provided with comma separated strings
/// ///
/// @param status Status values that need to be considered for filter (optional) (default to available) /// @param status Status values that need to be considered for filter (optional) (default to available)
/// ///
@ -74,7 +63,7 @@ extern NSInteger kSWGPetApiMissingParamErrorCode;
/// Finds Pets by tags /// Finds Pets by tags
/// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
/// ///
/// @param tags Tags to filter by (optional) /// @param tags Tags to filter by (optional)
/// ///

View File

@ -186,7 +186,7 @@ NSInteger kSWGPetApiMissingParamErrorCode = 234513;
/// ///
/// Finds Pets by status /// Finds Pets by status
/// Multiple status values can be provided with comma seperated strings /// Multiple status values can be provided with comma separated strings
/// @param status Status values that need to be considered for filter (optional, default to available) /// @param status Status values that need to be considered for filter (optional, default to available)
/// ///
/// @returns NSArray<SWGPet>* /// @returns NSArray<SWGPet>*
@ -247,7 +247,7 @@ NSInteger kSWGPetApiMissingParamErrorCode = 234513;
/// ///
/// Finds Pets by tags /// Finds Pets by tags
/// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
/// @param tags Tags to filter by (optional) /// @param tags Tags to filter by (optional)
/// ///
/// @returns NSArray<SWGPet>* /// @returns NSArray<SWGPet>*

View File

@ -12,21 +12,10 @@
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGStoreApi: NSObject <SWGApi> @interface SWGStoreApi: NSObject <SWGApi>
extern NSString* kSWGStoreApiErrorDomain; extern NSString* kSWGStoreApiErrorDomain;

View File

@ -12,21 +12,10 @@
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@interface SWGUserApi: NSObject <SWGApi> @interface SWGUserApi: NSObject <SWGApi>
extern NSString* kSWGUserApiErrorDomain; extern NSString* kSWGUserApiErrorDomain;

View File

@ -13,20 +13,9 @@
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
/** /**
* A key for `NSError` user info dictionaries. * A key for `NSError` user info dictionaries.
* *

View File

@ -89,7 +89,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
#pragma mark - Task Methods #pragma mark - Task Methods
- (NSURLSessionDataTask*) taskWithCompletionBlock: (NSURLRequest *)request completionBlock: (void (^)(id, NSError *))completionBlock { - (NSURLSessionDataTask*) taskWithCompletionBlock: (NSURLRequest *)request completionBlock: (void (^)(id, NSError *))completionBlock {
NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
SWGDebugLogResponse(response, responseObject,request,error); SWGDebugLogResponse(response, responseObject,request,error);
if(!error) { if(!error) {
@ -104,7 +104,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
completionBlock(nil, augmentedError); completionBlock(nil, augmentedError);
}]; }];
return task; return task;
} }
@ -135,7 +135,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
completionBlock(file, nil); completionBlock(file, nil);
}]; }];
return task; return task;
} }
@ -222,7 +222,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
[self postProcessRequest:request]; [self postProcessRequest:request];
NSURLSessionTask *task = nil; NSURLSessionTask *task = nil;
if ([self.downloadTaskResponseTypes containsObject:responseType]) { if ([self.downloadTaskResponseTypes containsObject:responseType]) {
@ -241,9 +241,9 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
completionBlock(response, error); completionBlock(response, error);
}]; }];
} }
[task resume]; [task resume];
return task; return task;
} }
@ -330,7 +330,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
id<SWGConfiguration> config = self.configuration; id<SWGConfiguration> config = self.configuration;
for (NSString *auth in authSettings) { for (NSString *auth in authSettings) {
NSDictionary *authSetting = config.authSettings[auth]; NSDictionary *authSetting = config.authSettings[auth];

View File

@ -12,20 +12,9 @@
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
static NSString * const kSWGAPIVersion = @"1.0.0"; static NSString * const kSWGAPIVersion = @"1.0.0";
@protocol SWGConfiguration <NSObject> @protocol SWGConfiguration <NSObject>

View File

@ -11,20 +11,9 @@
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually. * Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@class SWGApiClient; @class SWGApiClient;
@interface SWGDefaultConfiguration : NSObject <SWGConfiguration> @interface SWGDefaultConfiguration : NSObject <SWGConfiguration>
@ -117,7 +106,7 @@
/** /**
* Sets the prefix for API key * Sets the prefix for API key
* *
* @param apiKeyPrefix API key prefix. * @param prefix API key prefix.
* @param identifier API key identifier. * @param identifier API key identifier.
*/ */
- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier; - (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier;
@ -157,7 +146,7 @@
/** /**
* Removes header from defaultHeaders * Removes header from defaultHeaders
* *
* @param Header name. * @param key Header name.
*/ */
-(void) removeDefaultHeaderForKey:(NSString*)key; -(void) removeDefaultHeaderForKey:(NSString*)key;
@ -170,7 +159,7 @@
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key; -(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key;
/** /**
* @param Header key name. * @param key Header key name.
*/ */
-(NSString*) defaultHeaderForKey:(NSString*)key; -(NSString*) defaultHeaderForKey:(NSString*)key;

View File

@ -104,13 +104,6 @@
- (NSDictionary *) authSettings { - (NSDictionary *) authSettings {
return @{ return @{
@"petstore_auth":
@{
@"type": @"oauth",
@"in": @"header",
@"key": @"Authorization",
@"value": [self getAccessToken]
},
@"api_key": @"api_key":
@{ @{
@"type": @"api_key", @"type": @"api_key",
@ -118,6 +111,13 @@
@"key": @"api_key", @"key": @"api_key",
@"value": [self getApiKeyWithPrefix:@"api_key"] @"value": [self getApiKeyWithPrefix:@"api_key"]
}, },
@"petstore_auth":
@{
@"type": @"oauth",
@"in": @"header",
@"key": @"Authorization",
@"value": [self getAccessToken]
},
}; };
} }