mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Merge pull request #2129 from wing328/objc_binary_fix
[ObjC][Swift] fix objc `binary` mapping, add objc,swift to CI tests
This commit is contained in:
commit
e72abc01e9
@ -84,6 +84,9 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("List", "NSArray");
|
typeMapping.put("List", "NSArray");
|
||||||
typeMapping.put("object", "NSObject");
|
typeMapping.put("object", "NSObject");
|
||||||
typeMapping.put("file", "NSURL");
|
typeMapping.put("file", "NSURL");
|
||||||
|
//TODO binary should be mapped to byte array
|
||||||
|
// mapped to String as a workaround
|
||||||
|
typeMapping.put("binary", "NSString");
|
||||||
|
|
||||||
|
|
||||||
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
|
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
|
||||||
|
17
pom.xml
17
pom.xml
@ -399,7 +399,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</activation>
|
</activation>
|
||||||
<modules>
|
<modules>
|
||||||
<module>samples/client/petstore/objc</module>
|
<module>samples/client/petstore/objc/SwaggerClientTests</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>swift-client</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>swift</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/client/petstore/swift/SwaggerClientTests</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
@ -459,9 +471,10 @@
|
|||||||
<module>samples/client/petstore/javascript</module>
|
<module>samples/client/petstore/javascript</module>
|
||||||
<module>samples/client/petstore/scala</module>
|
<module>samples/client/petstore/scala</module>
|
||||||
<module>samples/server/petstore/spring-mvc</module>
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
<!--module>samples/client/petstore/objc</module-->
|
|
||||||
<module>samples/client/petstore/ruby</module>
|
<module>samples/client/petstore/ruby</module>
|
||||||
<module>samples/server/petstore/jaxrs</module>
|
<module>samples/server/petstore/jaxrs</module>
|
||||||
|
<!--module>samples/client/petstore/objc/SwaggerClientTests</module-->
|
||||||
|
<!--module>samples/client/petstore/swift/SwaggerClientTests</module-->
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
14
samples/client/petstore/csharp/SwaggerClientTest/mono-nunit.sh
Executable file
14
samples/client/petstore/csharp/SwaggerClientTest/mono-nunit.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
wget -nc https://nuget.org/nuget.exe;
|
||||||
|
mozroots --import --sync
|
||||||
|
|
||||||
|
# remove bin/Debug/SwaggerClientTest.dll
|
||||||
|
rm bin/Debug/SwaggerClientTest.dll 2> /dev/null
|
||||||
|
|
||||||
|
# install NUnit runners via NuGet
|
||||||
|
mono nuget.exe install NUnit.Runners -Version 2.6.4 -OutputDirectory testrunner
|
||||||
|
|
||||||
|
# build the solution and run the unit test
|
||||||
|
xbuild SwaggerClientTest.sln && \
|
||||||
|
mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe bin/Debug/SwaggerClientTest.dll
|
||||||
|
|
56
samples/client/petstore/csharp/SwaggerClientTest/pom.xml
Normal file
56
samples/client/petstore/csharp/SwaggerClientTest/pom.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.wordnik</groupId>
|
||||||
|
<artifactId>CsharpPetstoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>C# Swagger Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<!--execution>
|
||||||
|
<id>bundle-install</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>bundle</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution-->
|
||||||
|
<execution>
|
||||||
|
<id>mono-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>mono-nunit.sh</executable>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -149,5 +149,35 @@
|
|||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// Fake endpoint to test byte array return by 'Find pet by ID'
|
||||||
|
/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
///
|
||||||
|
/// @param petId ID of pet that needs to be fetched
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @return NSString*
|
||||||
|
-(NSNumber*) getPetByIdWithByteArrayWithCompletionBlock :(NSNumber*) petId
|
||||||
|
|
||||||
|
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @param body Pet object in the form of byte array
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @return
|
||||||
|
-(NSNumber*) addPetUsingByteArrayWithCompletionBlock :(NSString*) body
|
||||||
|
|
||||||
|
|
||||||
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -758,6 +758,170 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
|
queryParams: queryParams
|
||||||
|
formParams: formParams
|
||||||
|
files: files
|
||||||
|
body: bodyParam
|
||||||
|
headerParams: headerParams
|
||||||
|
authSettings: authSettings
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
responseType: nil
|
||||||
|
completionBlock: ^(id data, NSError *error) {
|
||||||
|
completionBlock(error);
|
||||||
|
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fake endpoint to test byte array return by 'Find pet by ID'
|
||||||
|
/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
/// @param petId ID of pet that needs to be fetched
|
||||||
|
///
|
||||||
|
/// @returns NSString*
|
||||||
|
///
|
||||||
|
-(NSNumber*) getPetByIdWithByteArrayWithCompletionBlock: (NSNumber*) petId
|
||||||
|
|
||||||
|
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// verify the required parameter 'petId' is set
|
||||||
|
if (petId == nil) {
|
||||||
|
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `getPetByIdWithByteArray`"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?testing_byte_array=true"];
|
||||||
|
|
||||||
|
// remove format in URL if needed
|
||||||
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (petId != nil) {
|
||||||
|
pathParams[@"petId"] = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
|
// Authentication setting
|
||||||
|
NSArray *authSettings = @[@"api_key"];
|
||||||
|
|
||||||
|
id bodyParam = nil;
|
||||||
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||||
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
|
queryParams: queryParams
|
||||||
|
formParams: formParams
|
||||||
|
files: files
|
||||||
|
body: bodyParam
|
||||||
|
headerParams: headerParams
|
||||||
|
authSettings: authSettings
|
||||||
|
requestContentType: requestContentType
|
||||||
|
responseContentType: responseContentType
|
||||||
|
responseType: @"NSString*"
|
||||||
|
completionBlock: ^(id data, NSError *error) {
|
||||||
|
|
||||||
|
completionBlock((NSString*)data, error);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||||
|
///
|
||||||
|
/// @param body Pet object in the form of byte array
|
||||||
|
///
|
||||||
|
/// @returns void
|
||||||
|
///
|
||||||
|
-(NSNumber*) addPetUsingByteArrayWithCompletionBlock: (NSString*) body
|
||||||
|
|
||||||
|
|
||||||
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet?testing_byte_array=true"];
|
||||||
|
|
||||||
|
// remove format in URL if needed
|
||||||
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
|
||||||
|
|
||||||
|
// Authentication setting
|
||||||
|
NSArray *authSettings = @[@"petstore_auth"];
|
||||||
|
|
||||||
|
id bodyParam = nil;
|
||||||
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||||
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
bodyParam = body;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
pathParams: pathParams
|
pathParams: pathParams
|
||||||
|
@ -71,20 +71,20 @@ extension PetstoreClientAPI {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -93,21 +93,21 @@ extension PetstoreClientAPI {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -116,7 +116,7 @@ extension PetstoreClientAPI {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter status: (query) Status values that need to be considered for filter
|
- parameter status: (query) Status values that need to be considered for filter
|
||||||
|
|
||||||
@ -145,20 +145,20 @@ extension PetstoreClientAPI {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -167,21 +167,21 @@ extension PetstoreClientAPI {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -190,7 +190,7 @@ extension PetstoreClientAPI {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter tags: (query) Tags to filter by
|
- parameter tags: (query) Tags to filter by
|
||||||
|
|
||||||
@ -219,20 +219,20 @@ extension PetstoreClientAPI {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
}, contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
}}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -241,21 +241,21 @@ extension PetstoreClientAPI {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
}, contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
}}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -264,7 +264,7 @@ extension PetstoreClientAPI {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
@ -374,5 +374,59 @@ extension PetstoreClientAPI {
|
|||||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false)
|
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Fake endpoint to test byte array return by 'Find pet by ID'
|
||||||
|
|
||||||
|
- GET /pet/{petId}?testing_byte_array=true
|
||||||
|
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key
|
||||||
|
- name: api_key
|
||||||
|
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
|
||||||
|
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
|
||||||
|
|
||||||
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
- returns: RequestBuilder<String>
|
||||||
|
*/
|
||||||
|
public class func getPetByIdWithByteArray(petId petId: Int) -> RequestBuilder<String> {
|
||||||
|
var path = "/pet/{petId}?testing_byte_array=true"
|
||||||
|
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
|
||||||
|
let nillableParameters: [String:AnyObject?] = [:]
|
||||||
|
let parameters = APIHelper.rejectNil(nillableParameters)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||||
|
|
||||||
|
- POST /pet?testing_byte_array=true
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
|
||||||
|
- parameter body: (body) Pet object in the form of byte array
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
public class func addPetUsingByteArray(body body: String?) -> RequestBuilder<Void> {
|
||||||
|
let path = "/pet?testing_byte_array=true"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
|
||||||
|
let parameters = body?.encodeToJSON() as? [String:AnyObject]
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ extension PetstoreClientAPI {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"key" : 123
|
"key" : 123
|
||||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"key" : 123
|
"key" : 123
|
||||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||||
|
|
||||||
- returns: RequestBuilder<[String:Int]>
|
- returns: RequestBuilder<[String:Int]>
|
||||||
*/
|
*/
|
||||||
@ -48,36 +48,36 @@ extension PetstoreClientAPI {
|
|||||||
|
|
||||||
- POST /store/order
|
- POST /store/order
|
||||||
-
|
-
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2016-02-07T13:55:23.709+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2016-02-13T08:19:01.757+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2016-02-07T05:55:23.712Z</shipDate>
|
<shipDate>2016-02-13T16:19:01.763Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2016-02-07T13:55:23.709+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2016-02-13T08:19:01.757+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2016-02-07T05:55:23.712Z</shipDate>
|
<shipDate>2016-02-13T16:19:01.763Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter body: (body) order placed for purchasing the pet
|
- parameter body: (body) order placed for purchasing the pet
|
||||||
|
|
||||||
@ -100,36 +100,36 @@ extension PetstoreClientAPI {
|
|||||||
|
|
||||||
- GET /store/order/{orderId}
|
- GET /store/order/{orderId}
|
||||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2016-02-07T13:55:23.713+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2016-02-13T08:19:01.765+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2016-02-07T05:55:23.713Z</shipDate>
|
<shipDate>2016-02-13T16:19:01.766Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2016-02-07T13:55:23.713+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2016-02-13T08:19:01.765+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2016-02-07T05:55:23.713Z</shipDate>
|
<shipDate>2016-02-13T16:19:01.766Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ extension PetstoreClientAPI {
|
|||||||
|
|
||||||
- GET /user/login
|
- GET /user/login
|
||||||
-
|
-
|
||||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter username: (query) The user name for login
|
- parameter username: (query) The user name for login
|
||||||
- parameter password: (query) The password for login in clear text
|
- parameter password: (query) The password for login in clear text
|
||||||
@ -134,7 +134,7 @@ extension PetstoreClientAPI {
|
|||||||
|
|
||||||
- GET /user/{username}
|
- GET /user/{username}
|
||||||
-
|
-
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"id" : 1,
|
"id" : 1,
|
||||||
"username" : "johnp",
|
"username" : "johnp",
|
||||||
"firstName" : "John",
|
"firstName" : "John",
|
||||||
@ -143,7 +143,7 @@ extension PetstoreClientAPI {
|
|||||||
"password" : "-secret-",
|
"password" : "-secret-",
|
||||||
"phone" : "0123456789",
|
"phone" : "0123456789",
|
||||||
"userStatus" : 0
|
"userStatus" : 0
|
||||||
}}]
|
}, contentType=application/json}]
|
||||||
|
|
||||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||||
|
|
||||||
|
@ -109,13 +109,19 @@ class Decoders {
|
|||||||
}
|
}
|
||||||
// Decoder for NSDate
|
// Decoder for NSDate
|
||||||
Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in
|
Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in
|
||||||
let sourceString = source as! String
|
if let sourceString = source as? String {
|
||||||
for formatter in formatters {
|
for formatter in formatters {
|
||||||
if let date = formatter.dateFromString(sourceString) {
|
if let date = formatter.dateFromString(sourceString) {
|
||||||
return date
|
return date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
fatalError("formatter failed to parse \(sourceString)")
|
if let sourceInt = source as? Int {
|
||||||
|
// treat as a java date
|
||||||
|
return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) )
|
||||||
|
}
|
||||||
|
fatalError("formatter failed to parse \(source)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder for [User]
|
// Decoder for [User]
|
||||||
|
Loading…
Reference in New Issue
Block a user