forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OpenAPITools#2931 from Edubits/swift-sample-withou…
…t-promisekit [Swift] Add sample/tests for Swift client without PromiseKit
- Loading branch information
Showing
177 changed files
with
12,029 additions
and
1,437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"podSummary": "PetstoreClient", | ||
"podHomepage": "https://github.com/swagger-api/swagger-codegen", | ||
"podAuthors": "", | ||
"projectName": "PetstoreClient", | ||
"responseAs": "PromiseKit" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
SCRIPT="$0" | ||
|
||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
if [ ! -d "${APP_DIR}" ]; then | ||
APP_DIR=`dirname "$SCRIPT"`/.. | ||
APP_DIR=`cd "${APP_DIR}"; pwd` | ||
fi | ||
|
||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" | ||
|
||
if [ ! -f "$executable" ] | ||
then | ||
mvn clean package | ||
fi | ||
|
||
# if you've executed sbt assembly previously it will use that instead. | ||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" | ||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-promisekit.json -o samples/client/petstore/swift-promisekit" | ||
|
||
java $JAVA_OPTS -jar $executable $ags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## Build generated | ||
build/ | ||
DerivedData | ||
|
||
## Various settings | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
|
||
## Other | ||
*.xccheckout | ||
*.moved-aside | ||
*.xcuserstate | ||
*.xcscmblueprint | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
*.ipa | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md | ||
|
||
fastlane/report.xml | ||
fastlane/screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github "Alamofire/Alamofire" >= 3.1.0 | ||
github "mxcl/PromiseKit" >=1.5.3 |
14 changes: 14 additions & 0 deletions
14
samples/client/petstore/swift-promisekit/PetstoreClient.podspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'PetstoreClient' | ||
s.ios.deployment_target = '8.0' | ||
s.osx.deployment_target = '10.9' | ||
s.version = '0.0.1' | ||
s.source = { :git => '[email protected]:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' } | ||
s.authors = | ||
s.license = 'Apache License, Version 2.0' | ||
s.homepage = 'https://github.com/swagger-api/swagger-codegen' | ||
s.summary = 'PetstoreClient' | ||
s.source_files = 'PetstoreClient/Classes/Swaggers/**/*.swift' | ||
s.dependency 'PromiseKit', '~> 3.1.1' | ||
s.dependency 'Alamofire', '~> 3.1.5' | ||
end |
39 changes: 39 additions & 0 deletions
39
samples/client/petstore/swift-promisekit/PetstoreClient/Classes/Swaggers/APIHelper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// APIHelper.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
class APIHelper { | ||
static func rejectNil(source: [String:AnyObject?]) -> [String:AnyObject]? { | ||
var destination = [String:AnyObject]() | ||
for (key, nillableValue) in source { | ||
if let value: AnyObject = nillableValue { | ||
destination[key] = value | ||
} | ||
} | ||
|
||
if destination.isEmpty { | ||
return nil | ||
} | ||
return destination | ||
} | ||
|
||
static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject] { | ||
var destination = [String:AnyObject]() | ||
let theTrue = NSNumber(bool: true) | ||
let theFalse = NSNumber(bool: false) | ||
if (source != nil) { | ||
for (key, value) in source! { | ||
switch value { | ||
case let x where x === theTrue || x === theFalse: | ||
destination[key] = "\(value as! Bool)" | ||
default: | ||
destination[key] = value | ||
} | ||
} | ||
} | ||
return destination | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
samples/client/petstore/swift-promisekit/PetstoreClient/Classes/Swaggers/APIs.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// APIs.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
import Foundation | ||
|
||
public class PetstoreClientAPI { | ||
public static var basePath = "http://petstore.swagger.io/v2" | ||
public static var credential: NSURLCredential? | ||
public static var customHeaders: [String:String] = [:] | ||
static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() | ||
} | ||
|
||
public class APIBase { | ||
func toParameters(encodable: JSONEncodable?) -> [String: AnyObject]? { | ||
let encoded: AnyObject? = encodable?.encodeToJSON() | ||
|
||
if encoded! is [AnyObject] { | ||
var dictionary = [String:AnyObject]() | ||
for (index, item) in (encoded as! [AnyObject]).enumerate() { | ||
dictionary["\(index)"] = item | ||
} | ||
return dictionary | ||
} else { | ||
return encoded as? [String:AnyObject] | ||
} | ||
} | ||
} | ||
|
||
public class RequestBuilder<T> { | ||
var credential: NSURLCredential? | ||
var headers: [String:String] = [:] | ||
let parameters: [String:AnyObject]? | ||
let isBody: Bool | ||
let method: String | ||
let URLString: String | ||
|
||
required public init(method: String, URLString: String, parameters: [String:AnyObject]?, isBody: Bool) { | ||
self.method = method | ||
self.URLString = URLString | ||
self.parameters = parameters | ||
self.isBody = isBody | ||
|
||
addHeaders(PetstoreClientAPI.customHeaders) | ||
} | ||
|
||
public func addHeaders(aHeaders:[String:String]) { | ||
for (header, value) in aHeaders { | ||
headers[header] = value | ||
} | ||
} | ||
|
||
public func execute(completion: (response: Response<T>?, error: ErrorType?) -> Void) { } | ||
|
||
public func addHeader(name name: String, value: String) -> Self { | ||
if !value.isEmpty { | ||
headers[name] = value | ||
} | ||
return self | ||
} | ||
|
||
public func addCredential() -> Self { | ||
self.credential = PetstoreClientAPI.credential | ||
return self | ||
} | ||
} | ||
|
||
protocol RequestBuilderFactory { | ||
func getBuilder<T>() -> RequestBuilder<T>.Type | ||
} | ||
|
Oops, something went wrong.