Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[swift] add petstore for non public api
  • Loading branch information
4brunu committed Nov 20, 2019
commit eefe9c786df000471c124822034b7316e65d34bd
1 change: 1 addition & 0 deletions bin/swift4-petstore-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
./bin/swift4-petstore-rxswift.sh
./bin/swift4-petstore-objcCompatible.sh
./bin/swift4-petstore-unwrapRequired.sh
./bin/swift4-petstore-nonPublicApi.sh
7 changes: 7 additions & 0 deletions bin/swift4-petstore-nonPublicApi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"podSummary": "PetstoreClient",
"podHomepage": "https://github.com/openapitools/openapi-generator",
"podAuthors": "",
"projectName": "PetstoreClient",
"nonPublicApi": true
}
42 changes: 42 additions & 0 deletions bin/swift4-petstore-nonPublicApi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"

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/openapi-generator-cli/target/openapi-generator-cli.jar"

if [ ! -f "$executable" ]
then
mvn -B clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-nonPublicApi.json -o samples/client/petstore/swift4/nonPublicApi $@"

java $JAVA_OPTS -jar $executable $ags

if type "xcodegen" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/nonPublicApi
xcodegen generate
fi

if type "swiftlint" > /dev/null 2>&1; then
cd samples/client/petstore/swift4/nonPublicApi
swiftlint autocorrect
fi
6 changes: 3 additions & 3 deletions samples/client/petstore/swift4/default/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ playground.xcworkspace
# 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/
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
Carthage/Checkouts
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.0-SNAPSHOT
4.2.2-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Base,
en,
);
mainGroup = 5FBA6AE5F64CD737F88B4565;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
onlyGenerateCoverageForSpecifiedTargets = "NO"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct APIHelper {

public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] {
return source.reduce(into: [String: String]()) { (result, item) in
if let collection = item.value as? Array<Any?> {
if let collection = item.value as? [Any?] {
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
} else if let value: Any = item.value {
result[item.key] = "\(value)"
Expand All @@ -46,15 +46,15 @@ public struct APIHelper {
}

public static func mapValueToPathItem(_ source: Any) -> Any {
if let collection = source as? Array<Any?> {
if let collection = source as? [Any?] {
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
}
return source
}

public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? {
let destination = source.filter({ $0.value != nil}).reduce(into: [URLQueryItem]()) { (result, item) in
if let collection = item.value as? Array<Any?> {
if let collection = item.value as? [Any?] {
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
result.append(URLQueryItem(name: item.key, value: value))
} else if let value = item.value {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// JSONDataEncoding.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation
import Alamofire

public struct JSONDataEncoding: ParameterEncoding {

// MARK: Properties

private static let jsonDataKey = "jsonData"

// MARK: Encoding

/// Creates a URL request by encoding parameters and applying them onto an existing request.
///
/// - parameter urlRequest: The request to have parameters applied.
/// - parameter parameters: The parameters to apply. This should have a single key/value
/// pair with "jsonData" as the key and a Data object as the value.
///
/// - throws: An `Error` if the encoding process encounters an error.
///
/// - returns: The encoded request.
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
var urlRequest = try urlRequest.asURLRequest()

guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else {
return urlRequest
}

if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
}

urlRequest.httpBody = jsonData

return urlRequest
}

public static func encodingParameters(jsonData: Data?) -> Parameters? {
var returnedParams: Parameters?
if let jsonData = jsonData, !jsonData.isEmpty {
var params = Parameters()
params[jsonDataKey] = jsonData
returnedParams = params
}
return returnedParams
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// JSONEncodingHelper.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation
import Alamofire

open class JSONEncodingHelper {

open class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
var params: Parameters?

// Encode the Encodable object
if let encodableObj = encodableObj {
let encodeResult = CodableHelper.encode(encodableObj, prettyPrint: true)
if encodeResult.error == nil {
params = JSONDataEncoding.encodingParameters(jsonData: encodeResult.data)
}
}

return params
}

open class func encodingParameters(forEncodableObject encodableObj: Any?) -> Parameters? {
var params: Parameters?

if let encodableObj = encodableObj {
do {
let data = try JSONSerialization.data(withJSONObject: encodableObj, options: .prettyPrinted)
params = JSONDataEncoding.encodingParameters(jsonData: data)
} catch {
print(error)
return nil
}
}

return params
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Animal.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public struct Animal: Codable {

public var className: String
public var color: String? = "red"

public init(className: String, color: String?) {
self.className = className
self.color = color
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// AnimalFarm.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public typealias AnimalFarm = [Animal]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ApiResponse.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public struct ApiResponse: Codable {

public var code: Int?
public var type: String?
public var message: String?

public init(code: Int?, type: String?, message: String?) {
self.code = code
self.type = type
self.message = message
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ArrayOfArrayOfNumberOnly.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public struct ArrayOfArrayOfNumberOnly: Codable {

public var arrayArrayNumber: [[Double]]?

public init(arrayArrayNumber: [[Double]]?) {
self.arrayArrayNumber = arrayArrayNumber
}

public enum CodingKeys: String, CodingKey {
case arrayArrayNumber = "ArrayArrayNumber"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ArrayOfNumberOnly.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public struct ArrayOfNumberOnly: Codable {

public var arrayNumber: [Double]?

public init(arrayNumber: [Double]?) {
self.arrayNumber = arrayNumber
}

public enum CodingKeys: String, CodingKey {
case arrayNumber = "ArrayNumber"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// ArrayTest.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public struct ArrayTest: Codable {

public var arrayOfString: [String]?
public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]?

public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
self.arrayOfString = arrayOfString
self.arrayArrayOfInteger = arrayArrayOfInteger
self.arrayArrayOfModel = arrayArrayOfModel
}

public enum CodingKeys: String, CodingKey {
case arrayOfString = "array_of_string"
case arrayArrayOfInteger = "array_array_of_integer"
case arrayArrayOfModel = "array_array_of_model"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Capitalization.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

public struct Capitalization: Codable {

public var smallCamel: String?
public var capitalCamel: String?
public var smallSnake: String?
public var capitalSnake: String?
public var sCAETHFlowPoints: String?
/** Name of the pet */
public var ATT_NAME: String?

public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
self.smallCamel = smallCamel
self.capitalCamel = capitalCamel
self.smallSnake = smallSnake
self.capitalSnake = capitalSnake
self.sCAETHFlowPoints = sCAETHFlowPoints
self.ATT_NAME = ATT_NAME
}

public enum CodingKeys: String, CodingKey {
case smallCamel
case capitalCamel = "CapitalCamel"
case smallSnake = "small_Snake"
case capitalSnake = "Capital_Snake"
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
case ATT_NAME
}

}
Loading