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

@@ -2,46 +2,35 @@
#import "SWGApi.h"
/**
* 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
* 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 --
*
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =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
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* 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>
extern NSString* kSWGFakeApiErrorDomain;
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
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
-(NSURLSessionTask*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
completionHandler: (void (^)(NSError* error)) handler;

View File

@@ -1,10 +1,11 @@
#import "SWGFakeApi.h"
#import "SWGQueryParamCollection.h"
#import "SWGApiClient.h"
@interface SWGFakeApi ()
@property (nonatomic, strong) NSMutableDictionary *defaultHeaders;
@property (nonatomic, strong, readwrite) NSMutableDictionary *mutableDefaultHeaders;
@end
@@ -18,64 +19,43 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
#pragma mark - Initialize methods
- (instancetype) init {
self = [super init];
if (self) {
SWGConfiguration *config = [SWGConfiguration sharedConfig];
if (config.apiClient == nil) {
config.apiClient = [[SWGApiClient alloc] init];
}
_apiClient = config.apiClient;
_defaultHeaders = [NSMutableDictionary dictionary];
}
return self;
return [self initWithApiClient:[SWGApiClient sharedClient]];
}
- (id) initWithApiClient:(SWGApiClient *)apiClient {
-(instancetype) initWithApiClient:(SWGApiClient *)apiClient {
self = [super init];
if (self) {
_apiClient = apiClient;
_defaultHeaders = [NSMutableDictionary dictionary];
_mutableDefaultHeaders = [NSMutableDictionary dictionary];
}
return self;
}
#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 {
return self.defaultHeaders[key];
}
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
[self setDefaultHeaderValue:value forKey:key];
return self.mutableDefaultHeaders[key];
}
-(void) setDefaultHeaderValue:(NSString*) value forKey:(NSString*)key {
[self.defaultHeaders setValue:value forKey:key];
[self.mutableDefaultHeaders setValue:value forKey:key];
}
-(NSUInteger) requestQueueSize {
return [SWGApiClient requestQueueSize];
-(NSDictionary *)defaultHeaders {
return self.mutableDefaultHeaders;
}
#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
///
-(NSNumber*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
-(NSURLSessionTask*) testCodeInjectEndRnNRWithTestCodeInjectEndRnNR: (NSString*) testCodeInjectEndRnNR
completionHandler: (void (^)(NSError* error)) handler {
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/fake"];
@@ -88,9 +68,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.apiClient.configuration.defaultHeaders];
[headerParams addEntriesFromDictionary:self.defaultHeaders];
// 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) {
headerParams[@"Accept"] = acceptHeader;
}
@@ -99,9 +77,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
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
NSArray *authSettings = @[];
@@ -110,7 +86,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
if (testCodeInjectEndRnNR) {
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
formParams[@"test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r"] = testCodeInjectEndRnNR;
}
return [self.apiClient requestWithPath: resourcePath
@@ -129,8 +105,7 @@ NSInteger kSWGFakeApiMissingParamErrorCode = 234513;
if(handler) {
handler(error);
}
handler(error);
}
}];
}