Fixes for swift4 language (#6116)

* Fix build error in Xcode 9 beta 3, as .compact is no longer defined

* Add test schema for Swift 4 and associated script and config files

* Add test app for swift4Test.json schema

* Make integer, Integer, int, and Int32 types map to Swift Int type instead of Int32 type

* Add CodingKeys to model template, which allows us to serialize/deserialize variable names that are different than property names

* Make updates to Swift 4 test schema

* Fixes for unit test app for swift4Test.json Swift 4 test schema
This commit is contained in:
ehyche
2017-07-20 03:45:09 -04:00
committed by wing328
parent bca35f6645
commit 2be2ee080b
96 changed files with 13391 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -0,0 +1,42 @@
//
// TestClientAppTests.swift
// TestClientAppTests
//
// Created by Eric Hyche on 7/18/17.
// Copyright © 2017 Swagger Codegen. All rights reserved.
//
import XCTest
import TestClient
@testable import TestClientApp
class TestClientAppTests: XCTestCase {
func testWhenVariableNameIsDifferentFromPropertyName() {
// This tests to make sure that the swift4 language can handle when
// we have property names which map to variable names that are not the same.
// This can happen when we have things like snake_case property names,
// or when we have property names which may be Swift 4 reserved words.
let jsonData = """
{
"example_name": "Test example name",
"for": "Some reason"
}
""".data(using: .utf8)!
let decodedResult = CodableHelper.decode(VariableNameTest.self, from: jsonData)
XCTAssertNil(decodedResult.error, "Got an error decoding VariableNameTest, error=\(String(describing: decodedResult.error))")
guard let variableNameTest = decodedResult.decodableObj else {
XCTFail("Did not get an VariableNameTest decoded object")
return
}
XCTAssertTrue(variableNameTest.exampleName == "Test example name", "Did not decode snake_case property correctly.")
XCTAssertTrue(variableNameTest._for == "Some reason", "Did not decode property name that is a reserved word correctly.")
}
}