Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bin/swift-petstore-promisekit.json
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"
}
31 changes: 31 additions & 0 deletions bin/swift-petstore-promisekit.sh
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
3 changes: 1 addition & 2 deletions bin/swift-petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"podSummary": "PetstoreClient",
"podHomepage": "https://github.com/swagger-api/swagger-codegen",
"podAuthors": "",
"projectName": "PetstoreClient",
"responseAs": "PromiseKit"
"projectName": "PetstoreClient"
}
Empty file modified bin/swift-petstore.sh
100755 → 100644
Empty file.
63 changes: 63 additions & 0 deletions samples/client/petstore/swift-promisekit/.gitignore
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
2 changes: 2 additions & 0 deletions samples/client/petstore/swift-promisekit/Cartfile
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 samples/client/petstore/swift-promisekit/PetstoreClient.podspec
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 => 'git@github.com: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
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
}

}
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
}

Loading