File tree Expand file tree Collapse file tree 6 files changed +265
-103
lines changed
modules/swagger-codegen/src/main/resources/objc
samples/client/petstore/objc
PetstoreClient/PetstoreClientTests Expand file tree Collapse file tree 6 files changed +265
-103
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,10 @@ static NSString * basePath = @"{{basePath}}";
129
129
if(bodyDictionary == nil) {
130
130
bodyDictionary = [[NSMutableArray alloc] init];
131
131
}
132
- [bodyDictionary addObject:{ {paramName} }];
133
- { {paramName} }.paramName = @"{ {baseName} }";
132
+ if({ {paramName} } != nil) {
133
+ [bodyDictionary addObject:{{paramName} }];
134
+ { {paramName} }.paramName = @"{ {baseName} }";
135
+ }
134
136
{ {/isFile} }
135
137
if(bodyDictionary == nil) {
136
138
bodyDictionary = [[NSMutableArray alloc] init];
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ - (void)testGetPetByTags {
154
154
}
155
155
156
156
- (void )testDeletePet {
157
- XCTestExpectation *expectation = [self expectationWithDescription: @" testGetPetById " ];
157
+ XCTestExpectation *expectation = [self expectationWithDescription: @" testDeletePet " ];
158
158
159
159
SWGPet* pet = [self createPet ];
160
160
@@ -181,6 +181,42 @@ - (void)testDeletePet {
181
181
[self waitForExpectationsWithTimeout: 10.0 handler: nil ];
182
182
}
183
183
184
+ - (void )testUploadFile {
185
+ XCTestExpectation *expectation = [self expectationWithDescription: @" testUploadFile" ];
186
+
187
+ NSString * str = @" teststring" ;
188
+ NSData * data = [str dataUsingEncoding: NSUTF8StringEncoding];
189
+
190
+ SWGFile * file = [[SWGFile alloc ] initWithNameData: @" myFile.txt" mimeType: @" text/plain" data: data];
191
+
192
+ [api uploadFileWithCompletionBlock: @1 additionalMetadata: @" special-metadata" file: file completionHandler: ^(NSError *error) {
193
+ if (error) {
194
+ // good
195
+ XCTFail (@" expected a failure" );
196
+
197
+ }
198
+ else {
199
+ [expectation fulfill ];
200
+ }
201
+ }];
202
+ [self waitForExpectationsWithTimeout: 10.0 handler: nil ];
203
+ }
204
+
205
+ - (void )TestUploadWithoutFile {
206
+ XCTestExpectation *expectation = [self expectationWithDescription: @" testUploadWithoutFile" ];
207
+
208
+ [api uploadFileWithCompletionBlock: @1 additionalMetadata: @" special-metadata" file: nil completionHandler: ^(NSError *error) {
209
+ if (error) {
210
+ XCTFail (@" failed to upload" );
211
+
212
+ }
213
+ else {
214
+ [expectation fulfill ];
215
+ }
216
+ }];
217
+ [self waitForExpectationsWithTimeout: 10.0 handler: nil ];
218
+ }
219
+
184
220
- (SWGPet*) createPet {
185
221
SWGPet * pet = [[SWGPet alloc ] init ];
186
222
pet._id = [[NSNumber alloc ] initWithLong: [[NSDate date ] timeIntervalSince1970 ]];
You can’t perform that action at this time.
0 commit comments