Skip to content

Commit da711e9

Browse files
fix: stop implicitly coercing warning in Swift snippet generator (Kong#195)
* swift/nsurlsession adds `as Any` to print for error * adds OVERWRITE_EVERYTHING to ease fixture snapshot resetting * updates fixtures Co-authored-by: Dimitri Mitropoulos <[email protected]>
1 parent d4bebe4 commit da711e9

23 files changed

Lines changed: 45 additions & 32 deletions

src/targets/swift/nsurlsession/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const nsurlsession: Client<NsurlsessionOptions> = {
103103
2,
104104
);
105105
push('if (error != nil) {', 2);
106-
push('print(error)', 3);
106+
push('print(error as Any)', 3);
107107
push('}', 2);
108108
push('body += "; filename=\\"\\(filename)\\"\\r\\n"', 2);
109109
push('body += "Content-Type: \\(contentType)\\r\\n\\r\\n"', 2);
@@ -151,7 +151,7 @@ export const nsurlsession: Client<NsurlsessionOptions> = {
151151
'let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in',
152152
);
153153
push('if (error != nil) {', 1);
154-
push('print(error)', 2);
154+
push('print(error as Any)', 2);
155155
push('} else {', 1); // Casting the NSURLResponse to NSHTTPURLResponse so the user can see the status .
156156
push('let httpResponse = response as? HTTPURLResponse', 2);
157157
push('print(httpResponse)', 2);

src/targets/swift/nsurlsession/fixtures/application-form-encoded.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ request.httpBody = postData as Data
1515
let session = URLSession.shared
1616
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1717
if (error != nil) {
18-
print(error)
18+
print(error as Any)
1919
} else {
2020
let httpResponse = response as? HTTPURLResponse
2121
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/application-json.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ request.httpBody = postData as Data
2222
let session = URLSession.shared
2323
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
2424
if (error != nil) {
25-
print(error)
25+
print(error as Any)
2626
} else {
2727
let httpResponse = response as? HTTPURLResponse
2828
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/cookies.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ request.allHTTPHeaderFields = headers
1111
let session = URLSession.shared
1212
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1313
if (error != nil) {
14-
print(error)
14+
print(error as Any)
1515
} else {
1616
let httpResponse = response as? HTTPURLResponse
1717
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/custom-method.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ request.httpMethod = "PROPFIND"
88
let session = URLSession.shared
99
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1010
if (error != nil) {
11-
print(error)
11+
print(error as Any)
1212
} else {
1313
let httpResponse = response as? HTTPURLResponse
1414
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/full.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ request.httpBody = postData as Data
1818
let session = URLSession.shared
1919
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
2020
if (error != nil) {
21-
print(error)
21+
print(error as Any)
2222
} else {
2323
let httpResponse = response as? HTTPURLResponse
2424
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/headers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ request.allHTTPHeaderFields = headers
1515
let session = URLSession.shared
1616
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1717
if (error != nil) {
18-
print(error)
18+
print(error as Any)
1919
} else {
2020
let httpResponse = response as? HTTPURLResponse
2121
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/https.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ request.httpMethod = "GET"
88
let session = URLSession.shared
99
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1010
if (error != nil) {
11-
print(error)
11+
print(error as Any)
1212
} else {
1313
let httpResponse = response as? HTTPURLResponse
1414
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/indent-option.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ request.httpMethod = "GET"
88
let session = URLSession.shared
99
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1010
if (error != nil) {
11-
print(error)
11+
print(error as Any)
1212
} else {
1313
let httpResponse = response as? HTTPURLResponse
1414
print(httpResponse)

src/targets/swift/nsurlsession/fixtures/json-null-value.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ request.httpBody = postData as Data
1515
let session = URLSession.shared
1616
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
1717
if (error != nil) {
18-
print(error)
18+
print(error as Any)
1919
} else {
2020
let httpResponse = response as? HTTPURLResponse
2121
print(httpResponse)

0 commit comments

Comments
 (0)