You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/faq-generators.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -477,6 +477,8 @@ Here is a working sample that put's together all of this.
477
477
478
478
### How do I migrate from the Swift 5 generator to the swift 6 generator?
479
479
480
+
- Change the generator to the new `swift6` generator, e.g. `openapi-generator generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g swift6 -o /tmp/test/`
481
+
- Check the `swift6`[URLSession](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/swift6/urlsessionLibrary) and [Alamofire](https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/swift6/alamofireLibrary) samples.
480
482
- The infrastructure files have been moved to a new directory called `Infrastructure`. Please delete the old ones.
481
483
- The `AnyCodable` dependency has been removed and replaced with a new enum called `JSONValue`, allowing you to use this generator without external dependencies.
482
484
- The `Combine` response is now deferred by default, meaning the request will only start when you begin listening to it. To restore the previous behavior, set the `combineDeferred` flag to `false`.
// Before making the request, we can validate if we have a bearer token to be able to make a request
104
-
BearerTokenHandler.refreshTokenIfDoesntExist {
105
-
106
-
// Here we make the request
107
-
super.execute(apiResponseQueue) { result in
108
-
109
-
switch result {
110
-
case .success:
111
-
// If we got a successful response, we send the response to the completion block
112
-
completion(result)
113
-
114
-
case let .failure(error):
115
-
116
-
// If we got a failure response, we will analyse the error to see what we should do with it
117
-
ifcase let ErrorResponse.error(_, data, response, error) = error {
118
-
119
-
// If the error is an ErrorResponse.error() we will analyse it to see if it's a 401, and if it's a 401, we will refresh the token and retry the request
// If the token was refreshed, it's because it was a 401 error, so we refreshed the token, and we are going to retry the request by calling self.execute()
128
-
self.execute(apiResponseQueue, completion)
129
-
} else {
130
-
// If the token was not refreshed, it's because it was not a 401 error, so we send the response to the completion block
131
-
completion(result)
132
-
}
133
-
}
134
-
} else {
135
-
// If it's an unknown error, we send the response to the completion block
136
-
completion(result)
137
-
}
138
-
139
-
}
140
-
}
141
-
}
142
-
143
-
return requestTask
144
-
}
145
-
}
146
-
147
-
class BearerDecodableRequestBuilder<T: Decodable>: URLSessionDecodableRequestBuilder<T> {
// If the token was refreshed, it's because it was a 401 error, so we refreshed the token, and we are going to retry the request by calling self.execute()
175
-
self.execute(apiResponseQueue, completion)
176
-
} else {
177
-
// If the token was not refreshed, it's because it was not a 401 error, so we send the response to the completion block
178
-
completion(result)
179
-
}
180
-
}
181
-
} else {
182
-
// If it's an unknown error, we send the response to the completion block
0 commit comments