forked from loafle/openapi-generator-original
[swift6] add samples that test upload files as data (#19780)
* [swift6] upload files as data * [swift6] upload files as data * [swift6] upload files as data * [swift6] upload files as data * [swift6] upload files as data * [swift6] upload files as data
This commit is contained in:
parent
66cde8b5f4
commit
8e10dd7be7
@ -6,6 +6,7 @@ templateDir: modules/openapi-generator/src/main/resources/swift6
|
||||
additionalProperties:
|
||||
responseAs: AsyncAwait,Combine,Result,PromiseKit,RxSwift,ObjcBlock
|
||||
apiStaticMethod: false
|
||||
mapFileBinaryToData: true
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
|
@ -11,5 +11,6 @@ additionalProperties:
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
useSPMFileStructure: true
|
||||
mapFileBinaryToData: true
|
||||
useClasses: true
|
||||
swiftUseApiNamespace: true
|
||||
|
@ -30,7 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|library|Library template (sub-template) to use|<dl><dt>**urlsession**</dt><dd>[DEFAULT] HTTP client: URLSession</dd><dt>**alamofire**</dt><dd>HTTP client: Alamofire</dd><dt>**vapor**</dt><dd>HTTP client: Vapor</dd></dl>|urlsession|
|
||||
|mapFileBinaryToData|[WARNING] This option will be removed and enabled by default in the future once we've enhanced the code to work with `Data` in all the different situations. Map File and Binary to Data (default: false)| |false|
|
||||
|mapFileBinaryToData|Map File and Binary to Data (default: false)| |false|
|
||||
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
|
||||
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
|
||||
|oneOfUnknownDefaultCase|Add unknownDefault case to oneOf enum (default: false)| |false|
|
||||
|
@ -338,7 +338,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
cliOptions.add(new CliOption(MAP_FILE_BINARY_TO_DATA,
|
||||
"[WARNING] This option will be removed and enabled by default in the future once we've enhanced the code to work with `Data` in all the different situations. Map File and Binary to Data (default: false)")
|
||||
"Map File and Binary to Data (default: false)")
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
cliOptions.add(new CliOption(USE_CUSTOM_DATE_WITHOUT_TIME,
|
||||
|
@ -1034,7 +1034,7 @@ open class FakeAPI {
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@discardableResult
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @Sendable @escaping (_ data: Void?, _ error: Error?) -> Void) -> RequestTask {
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @Sendable @escaping (_ data: Void?, _ error: Error?) -> Void) -> RequestTask {
|
||||
return testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
@ -1064,7 +1064,7 @@ open class FakeAPI {
|
||||
- parameter callback: (form) None (optional)
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Promise<Void> {
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { result in
|
||||
switch result {
|
||||
@ -1096,7 +1096,7 @@ open class FakeAPI {
|
||||
- parameter callback: (form) None (optional)
|
||||
- returns: Observable<Void>
|
||||
*/
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Observable<Void> {
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Observable<Void> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
let requestTask = self.testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { result in
|
||||
switch result {
|
||||
@ -1135,7 +1135,7 @@ open class FakeAPI {
|
||||
*/
|
||||
#if canImport(Combine)
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> AnyPublisher<Void, Error> {
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> AnyPublisher<Void, Error> {
|
||||
let requestBuilder = testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return Deferred { Future<Void, Error> { promise in
|
||||
@ -1178,7 +1178,7 @@ open class FakeAPI {
|
||||
- returns: Void
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) async throws(ErrorResponse) {
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) async throws(ErrorResponse) {
|
||||
return try await testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute().body
|
||||
}
|
||||
|
||||
@ -1202,7 +1202,7 @@ open class FakeAPI {
|
||||
- parameter completion: completion handler to receive the result
|
||||
*/
|
||||
@discardableResult
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @Sendable @escaping (_ result: Swift.Result<Void, ErrorResponse>) -> Void) -> RequestTask {
|
||||
open func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @Sendable @escaping (_ result: Swift.Result<Void, ErrorResponse>) -> Void) -> RequestTask {
|
||||
return testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
@ -1237,7 +1237,7 @@ open class FakeAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
open func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake"
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
|
@ -1134,7 +1134,7 @@ open class PetAPI {
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@discardableResult
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
return uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
@ -1153,7 +1153,7 @@ open class PetAPI {
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- returns: Promise<ApiResponse>
|
||||
*/
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> Promise<ApiResponse> {
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) -> Promise<ApiResponse> {
|
||||
let deferred = Promise<ApiResponse>.pending()
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { result in
|
||||
switch result {
|
||||
@ -1174,7 +1174,7 @@ open class PetAPI {
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- returns: Observable<ApiResponse>
|
||||
*/
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> Observable<ApiResponse> {
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) -> Observable<ApiResponse> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
let requestTask = self.uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { result in
|
||||
switch result {
|
||||
@ -1202,7 +1202,7 @@ open class PetAPI {
|
||||
*/
|
||||
#if canImport(Combine)
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> AnyPublisher<ApiResponse, Error> {
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) -> AnyPublisher<ApiResponse, Error> {
|
||||
let requestBuilder = uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return Deferred { Future<ApiResponse, Error> { promise in
|
||||
@ -1234,7 +1234,7 @@ open class PetAPI {
|
||||
- returns: ApiResponse
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) async throws(ErrorResponse) -> ApiResponse {
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) async throws(ErrorResponse) -> ApiResponse {
|
||||
return try await uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute().body
|
||||
}
|
||||
|
||||
@ -1247,7 +1247,7 @@ open class PetAPI {
|
||||
- parameter completion: completion handler to receive the result
|
||||
*/
|
||||
@discardableResult
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @Sendable @escaping (_ result: Swift.Result<ApiResponse, ErrorResponse>) -> Void) -> RequestTask {
|
||||
open func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil, completion: @Sendable @escaping (_ result: Swift.Result<ApiResponse, ErrorResponse>) -> Void) -> RequestTask {
|
||||
return uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
@ -1270,7 +1270,7 @@ open class PetAPI {
|
||||
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
|
||||
open func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) -> RequestBuilder<ApiResponse> {
|
||||
var localVariablePath = "/pet/{petId}/uploadImage"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
@ -1306,7 +1306,7 @@ open class PetAPI {
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@discardableResult
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
return uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
@ -1325,7 +1325,7 @@ open class PetAPI {
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- returns: Promise<ApiResponse>
|
||||
*/
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> Promise<ApiResponse> {
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) -> Promise<ApiResponse> {
|
||||
let deferred = Promise<ApiResponse>.pending()
|
||||
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { result in
|
||||
switch result {
|
||||
@ -1346,7 +1346,7 @@ open class PetAPI {
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- returns: Observable<ApiResponse>
|
||||
*/
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> Observable<ApiResponse> {
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) -> Observable<ApiResponse> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
let requestTask = self.uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { result in
|
||||
switch result {
|
||||
@ -1374,7 +1374,7 @@ open class PetAPI {
|
||||
*/
|
||||
#if canImport(Combine)
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> AnyPublisher<ApiResponse, Error> {
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) -> AnyPublisher<ApiResponse, Error> {
|
||||
let requestBuilder = uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata)
|
||||
let requestTask = requestBuilder.requestTask
|
||||
return Deferred { Future<ApiResponse, Error> { promise in
|
||||
@ -1406,7 +1406,7 @@ open class PetAPI {
|
||||
- returns: ApiResponse
|
||||
*/
|
||||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) async throws(ErrorResponse) -> ApiResponse {
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) async throws(ErrorResponse) -> ApiResponse {
|
||||
return try await uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute().body
|
||||
}
|
||||
|
||||
@ -1419,7 +1419,7 @@ open class PetAPI {
|
||||
- parameter completion: completion handler to receive the result
|
||||
*/
|
||||
@discardableResult
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @Sendable @escaping (_ result: Swift.Result<ApiResponse, ErrorResponse>) -> Void) -> RequestTask {
|
||||
open func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil, completion: @Sendable @escaping (_ result: Swift.Result<ApiResponse, ErrorResponse>) -> Void) -> RequestTask {
|
||||
return uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
@ -1442,7 +1442,7 @@ open class PetAPI {
|
||||
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> RequestBuilder<ApiResponse> {
|
||||
open func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) -> RequestBuilder<ApiResponse> {
|
||||
var localVariablePath = "/fake/{petId}/uploadImageWithRequiredFile"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
|
@ -24,13 +24,13 @@ public struct FormatTest: Codable, JSONEncodable, Hashable {
|
||||
public var double: Double?
|
||||
public var string: String?
|
||||
public var byte: Data
|
||||
public var binary: URL?
|
||||
public var binary: Data?
|
||||
public var date: Date
|
||||
public var dateTime: Date?
|
||||
public var uuid: UUID?
|
||||
public var password: String
|
||||
|
||||
public init(integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: URL? = nil, date: Date, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
|
||||
public init(integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: Date, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
|
||||
self.integer = integer
|
||||
self.int32 = int32
|
||||
self.int64 = int64
|
||||
|
@ -52,21 +52,16 @@ class PetAPITests: XCTestCase {
|
||||
}
|
||||
|
||||
func test3UploadFile() async throws {
|
||||
let imageName = UUID().uuidString + ".png"
|
||||
|
||||
guard
|
||||
let image = UIImage(color: .red, size: CGSize(width: 10, height: 10)),
|
||||
let imageURL = FileUtils.saveImage(imageName: imageName, image: image)
|
||||
let imageData = image.pngData()
|
||||
else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
do {
|
||||
let _ = try await PetAPI().uploadFile(petId: 1000, additionalMetadata: "additionalMetadata", file: imageURL)
|
||||
|
||||
FileUtils.deleteFile(fileURL: imageURL)
|
||||
let _ = try await PetAPI().uploadFile(petId: 1000, additionalMetadata: "additionalMetadata", file: imageData)
|
||||
} catch {
|
||||
FileUtils.deleteFile(fileURL: imageURL)
|
||||
XCTFail("error uploading file")
|
||||
}
|
||||
}
|
||||
|
@ -357,8 +357,8 @@ No authorization required
|
||||
|
||||
# **testEndpointParameters**
|
||||
```swift
|
||||
open class func testEndpointParameters( number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Promise<Void>
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Observable<Void>
|
||||
open class func testEndpointParameters( number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Promise<Void>
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Observable<Void>
|
||||
```
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@ -379,7 +379,7 @@ let int32 = 987 // Int | None (optional)
|
||||
let int64 = 987 // Int64 | None (optional)
|
||||
let float = 987 // Float | None (optional)
|
||||
let string = "string_example" // String | None (optional)
|
||||
let binary = URL(string: "https://example.com")! // URL | None (optional)
|
||||
let binary = Data([9, 8, 7]) // Data | None (optional)
|
||||
let date = Date() // Date | None (optional)
|
||||
let dateTime = Date() // Date | None (optional)
|
||||
let password = "password_example" // String | None (optional)
|
||||
@ -409,7 +409,7 @@ Name | Type | Description | Notes
|
||||
**int64** | **Int64** | None | [optional]
|
||||
**float** | **Float** | None | [optional]
|
||||
**string** | **String** | None | [optional]
|
||||
**binary** | **URL** | None | [optional]
|
||||
**binary** | **Data** | None | [optional]
|
||||
**date** | **Date** | None | [optional]
|
||||
**dateTime** | **Date** | None | [optional]
|
||||
**password** | **String** | None | [optional]
|
||||
|
@ -11,7 +11,7 @@ Name | Type | Description | Notes
|
||||
**double** | **Double** | | [optional]
|
||||
**string** | **String** | | [optional]
|
||||
**byte** | **Data** | |
|
||||
**binary** | **URL** | | [optional]
|
||||
**binary** | **Data** | | [optional]
|
||||
**date** | **Date** | |
|
||||
**dateTime** | **Date** | | [optional]
|
||||
**uuid** | **UUID** | | [optional]
|
||||
|
@ -358,8 +358,8 @@ Void (empty response body)
|
||||
|
||||
# **uploadFile**
|
||||
```swift
|
||||
open class func uploadFile( petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> Promise<ApiResponse>
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> Observable<ApiResponse>
|
||||
open class func uploadFile( petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) -> Promise<ApiResponse>
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil) -> Observable<ApiResponse>
|
||||
```
|
||||
|
||||
uploads an image
|
||||
@ -371,7 +371,7 @@ import PetstoreClient
|
||||
|
||||
let petId = 987 // Int64 | ID of pet to update
|
||||
let additionalMetadata = "additionalMetadata_example" // String | Additional data to pass to server (optional)
|
||||
let file = URL(string: "https://example.com")! // URL | file to upload (optional)
|
||||
let file = Data([9, 8, 7]) // Data | file to upload (optional)
|
||||
|
||||
// uploads an image
|
||||
PetAPI.uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file).then {
|
||||
@ -390,7 +390,7 @@ Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **Int64** | ID of pet to update |
|
||||
**additionalMetadata** | **String** | Additional data to pass to server | [optional]
|
||||
**file** | **URL** | file to upload | [optional]
|
||||
**file** | **Data** | file to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
@ -409,8 +409,8 @@ Name | Type | Description | Notes
|
||||
|
||||
# **uploadFileWithRequiredFile**
|
||||
```swift
|
||||
open class func uploadFileWithRequiredFile( petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> Promise<ApiResponse>
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> Observable<ApiResponse>
|
||||
open class func uploadFileWithRequiredFile( petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) -> Promise<ApiResponse>
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil) -> Observable<ApiResponse>
|
||||
```
|
||||
|
||||
uploads an image (required)
|
||||
@ -421,7 +421,7 @@ uploads an image (required)
|
||||
import PetstoreClient
|
||||
|
||||
let petId = 987 // Int64 | ID of pet to update
|
||||
let requiredFile = URL(string: "https://example.com")! // URL | file to upload
|
||||
let requiredFile = Data([9, 8, 7]) // Data | file to upload
|
||||
let additionalMetadata = "additionalMetadata_example" // String | Additional data to pass to server (optional)
|
||||
|
||||
// uploads an image (required)
|
||||
@ -440,7 +440,7 @@ PetAPI.uploadFileWithRequiredFile(petId: petId, requiredFile: requiredFile, addi
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **Int64** | ID of pet to update |
|
||||
**requiredFile** | **URL** | file to upload |
|
||||
**requiredFile** | **Data** | file to upload |
|
||||
**additionalMetadata** | **String** | Additional data to pass to server | [optional]
|
||||
|
||||
### Return type
|
||||
|
@ -347,7 +347,7 @@ open class FakeAPI {
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@discardableResult
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared, completion: @Sendable @escaping (_ data: Void?, _ error: Error?) -> Void) -> RequestTask {
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared, completion: @Sendable @escaping (_ data: Void?, _ error: Error?) -> Void) -> RequestTask {
|
||||
return testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case .success:
|
||||
@ -383,7 +383,7 @@ open class FakeAPI {
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<Void> {
|
||||
let localVariablePath = "/fake"
|
||||
let localVariableURLString = openAPIClient.basePath + localVariablePath
|
||||
let localVariableFormParams: [String: Any?] = [
|
||||
|
@ -402,7 +402,7 @@ open class PetAPI {
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@discardableResult
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
return uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
@ -426,7 +426,7 @@ open class PetAPI {
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<ApiResponse> {
|
||||
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<ApiResponse> {
|
||||
var localVariablePath = "/pet/{petId}/uploadImage"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
@ -463,7 +463,7 @@ open class PetAPI {
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@discardableResult
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared, completion: @Sendable @escaping (_ data: ApiResponse?, _ error: Error?) -> Void) -> RequestTask {
|
||||
return uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata, openAPIClient: openAPIClient).execute { result in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
@ -487,7 +487,7 @@ open class PetAPI {
|
||||
- parameter openAPIClient: The OpenAPIClient that contains the configuration for the http request.
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<ApiResponse> {
|
||||
open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil, openAPIClient: OpenAPIClient = OpenAPIClient.shared) -> RequestBuilder<ApiResponse> {
|
||||
var localVariablePath = "/fake/{petId}/uploadImageWithRequiredFile"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(petId))"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
|
@ -29,13 +29,13 @@ public final class FormatTest: Codable, JSONEncodable, Hashable {
|
||||
public var double: Double?
|
||||
public var string: String?
|
||||
public var byte: Data
|
||||
public var binary: URL?
|
||||
public var binary: Data?
|
||||
public var date: Date
|
||||
public var dateTime: Date?
|
||||
public var uuid: UUID?
|
||||
public var password: String
|
||||
|
||||
public init(integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: URL? = nil, date: Date, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
|
||||
public init(integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: Date, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
|
||||
self.integer = integer
|
||||
self.int32 = int32
|
||||
self.int64 = int64
|
||||
|
@ -66,23 +66,19 @@ class PetAPITests: XCTestCase {
|
||||
func test3UploadFile() {
|
||||
let expectation = self.expectation(description: "testUploadFile")
|
||||
|
||||
let imageName = UUID().uuidString + ".png"
|
||||
|
||||
guard
|
||||
let image = UIImage(color: .red, size: CGSize(width: 10, height: 10)),
|
||||
let imageURL = FileUtils.saveImage(imageName: imageName, image: image)
|
||||
let imageData = image.pngData()
|
||||
else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
PetstoreClientAPI.PetAPI.uploadFile(petId: 1000, additionalMetadata: "additionalMetadata", file: imageURL) { (_, error) in
|
||||
PetstoreClientAPI.PetAPI.uploadFile(petId: 1000, additionalMetadata: "additionalMetadata", file: imageData) { (_, error) in
|
||||
guard error == nil else {
|
||||
FileUtils.deleteFile(fileURL: imageURL)
|
||||
XCTFail("error uploading file")
|
||||
return
|
||||
}
|
||||
|
||||
FileUtils.deleteFile(fileURL: imageURL)
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ No authorization required
|
||||
|
||||
# **testEndpointParameters**
|
||||
```swift
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping (_ data: Void?, _ error: Error?) -> Void)
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping (_ data: Void?, _ error: Error?) -> Void)
|
||||
```
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@ -385,7 +385,7 @@ let int32 = 987 // Int | None (optional)
|
||||
let int64 = 987 // Int64 | None (optional)
|
||||
let float = 987 // Float | None (optional)
|
||||
let string = "string_example" // String | None (optional)
|
||||
let binary = URL(string: "https://example.com")! // URL | None (optional)
|
||||
let binary = Data([9, 8, 7]) // Data | None (optional)
|
||||
let date = Date() // Date | None (optional)
|
||||
let dateTime = Date() // Date | None (optional)
|
||||
let password = "password_example" // String | None (optional)
|
||||
@ -417,7 +417,7 @@ Name | Type | Description | Notes
|
||||
**int64** | **Int64** | None | [optional]
|
||||
**float** | **Float** | None | [optional]
|
||||
**string** | **String** | None | [optional]
|
||||
**binary** | **URL** | None | [optional]
|
||||
**binary** | **Data** | None | [optional]
|
||||
**date** | **Date** | None | [optional]
|
||||
**dateTime** | **Date** | None | [optional]
|
||||
**password** | **String** | None | [optional]
|
||||
|
@ -11,7 +11,7 @@ Name | Type | Description | Notes
|
||||
**double** | **Double** | | [optional]
|
||||
**string** | **String** | | [optional]
|
||||
**byte** | **Data** | |
|
||||
**binary** | **URL** | | [optional]
|
||||
**binary** | **Data** | | [optional]
|
||||
**date** | **Date** | |
|
||||
**dateTime** | **Date** | | [optional]
|
||||
**uuid** | **UUID** | | [optional]
|
||||
|
@ -365,7 +365,7 @@ Void (empty response body)
|
||||
|
||||
# **uploadFile**
|
||||
```swift
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping (_ data: ApiResponse?, _ error: Error?) -> Void)
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: Data? = nil, completion: @escaping (_ data: ApiResponse?, _ error: Error?) -> Void)
|
||||
```
|
||||
|
||||
uploads an image
|
||||
@ -377,7 +377,7 @@ import PetstoreClient
|
||||
|
||||
let petId = 987 // Int64 | ID of pet to update
|
||||
let additionalMetadata = "additionalMetadata_example" // String | Additional data to pass to server (optional)
|
||||
let file = URL(string: "https://example.com")! // URL | file to upload (optional)
|
||||
let file = Data([9, 8, 7]) // Data | file to upload (optional)
|
||||
|
||||
// uploads an image
|
||||
PetAPI.uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file) { (response, error) in
|
||||
@ -398,7 +398,7 @@ Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **Int64** | ID of pet to update |
|
||||
**additionalMetadata** | **String** | Additional data to pass to server | [optional]
|
||||
**file** | **URL** | file to upload | [optional]
|
||||
**file** | **Data** | file to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
@ -417,7 +417,7 @@ Name | Type | Description | Notes
|
||||
|
||||
# **uploadFileWithRequiredFile**
|
||||
```swift
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping (_ data: ApiResponse?, _ error: Error?) -> Void)
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: Data, additionalMetadata: String? = nil, completion: @escaping (_ data: ApiResponse?, _ error: Error?) -> Void)
|
||||
```
|
||||
|
||||
uploads an image (required)
|
||||
@ -428,7 +428,7 @@ uploads an image (required)
|
||||
import PetstoreClient
|
||||
|
||||
let petId = 987 // Int64 | ID of pet to update
|
||||
let requiredFile = URL(string: "https://example.com")! // URL | file to upload
|
||||
let requiredFile = Data([9, 8, 7]) // Data | file to upload
|
||||
let additionalMetadata = "additionalMetadata_example" // String | Additional data to pass to server (optional)
|
||||
|
||||
// uploads an image (required)
|
||||
@ -449,7 +449,7 @@ PetAPI.uploadFileWithRequiredFile(petId: petId, requiredFile: requiredFile, addi
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **Int64** | ID of pet to update |
|
||||
**requiredFile** | **URL** | file to upload |
|
||||
**requiredFile** | **Data** | file to upload |
|
||||
**additionalMetadata** | **String** | Additional data to pass to server | [optional]
|
||||
|
||||
### Return type
|
||||
|
Loading…
x
Reference in New Issue
Block a user