From beaf1fc7aa1c6f81dd47fa8a9b668b8ea1bb928b Mon Sep 17 00:00:00 2001 From: Tony Wang Date: Thu, 25 Aug 2016 19:34:12 +0800 Subject: [PATCH] fix #3477, add RxSwift support for Swift (#3490) * fix #3477, add RxSwift support for Swift * make the SwaggerClient scheme shared --- bin/swift-petstore-all.sh | 4 + bin/swift-petstore-rxswift.json | 7 + bin/swift-petstore-rxswift.sh | 31 + .../codegen/languages/SwiftCodegen.java | 6 +- .../main/resources/swift/Cartfile.mustache | 3 +- .../src/main/resources/swift/Podspec.mustache | 3 +- .../src/main/resources/swift/api.mustache | 25 +- .../client/petstore/swift/rxswift/.gitignore | 63 + .../swift/rxswift/.swagger-codegen-ignore | 23 + .../client/petstore/swift/rxswift/Cartfile | 2 + samples/client/petstore/swift/rxswift/LICENSE | 201 ++ .../swift/rxswift/PetstoreClient.podspec | 14 + .../Classes/Swaggers/APIHelper.swift | 40 + .../Classes/Swaggers/APIs.swift | 75 + .../Classes/Swaggers/APIs/PetAPI.swift | 608 ++++++ .../Classes/Swaggers/APIs/StoreAPI.swift | 302 +++ .../Classes/Swaggers/APIs/UserAPI.swift | 498 +++++ .../Swaggers/AlamofireImplementations.swift | 148 ++ .../Classes/Swaggers/Extensions.swift | 84 + .../Classes/Swaggers/Models.swift | 224 +++ .../Classes/Swaggers/Models/Category.swift | 25 + .../Classes/Swaggers/Models/Order.swift | 39 + .../Classes/Swaggers/Models/Pet.swift | 39 + .../Classes/Swaggers/Models/Tag.swift | 25 + .../Classes/Swaggers/Models/User.swift | 38 + .../swift/rxswift/SwaggerClientTests/Podfile | 10 + .../SwaggerClientTests/Pods/Alamofire/LICENSE | 19 + .../Pods/Alamofire/README.md | 1149 +++++++++++ .../Pods/Alamofire/Source/Alamofire.swift | 368 ++++ .../Pods/Alamofire/Source/Download.swift | 244 +++ .../Pods/Alamofire/Source/Error.swift | 66 + .../Pods/Alamofire/Source/Manager.swift | 693 +++++++ .../Alamofire/Source/MultipartFormData.swift | 669 +++++++ .../Alamofire/Source/ParameterEncoding.swift | 251 +++ .../Pods/Alamofire/Source/Request.swift | 538 +++++ .../Pods/Alamofire/Source/Response.swift | 83 + .../Source/ResponseSerialization.swift | 355 ++++ .../Pods/Alamofire/Source/Result.swift | 101 + .../Alamofire/Source/ServerTrustPolicy.swift | 302 +++ .../Pods/Alamofire/Source/Stream.swift | 180 ++ .../Pods/Alamofire/Source/Upload.swift | 372 ++++ .../Pods/Alamofire/Source/Validation.swift | 189 ++ .../PetstoreClient.podspec.json | 25 + .../SwaggerClientTests/Pods/Manifest.lock | 22 + .../Pods/Pods.xcodeproj/project.pbxproj | 1731 +++++++++++++++++ .../Pods/RxSwift/LICENSE.md | 9 + .../SwaggerClientTests/Pods/RxSwift/README.md | 180 ++ .../Pods/RxSwift/RxSwift/AnyObserver.swift | 75 + .../Pods/RxSwift/RxSwift/Cancelable.swift | 19 + .../RxSwift/Concurrency/AsyncLock.swift | 104 + .../RxSwift/RxSwift/Concurrency/Lock.swift | 107 + .../RxSwift/Concurrency/LockOwnerType.swift | 23 + .../Concurrency/SynchronizedDisposeType.swift | 20 + .../Concurrency/SynchronizedOnType.swift | 20 + .../SynchronizedSubscribeType.swift | 20 + .../SynchronizedUnsubscribeType.swift | 15 + .../RxSwift/ConnectableObservableType.swift | 21 + .../RxSwift/RxSwift/DataStructures/Bag.swift | 328 ++++ .../DataStructures/InfiniteSequence.swift | 30 + .../DataStructures/PriorityQueue.swift | 120 ++ .../RxSwift/DataStructures/Queue.swift | 168 ++ .../Pods/RxSwift/RxSwift/Disposable.swift | 15 + .../Disposables/AnonymousDisposable.swift | 54 + .../Disposables/BinaryDisposable.swift | 54 + .../Disposables/BooleanDisposable.swift | 45 + .../Disposables/CompositeDisposable.swift | 135 ++ .../RxSwift/Disposables/DisposeBag.swift | 94 + .../RxSwift/Disposables/DisposeBase.swift | 26 + .../RxSwift/Disposables/NAryDisposable.swift | 10 + .../RxSwift/Disposables/NopDisposable.swift | 32 + .../Disposables/RefCountDisposable.swift | 127 ++ .../Disposables/ScheduledDisposable.swift | 58 + .../Disposables/SerialDisposable.swift | 85 + .../SingleAssignmentDisposable.swift | 89 + .../StableCompositeDisposable.swift | 15 + .../Disposables/SubscriptionDisposable.swift | 23 + .../Pods/RxSwift/RxSwift/Errors.swift | 72 + .../Pods/RxSwift/RxSwift/Event.swift | 66 + .../RxSwift/Extensions/String+Rx.swift | 26 + .../RxSwift/ImmediateSchedulerType.swift | 40 + .../RxSwift/Observable+Extensions.swift | 128 ++ .../Pods/RxSwift/RxSwift/Observable.swift | 51 + .../RxSwift/ObservableConvertibleType.swift | 26 + .../Pods/RxSwift/RxSwift/ObservableType.swift | 57 + .../Observables/Implementations/AddRef.swift | 47 + .../Observables/Implementations/Amb.swift | 122 ++ .../Implementations/AnonymousObservable.swift | 56 + .../Observables/Implementations/Buffer.swift | 119 ++ .../Observables/Implementations/Catch.swift | 162 ++ .../CombineLatest+CollectionType.swift | 125 ++ .../Implementations/CombineLatest+arity.swift | 724 +++++++ .../Implementations/CombineLatest.swift | 134 ++ .../Observables/Implementations/Concat.swift | 63 + .../ConnectableObservable.swift | 96 + .../Observables/Implementations/Debug.swift | 77 + .../Implementations/Deferred.swift | 61 + .../Implementations/DelaySubscription.swift | 52 + .../DistinctUntilChanged.swift | 70 + .../Observables/Implementations/Do.swift | 53 + .../Implementations/ElementAt.swift | 79 + .../Observables/Implementations/Empty.swift | 16 + .../Observables/Implementations/Error.swift | 22 + .../Observables/Implementations/Filter.swift | 60 + .../Implementations/Generate.swift | 71 + .../Observables/Implementations/Just.swift | 61 + .../Observables/Implementations/Map.swift | 140 ++ .../Observables/Implementations/Merge.swift | 423 ++++ .../Implementations/Multicast.swift | 71 + .../Observables/Implementations/Never.swift | 15 + .../Implementations/ObserveOn.swift | 133 ++ .../ObserveOnSerialDispatchQueue.swift | 81 + .../Implementations/Producer.swift | 30 + .../Observables/Implementations/Range.swift | 59 + .../Observables/Implementations/Reduce.swift | 74 + .../Implementations/RefCount.swift | 84 + .../Observables/Implementations/Repeat.swift | 44 + .../Implementations/RetryWhen.swift | 150 ++ .../Observables/Implementations/Sample.swift | 129 ++ .../Observables/Implementations/Scan.swift | 64 + .../Implementations/Sequence.swift | 58 + .../Implementations/ShareReplay1.swift | 101 + .../ShareReplay1WhileConnected.swift | 92 + .../Implementations/SingleAsync.swift | 76 + .../Observables/Implementations/Sink.swift | 57 + .../Observables/Implementations/Skip.swift | 128 ++ .../Implementations/SkipUntil.swift | 125 ++ .../Implementations/SkipWhile.swift | 115 ++ .../Implementations/StartWith.swift | 28 + .../Implementations/SubscribeOn.swift | 60 + .../Observables/Implementations/Switch.swift | 193 ++ .../Observables/Implementations/Take.swift | 144 ++ .../Implementations/TakeLast.swift | 63 + .../Implementations/TakeUntil.swift | 120 ++ .../Implementations/TakeWhile.swift | 132 ++ .../Implementations/Throttle.swift | 104 + .../Observables/Implementations/Timeout.swift | 120 ++ .../Observables/Implementations/Timer.swift | 72 + .../Observables/Implementations/ToArray.swift | 50 + .../Observables/Implementations/Using.swift | 78 + .../Observables/Implementations/Window.swift | 152 ++ .../Implementations/WithLatestFrom.swift | 122 ++ .../Implementations/Zip+CollectionType.swift | 137 ++ .../Implementations/Zip+arity.swift | 829 ++++++++ .../Observables/Implementations/Zip.swift | 157 ++ .../Observables/Observable+Aggregate.swift | 64 + .../Observables/Observable+Binding.swift | 190 ++ .../Observables/Observable+Concurrency.swift | 62 + .../Observables/Observable+Creation.swift | 219 +++ .../Observables/Observable+Debug.swift | 28 + .../Observables/Observable+Multiple.swift | 330 ++++ .../Observables/Observable+Single.swift | 258 +++ ...Observable+StandardSequenceOperators.swift | 323 +++ .../RxSwift/Observables/Observable+Time.swift | 274 +++ .../Pods/RxSwift/RxSwift/ObserverType.swift | 56 + .../RxSwift/Observers/AnonymousObserver.swift | 34 + .../RxSwift/Observers/ObserverBase.swift | 39 + .../RxSwift/Observers/TailRecursiveSink.swift | 151 ++ .../RxSwift/Platform/Platform.Darwin.swift | 45 + .../RxSwift/Platform/Platform.Linux.swift | 222 +++ .../Pods/RxSwift/RxSwift/Rx.swift | 42 + .../Pods/RxSwift/RxSwift/RxMutableBox.swift | 37 + .../Pods/RxSwift/RxSwift/SchedulerType.swift | 78 + .../ConcurrentDispatchQueueScheduler.swift | 147 ++ .../Schedulers/ConcurrentMainScheduler.swift | 90 + .../Schedulers/CurrentThreadScheduler.swift | 147 ++ .../DispatchQueueSchedulerQOS.swift | 54 + .../Schedulers/HistoricalScheduler.swift | 25 + .../HistoricalSchedulerTimeConverter.swift | 83 + .../Schedulers/ImmediateScheduler.swift | 39 + .../Internal/AnonymousInvocable.swift | 21 + .../Internal/InvocableScheduledItem.swift | 24 + .../Schedulers/Internal/InvocableType.swift | 19 + .../Schedulers/Internal/ScheduledItem.swift | 37 + .../Internal/ScheduledItemType.swift | 15 + .../RxSwift/Schedulers/MainScheduler.swift | 73 + .../Schedulers/OperationQueueScheduler.swift | 57 + .../Schedulers/RecursiveScheduler.swift | 193 ++ .../SchedulerServices+Emulation.swift | 63 + .../SerialDispatchQueueScheduler.swift | 184 ++ .../Schedulers/VirtualTimeConverterType.swift | 115 ++ .../Schedulers/VirtualTimeScheduler.swift | 292 +++ .../RxSwift/Subjects/BehaviorSubject.swift | 161 ++ .../RxSwift/Subjects/PublishSubject.swift | 139 ++ .../RxSwift/Subjects/ReplaySubject.swift | 263 +++ .../RxSwift/Subjects/SubjectType.swift | 29 + .../RxSwift/RxSwift/Subjects/Variable.swift | 69 + .../Alamofire/Alamofire-dummy.m | 5 + .../Alamofire/Alamofire-prefix.pch | 3 + .../Alamofire/Alamofire-umbrella.h | 5 + .../Alamofire/Alamofire.modulemap | 6 + .../Alamofire/Alamofire.xcconfig | 9 + .../Target Support Files/Alamofire/Info.plist | 26 + .../PetstoreClient/Info.plist | 26 + .../PetstoreClient/PetstoreClient-dummy.m | 5 + .../PetstoreClient/PetstoreClient-prefix.pch | 3 + .../PetstoreClient/PetstoreClient-umbrella.h | 5 + .../PetstoreClient/PetstoreClient.modulemap | 6 + .../PetstoreClient/PetstoreClient.xcconfig | 10 + .../Pods-SwaggerClient/Info.plist | 26 + ...ds-SwaggerClient-acknowledgements.markdown | 243 +++ .../Pods-SwaggerClient-acknowledgements.plist | 281 +++ .../Pods-SwaggerClient-dummy.m | 5 + .../Pods-SwaggerClient-frameworks.sh | 95 + .../Pods-SwaggerClient-resources.sh | 102 + .../Pods-SwaggerClient-umbrella.h | 5 + .../Pods-SwaggerClient.debug.xcconfig | 10 + .../Pods-SwaggerClient.modulemap | 6 + .../Pods-SwaggerClient.release.xcconfig | 10 + .../Pods-SwaggerClientTests/Info.plist | 26 + ...aggerClientTests-acknowledgements.markdown | 3 + ...-SwaggerClientTests-acknowledgements.plist | 29 + .../Pods-SwaggerClientTests-dummy.m | 5 + .../Pods-SwaggerClientTests-frameworks.sh | 83 + .../Pods-SwaggerClientTests-resources.sh | 102 + .../Pods-SwaggerClientTests-umbrella.h | 5 + .../Pods-SwaggerClientTests.debug.xcconfig | 7 + .../Pods-SwaggerClientTests.modulemap | 6 + .../Pods-SwaggerClientTests.release.xcconfig | 7 + .../Target Support Files/RxSwift/Info.plist | 26 + .../RxSwift/RxSwift-dummy.m | 5 + .../RxSwift/RxSwift-prefix.pch | 3 + .../RxSwift/RxSwift-umbrella.h | 5 + .../RxSwift/RxSwift.modulemap | 6 + .../RxSwift/RxSwift.xcconfig | 9 + .../SwaggerClient.xcodeproj/project.pbxproj | 553 ++++++ .../contents.xcworkspacedata | 7 + .../xcschemes/SwaggerClient.xcscheme | 101 + .../contents.xcworkspacedata | 10 + .../SwaggerClient/AppDelegate.swift | 45 + .../AppIcon.appiconset/Contents.json | 38 + .../Base.lproj/LaunchScreen.storyboard | 27 + .../SwaggerClient/Base.lproj/Main.storyboard | 25 + .../SwaggerClient/Info.plist | 58 + .../SwaggerClient/ViewController.swift | 24 + .../SwaggerClientTests/Info.plist | 35 + .../SwaggerClientTests/PetAPITests.swift | 78 + .../SwaggerClientTests/StoreAPITests.swift | 97 + .../SwaggerClientTests/UserAPITests.swift | 133 ++ .../swift/rxswift/SwaggerClientTests/pom.xml | 65 + .../client/petstore/swift/rxswift/git_push.sh | 51 + 240 files changed, 26914 insertions(+), 4 deletions(-) create mode 100644 bin/swift-petstore-rxswift.json create mode 100755 bin/swift-petstore-rxswift.sh create mode 100644 samples/client/petstore/swift/rxswift/.gitignore create mode 100644 samples/client/petstore/swift/rxswift/.swagger-codegen-ignore create mode 100644 samples/client/petstore/swift/rxswift/Cartfile create mode 100644 samples/client/petstore/swift/rxswift/LICENSE create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient.podspec create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIHelper.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Extensions.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Category.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Order.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Pet.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Tag.swift create mode 100644 samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/User.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Podfile create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/LICENSE create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/README.md create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Alamofire.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Download.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Error.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Manager.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/MultipartFormData.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ParameterEncoding.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Request.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Response.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ResponseSerialization.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Result.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ServerTrustPolicy.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Stream.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Upload.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Validation.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Manifest.lock create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Pods.xcodeproj/project.pbxproj create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/LICENSE.md create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/README.md create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/AnyObserver.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Cancelable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/Lock.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ConnectableObservableType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Bag.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Queue.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NAryDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Errors.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Event.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable+Extensions.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObserverType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Rx.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/RxMutableBox.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/SchedulerType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Subjects/Variable.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Alamofire/Alamofire-dummy.m create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Alamofire/Alamofire.modulemap create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Alamofire/Alamofire.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Alamofire/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/PetstoreClient/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/PetstoreClient/PetstoreClient-dummy.m create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/PetstoreClient/PetstoreClient-prefix.pch create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/PetstoreClient/PetstoreClient-umbrella.h create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/PetstoreClient/PetstoreClient.modulemap create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/PetstoreClient/PetstoreClient.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-acknowledgements.markdown create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-acknowledgements.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-dummy.m create mode 100755 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-frameworks.sh create mode 100755 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-resources.sh create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-umbrella.h create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient.debug.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient.modulemap create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient.release.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests-acknowledgements.markdown create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests-acknowledgements.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests-dummy.m create mode 100755 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests-frameworks.sh create mode 100755 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests-resources.sh create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests-umbrella.h create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests.debug.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests.modulemap create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests.release.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/RxSwift/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/RxSwift/RxSwift-dummy.m create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/RxSwift/RxSwift-prefix.pch create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/RxSwift/RxSwift-umbrella.h create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/RxSwift/RxSwift.modulemap create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Target Support Files/RxSwift/RxSwift.xcconfig create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient.xcodeproj/xcshareddata/xcschemes/SwaggerClient.xcscheme create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient.xcworkspace/contents.xcworkspacedata create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient/AppDelegate.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient/Base.lproj/LaunchScreen.storyboard create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient/Base.lproj/Main.storyboard create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClient/ViewController.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClientTests/Info.plist create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClientTests/PetAPITests.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClientTests/StoreAPITests.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/SwaggerClientTests/UserAPITests.swift create mode 100644 samples/client/petstore/swift/rxswift/SwaggerClientTests/pom.xml create mode 100644 samples/client/petstore/swift/rxswift/git_push.sh diff --git a/bin/swift-petstore-all.sh b/bin/swift-petstore-all.sh index e74eba37704..5d3f2b7f82d 100755 --- a/bin/swift-petstore-all.sh +++ b/bin/swift-petstore-all.sh @@ -34,3 +34,7 @@ java $JAVA_OPTS -jar $executable $ags ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-promisekit.json -o samples/client/petstore/swift/promisekit" echo "#### Petstore Swift API client (promisekit) ####" java $JAVA_OPTS -jar $executable $ags + +ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-rxswift.json -o samples/client/petstore/swift/rxswift" +echo "#### Petstore Swift API client (rxswift) ####" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/swift-petstore-rxswift.json b/bin/swift-petstore-rxswift.json new file mode 100644 index 00000000000..3a81d53deed --- /dev/null +++ b/bin/swift-petstore-rxswift.json @@ -0,0 +1,7 @@ +{ + "podSummary": "PetstoreClient", + "podHomepage": "https://github.com/swagger-api/swagger-codegen", + "podAuthors": "", + "projectName": "PetstoreClient", + "responseAs": "RxSwift" +} diff --git a/bin/swift-petstore-rxswift.sh b/bin/swift-petstore-rxswift.sh new file mode 100755 index 00000000000..c140ed7f908 --- /dev/null +++ b/bin/swift-petstore-rxswift.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +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/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-rxswift.json -o samples/client/petstore/swift/rxswift" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 72e085ce596..3ce1342998d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -40,7 +40,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace"; public static final String DEFAULT_POD_AUTHORS = "Swagger Codegen"; protected static final String LIBRARY_PROMISE_KIT = "PromiseKit"; - protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT }; + protected static final String LIBRARY_RX_SWIFT = "RxSwift"; + protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT, LIBRARY_RX_SWIFT }; protected String projectName = "SwaggerClient"; protected boolean unwrapRequired; protected boolean swiftUseApiNamespace; @@ -186,6 +187,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { if (ArrayUtils.contains(responseAs, LIBRARY_PROMISE_KIT)) { additionalProperties.put("usePromiseKit", true); } + if (ArrayUtils.contains(responseAs, LIBRARY_RX_SWIFT)) { + additionalProperties.put("useRxSwift", true); + } // Setup swiftUseApiNamespace option, which makes all the API classes inner-class of {{projectName}}API if (additionalProperties.containsKey(SWIFT_USE_API_NAMESPACE)) { diff --git a/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache b/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache index a0906ba5969..101df9a7e04 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache @@ -1,2 +1,3 @@ github "Alamofire/Alamofire" >= 3.1.0{{#usePromiseKit}} -github "mxcl/PromiseKit" >=1.5.3{{/usePromiseKit}} +github "mxcl/PromiseKit" >=1.5.3{{/usePromiseKit}}{{#useRxSwift}} +github "ReactiveX/RxSwift" ~> 2.0{{/useRxSwift}} diff --git a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache index f893182d9ab..b5b1d0efb63 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache @@ -15,6 +15,7 @@ Pod::Spec.new do |s| s.screenshots = {{& podScreenshots}}{{/podScreenshots}}{{#podDocumentationURL}} s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}} s.source_files = '{{projectName}}/Classes/Swaggers/**/*.swift'{{#usePromiseKit}} - s.dependency 'PromiseKit', '~> 3.1.1'{{/usePromiseKit}} + s.dependency 'PromiseKit', '~> 3.1.1'{{/usePromiseKit}}{{#useRxSwift}} + s.dependency 'RxSwift', '~> 2.0'{{/useRxSwift}} s.dependency 'Alamofire', '~> 3.4.1' end diff --git a/modules/swagger-codegen/src/main/resources/swift/api.mustache b/modules/swagger-codegen/src/main/resources/swift/api.mustache index 8698c5da4e7..88fb5c33d8c 100644 --- a/modules/swagger-codegen/src/main/resources/swift/api.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/api.mustache @@ -6,7 +6,8 @@ // import Alamofire{{#usePromiseKit}} -import PromiseKit{{/usePromiseKit}} +import PromiseKit{{/usePromiseKit}}{{#useRxSwift}} +import RxSwift{{/useRxSwift}} {{#swiftUseApiNamespace}} extension {{projectName}}API { @@ -62,6 +63,28 @@ public class {{classname}}: APIBase { return deferred.promise } {{/usePromiseKit}} +{{#useRxSwift}} + /** + {{#summary}} + {{{summary}}} + {{/summary}}{{#allParams}} + - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} + - returns: Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> + */ + public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> { + return Observable.create { observer -> Disposable in + {{operationId}}({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#returnType}}data, {{/returnType}}error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next({{#returnType}}data!{{/returnType}})) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } +{{/useRxSwift}} /** {{#summary}} diff --git a/samples/client/petstore/swift/rxswift/.gitignore b/samples/client/petstore/swift/rxswift/.gitignore new file mode 100644 index 00000000000..fc4e330f8fa --- /dev/null +++ b/samples/client/petstore/swift/rxswift/.gitignore @@ -0,0 +1,63 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# 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/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# 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 + +fastlane/report.xml +fastlane/screenshots diff --git a/samples/client/petstore/swift/rxswift/.swagger-codegen-ignore b/samples/client/petstore/swift/rxswift/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/swift/rxswift/Cartfile b/samples/client/petstore/swift/rxswift/Cartfile new file mode 100644 index 00000000000..d862ef91d09 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/Cartfile @@ -0,0 +1,2 @@ +github "Alamofire/Alamofire" >= 3.1.0 +github "ReactiveX/RxSwift" ~> 2.0 diff --git a/samples/client/petstore/swift/rxswift/LICENSE b/samples/client/petstore/swift/rxswift/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient.podspec b/samples/client/petstore/swift/rxswift/PetstoreClient.podspec new file mode 100644 index 00000000000..41010ccde4a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = 'PetstoreClient' + s.ios.deployment_target = '8.0' + s.osx.deployment_target = '10.9' + s.version = '0.0.1' + s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' } + s.authors = '' + s.license = 'Apache License, Version 2.0' + s.homepage = 'https://github.com/swagger-api/swagger-codegen' + s.summary = 'PetstoreClient' + s.source_files = 'PetstoreClient/Classes/Swaggers/**/*.swift' + s.dependency 'RxSwift', '~> 2.0' + s.dependency 'Alamofire', '~> 3.1.5' +end diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIHelper.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIHelper.swift new file mode 100644 index 00000000000..23e727b6b54 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIHelper.swift @@ -0,0 +1,40 @@ +// APIHelper.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +class APIHelper { + static func rejectNil(source: [String:AnyObject?]) -> [String:AnyObject]? { + var destination = [String:AnyObject]() + for (key, nillableValue) in source { + if let value: AnyObject = nillableValue { + destination[key] = value + } + } + + if destination.isEmpty { + return nil + } + return destination + } + + static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject]? { + guard let source = source else { + return nil + } + var destination = [String:AnyObject]() + let theTrue = NSNumber(bool: true) + let theFalse = NSNumber(bool: false) + for (key, value) in source { + switch value { + case let x where x === theTrue || x === theFalse: + destination[key] = "\(value as! Bool)" + default: + destination[key] = value + } + } + return destination + } + +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs.swift new file mode 100644 index 00000000000..40253b7b32d --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs.swift @@ -0,0 +1,75 @@ +// APIs.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +public class PetstoreClientAPI { + public static var basePath = "http://petstore.swagger.io/v2" + public static var credential: NSURLCredential? + public static var customHeaders: [String:String] = [:] + static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() +} + +public class APIBase { + func toParameters(encodable: JSONEncodable?) -> [String: AnyObject]? { + let encoded: AnyObject? = encodable?.encodeToJSON() + + if encoded! is [AnyObject] { + var dictionary = [String:AnyObject]() + for (index, item) in (encoded as! [AnyObject]).enumerate() { + dictionary["\(index)"] = item + } + return dictionary + } else { + return encoded as? [String:AnyObject] + } + } +} + +public class RequestBuilder { + var credential: NSURLCredential? + var headers: [String:String] = [:] + let parameters: [String:AnyObject]? + let isBody: Bool + let method: String + let URLString: String + + /// Optional block to obtain a reference to the request's progress instance when available. + public var onProgressReady: ((NSProgress) -> ())? + + required public init(method: String, URLString: String, parameters: [String:AnyObject]?, isBody: Bool) { + self.method = method + self.URLString = URLString + self.parameters = parameters + self.isBody = isBody + + addHeaders(PetstoreClientAPI.customHeaders) + } + + public func addHeaders(aHeaders:[String:String]) { + for (header, value) in aHeaders { + headers[header] = value + } + } + + public func execute(completion: (response: Response?, error: ErrorType?) -> Void) { } + + public func addHeader(name name: String, value: String) -> Self { + if !value.isEmpty { + headers[name] = value + } + return self + } + + public func addCredential() -> Self { + self.credential = PetstoreClientAPI.credential + return self + } +} + +protocol RequestBuilderFactory { + func getBuilder() -> RequestBuilder.Type +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift new file mode 100644 index 00000000000..ee5d73bf4c7 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -0,0 +1,608 @@ +// +// PetAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire +import RxSwift + + + +public class PetAPI: APIBase { + /** + Add a new pet to the store + + - parameter body: (body) Pet object that needs to be added to the store (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func addPet(body body: Pet? = nil, completion: ((error: ErrorType?) -> Void)) { + addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Add a new pet to the store + + - parameter body: (body) Pet object that needs to be added to the store (optional) + - returns: Observable + */ + public class func addPet(body body: Pet? = nil) -> Observable { + return Observable.create { observer -> Disposable in + addPet(body: body) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Add a new pet to the store + - POST /pet + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter body: (body) Pet object that needs to be added to the store (optional) + + - returns: RequestBuilder + */ + public class func addPetWithRequestBuilder(body body: Pet? = nil) -> RequestBuilder { + let path = "/pet" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Deletes a pet + + - parameter petId: (path) Pet id to delete + - parameter completion: completion handler to receive the data and the error objects + */ + public class func deletePet(petId petId: Int64, completion: ((error: ErrorType?) -> Void)) { + deletePetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Deletes a pet + + - parameter petId: (path) Pet id to delete + - returns: Observable + */ + public class func deletePet(petId petId: Int64) -> Observable { + return Observable.create { observer -> Disposable in + deletePet(petId: petId) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Deletes a pet + - DELETE /pet/{petId} + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter petId: (path) Pet id to delete + + - returns: RequestBuilder + */ + public class func deletePetWithRequestBuilder(petId petId: Int64) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Finds Pets by status + + - parameter status: (query) Status values that need to be considered for filter (optional, default to available) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func findPetsByStatus(status status: [String]? = nil, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { + findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Finds Pets by status + + - parameter status: (query) Status values that need to be considered for filter (optional, default to available) + - returns: Observable<[Pet]> + */ + public class func findPetsByStatus(status status: [String]? = nil) -> Observable<[Pet]> { + return Observable.create { observer -> Disposable in + findPetsByStatus(status: status) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Finds Pets by status + - GET /pet/findByStatus + - Multiple status values can be provided with comma seperated strings + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{example={ + "name" : "Puma", + "type" : "Dog", + "color" : "Black", + "gender" : "Female", + "breed" : "Mixed" +}, contentType=application/json}] + + - parameter status: (query) Status values that need to be considered for filter (optional, default to available) + + - returns: RequestBuilder<[Pet]> + */ + public class func findPetsByStatusWithRequestBuilder(status status: [String]? = nil) -> RequestBuilder<[Pet]> { + let path = "/pet/findByStatus" + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "status": status + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: false) + } + + /** + Finds Pets by tags + + - parameter tags: (query) Tags to filter by (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func findPetsByTags(tags tags: [String]? = nil, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { + findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Finds Pets by tags + + - parameter tags: (query) Tags to filter by (optional) + - returns: Observable<[Pet]> + */ + public class func findPetsByTags(tags tags: [String]? = nil) -> Observable<[Pet]> { + return Observable.create { observer -> Disposable in + findPetsByTags(tags: tags) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Finds Pets by tags + - GET /pet/findByTags + - Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{example=[ { + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], + "id" : 123456789, + "category" : { + "id" : 123456789, + "name" : "aeiou" + }, + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}, {example= + 123456 + doggie + + string + + + + string +, contentType=application/xml}] + - examples: [{example=[ { + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], + "id" : 123456789, + "category" : { + "id" : 123456789, + "name" : "aeiou" + }, + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}, {example= + 123456 + doggie + + string + + + + string +, contentType=application/xml}] + + - parameter tags: (query) Tags to filter by (optional) + + - returns: RequestBuilder<[Pet]> + */ + public class func findPetsByTagsWithRequestBuilder(tags tags: [String]? = nil) -> RequestBuilder<[Pet]> { + let path = "/pet/findByTags" + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "tags": tags + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: false) + } + + /** + Find pet by ID + + - parameter petId: (path) ID of pet that needs to be fetched + - parameter completion: completion handler to receive the data and the error objects + */ + public class func getPetById(petId petId: Int64, completion: ((data: Pet?, error: ErrorType?) -> Void)) { + getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Find pet by ID + + - parameter petId: (path) ID of pet that needs to be fetched + - returns: Observable + */ + public class func getPetById(petId petId: Int64) -> Observable { + return Observable.create { observer -> Disposable in + getPetById(petId: petId) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Find pet by ID + - GET /pet/{petId} + - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + - API Key: + - type: apiKey api_key + - name: api_key + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{example={ + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], + "id" : 123456789, + "category" : { + "id" : 123456789, + "name" : "aeiou" + }, + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}, {example= + 123456 + doggie + + string + + + + string +, contentType=application/xml}] + - examples: [{example={ + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], + "id" : 123456789, + "category" : { + "id" : 123456789, + "name" : "aeiou" + }, + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}, {example= + 123456 + doggie + + string + + + + string +, contentType=application/xml}] + + - parameter petId: (path) ID of pet that needs to be fetched + + - returns: RequestBuilder + */ + public class func getPetByIdWithRequestBuilder(petId petId: Int64) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Update an existing pet + + - parameter body: (body) Pet object that needs to be added to the store (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func updatePet(body body: Pet? = nil, completion: ((error: ErrorType?) -> Void)) { + updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Update an existing pet + + - parameter body: (body) Pet object that needs to be added to the store (optional) + - returns: Observable + */ + public class func updatePet(body body: Pet? = nil) -> Observable { + return Observable.create { observer -> Disposable in + updatePet(body: body) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Update an existing pet + - PUT /pet + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter body: (body) Pet object that needs to be added to the store (optional) + + - returns: RequestBuilder + */ + public class func updatePetWithRequestBuilder(body body: Pet? = nil) -> RequestBuilder { + let path = "/pet" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "PUT", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Updates a pet in the store with form data + + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet (optional) + - parameter status: (form) Updated status of the pet (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func updatePetWithForm(petId petId: String, name: String? = nil, status: String? = nil, completion: ((error: ErrorType?) -> Void)) { + updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Updates a pet in the store with form data + + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet (optional) + - parameter status: (form) Updated status of the pet (optional) + - returns: Observable + */ + public class func updatePetWithForm(petId petId: String, name: String? = nil, status: String? = nil) -> Observable { + return Observable.create { observer -> Disposable in + updatePetWithForm(petId: petId, name: name, status: status) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Updates a pet in the store with form data + - POST /pet/{petId} + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet (optional) + - parameter status: (form) Updated status of the pet (optional) + + - returns: RequestBuilder + */ + public class func updatePetWithFormWithRequestBuilder(petId petId: String, name: String? = nil, status: String? = nil) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "name": name, + "status": status + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: false) + } + + /** + uploads an image + + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server (optional) + - parameter file: (form) file to upload (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, file: NSURL? = nil, completion: ((error: ErrorType?) -> Void)) { + uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + uploads an image + + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server (optional) + - parameter file: (form) file to upload (optional) + - returns: Observable + */ + public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, file: NSURL? = nil) -> Observable { + return Observable.create { observer -> Disposable in + uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + uploads an image + - POST /pet/{petId}/uploadImage + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server (optional) + - parameter file: (form) file to upload (optional) + + - returns: RequestBuilder + */ + public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String? = nil, file: NSURL? = nil) -> RequestBuilder { + var path = "/pet/{petId}/uploadImage" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "additionalMetadata": additionalMetadata, + "file": file + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: false) + } + +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift new file mode 100644 index 00000000000..a3de3380f82 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -0,0 +1,302 @@ +// +// StoreAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire +import RxSwift + + + +public class StoreAPI: APIBase { + /** + Delete purchase order by ID + + - parameter orderId: (path) ID of the order that needs to be deleted + - parameter completion: completion handler to receive the data and the error objects + */ + public class func deleteOrder(orderId orderId: String, completion: ((error: ErrorType?) -> Void)) { + deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Delete purchase order by ID + + - parameter orderId: (path) ID of the order that needs to be deleted + - returns: Observable + */ + public class func deleteOrder(orderId orderId: String) -> Observable { + return Observable.create { observer -> Disposable in + deleteOrder(orderId: orderId) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Delete purchase order by ID + - DELETE /store/order/{orderId} + - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + + - parameter orderId: (path) ID of the order that needs to be deleted + + - returns: RequestBuilder + */ + public class func deleteOrderWithRequestBuilder(orderId orderId: String) -> RequestBuilder { + var path = "/store/order/{orderId}" + path = path.stringByReplacingOccurrencesOfString("{orderId}", withString: "\(orderId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Returns pet inventories by status + + - parameter completion: completion handler to receive the data and the error objects + */ + public class func getInventory(completion: ((data: [String:Int32]?, error: ErrorType?) -> Void)) { + getInventoryWithRequestBuilder().execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Returns pet inventories by status + + - returns: Observable<[String:Int32]> + */ + public class func getInventory() -> Observable<[String:Int32]> { + return Observable.create { observer -> Disposable in + getInventory() { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Returns pet inventories by status + - GET /store/inventory + - Returns a map of status codes to quantities + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{example={ + "key" : 123 +}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] + - examples: [{example={ + "key" : 123 +}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] + + - returns: RequestBuilder<[String:Int32]> + */ + public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int32]> { + let path = "/store/inventory" + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder<[String:Int32]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Find purchase order by ID + + - parameter orderId: (path) ID of pet that needs to be fetched + - parameter completion: completion handler to receive the data and the error objects + */ + public class func getOrderById(orderId orderId: String, completion: ((data: Order?, error: ErrorType?) -> Void)) { + getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Find purchase order by ID + + - parameter orderId: (path) ID of pet that needs to be fetched + - returns: Observable + */ + public class func getOrderById(orderId orderId: String) -> Observable { + return Observable.create { observer -> Disposable in + getOrderById(orderId: orderId) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Find purchase order by ID + - GET /store/order/{orderId} + - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + - examples: [{example={ + "id" : 123456789, + "petId" : 123456789, + "complete" : true, + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}, {example= + 123456 + 123456 + 0 + 2000-01-23T04:56:07.000Z + string + true +, contentType=application/xml}] + - examples: [{example={ + "id" : 123456789, + "petId" : 123456789, + "complete" : true, + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}, {example= + 123456 + 123456 + 0 + 2000-01-23T04:56:07.000Z + string + true +, contentType=application/xml}] + + - parameter orderId: (path) ID of pet that needs to be fetched + + - returns: RequestBuilder + */ + public class func getOrderByIdWithRequestBuilder(orderId orderId: String) -> RequestBuilder { + var path = "/store/order/{orderId}" + path = path.stringByReplacingOccurrencesOfString("{orderId}", withString: "\(orderId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Place an order for a pet + + - parameter body: (body) order placed for purchasing the pet (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func placeOrder(body body: Order? = nil, completion: ((data: Order?, error: ErrorType?) -> Void)) { + placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Place an order for a pet + + - parameter body: (body) order placed for purchasing the pet (optional) + - returns: Observable + */ + public class func placeOrder(body body: Order? = nil) -> Observable { + return Observable.create { observer -> Disposable in + placeOrder(body: body) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Place an order for a pet + - POST /store/order + - + - examples: [{example={ + "id" : 123456789, + "petId" : 123456789, + "complete" : true, + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}, {example= + 123456 + 123456 + 0 + 2000-01-23T04:56:07.000Z + string + true +, contentType=application/xml}] + - examples: [{example={ + "id" : 123456789, + "petId" : 123456789, + "complete" : true, + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}, {example= + 123456 + 123456 + 0 + 2000-01-23T04:56:07.000Z + string + true +, contentType=application/xml}] + + - parameter body: (body) order placed for purchasing the pet (optional) + + - returns: RequestBuilder + */ + public class func placeOrderWithRequestBuilder(body body: Order? = nil) -> RequestBuilder { + let path = "/store/order" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: true) + } + +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift new file mode 100644 index 00000000000..31549870544 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -0,0 +1,498 @@ +// +// UserAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire +import RxSwift + + + +public class UserAPI: APIBase { + /** + Create user + + - parameter body: (body) Created user object (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func createUser(body body: User? = nil, completion: ((error: ErrorType?) -> Void)) { + createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Create user + + - parameter body: (body) Created user object (optional) + - returns: Observable + */ + public class func createUser(body body: User? = nil) -> Observable { + return Observable.create { observer -> Disposable in + createUser(body: body) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Create user + - POST /user + - This can only be done by the logged in user. + + - parameter body: (body) Created user object (optional) + + - returns: RequestBuilder + */ + public class func createUserWithRequestBuilder(body body: User? = nil) -> RequestBuilder { + let path = "/user" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Creates list of users with given input array + + - parameter body: (body) List of user object (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func createUsersWithArrayInput(body body: [User]? = nil, completion: ((error: ErrorType?) -> Void)) { + createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Creates list of users with given input array + + - parameter body: (body) List of user object (optional) + - returns: Observable + */ + public class func createUsersWithArrayInput(body body: [User]? = nil) -> Observable { + return Observable.create { observer -> Disposable in + createUsersWithArrayInput(body: body) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Creates list of users with given input array + - POST /user/createWithArray + - + + - parameter body: (body) List of user object (optional) + + - returns: RequestBuilder + */ + public class func createUsersWithArrayInputWithRequestBuilder(body body: [User]? = nil) -> RequestBuilder { + let path = "/user/createWithArray" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Creates list of users with given input array + + - parameter body: (body) List of user object (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func createUsersWithListInput(body body: [User]? = nil, completion: ((error: ErrorType?) -> Void)) { + createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Creates list of users with given input array + + - parameter body: (body) List of user object (optional) + - returns: Observable + */ + public class func createUsersWithListInput(body body: [User]? = nil) -> Observable { + return Observable.create { observer -> Disposable in + createUsersWithListInput(body: body) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Creates list of users with given input array + - POST /user/createWithList + - + + - parameter body: (body) List of user object (optional) + + - returns: RequestBuilder + */ + public class func createUsersWithListInputWithRequestBuilder(body body: [User]? = nil) -> RequestBuilder { + let path = "/user/createWithList" + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Delete user + + - parameter username: (path) The name that needs to be deleted + - parameter completion: completion handler to receive the data and the error objects + */ + public class func deleteUser(username username: String, completion: ((error: ErrorType?) -> Void)) { + deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Delete user + + - parameter username: (path) The name that needs to be deleted + - returns: Observable + */ + public class func deleteUser(username username: String) -> Observable { + return Observable.create { observer -> Disposable in + deleteUser(username: username) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Delete user + - DELETE /user/{username} + - This can only be done by the logged in user. + + - parameter username: (path) The name that needs to be deleted + + - returns: RequestBuilder + */ + public class func deleteUserWithRequestBuilder(username username: String) -> RequestBuilder { + var path = "/user/{username}" + path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Get user by user name + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - parameter completion: completion handler to receive the data and the error objects + */ + public class func getUserByName(username username: String, completion: ((data: User?, error: ErrorType?) -> Void)) { + getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Get user by user name + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - returns: Observable + */ + public class func getUserByName(username username: String) -> Observable { + return Observable.create { observer -> Disposable in + getUserByName(username: username) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Get user by user name + - GET /user/{username} + - + - examples: [{example={ + "id" : 123456789, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", + "email" : "aeiou", + "userStatus" : 123, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}, {example= + 123456 + string + string + string + string + string + string + 0 +, contentType=application/xml}] + - examples: [{example={ + "id" : 123456789, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", + "email" : "aeiou", + "userStatus" : 123, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}, {example= + 123456 + string + string + string + string + string + string + 0 +, contentType=application/xml}] + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + + - returns: RequestBuilder + */ + public class func getUserByNameWithRequestBuilder(username username: String) -> RequestBuilder { + var path = "/user/{username}" + path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Logs user into the system + + - parameter username: (query) The user name for login (optional) + - parameter password: (query) The password for login in clear text (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func loginUser(username username: String? = nil, password: String? = nil, completion: ((data: String?, error: ErrorType?) -> Void)) { + loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + Logs user into the system + + - parameter username: (query) The user name for login (optional) + - parameter password: (query) The password for login in clear text (optional) + - returns: Observable + */ + public class func loginUser(username username: String? = nil, password: String? = nil) -> Observable { + return Observable.create { observer -> Disposable in + loginUser(username: username, password: password) { data, error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next(data!)) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Logs user into the system + - GET /user/login + - + - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] + - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] + + - parameter username: (query) The user name for login (optional) + - parameter password: (query) The password for login in clear text (optional) + + - returns: RequestBuilder + */ + public class func loginUserWithRequestBuilder(username username: String? = nil, password: String? = nil) -> RequestBuilder { + let path = "/user/login" + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "username": username, + "password": password + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: false) + } + + /** + Logs out current logged in user session + + - parameter completion: completion handler to receive the data and the error objects + */ + public class func logoutUser(completion: ((error: ErrorType?) -> Void)) { + logoutUserWithRequestBuilder().execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Logs out current logged in user session + + - returns: Observable + */ + public class func logoutUser() -> Observable { + return Observable.create { observer -> Disposable in + logoutUser() { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Logs out current logged in user session + - GET /user/logout + - + + - returns: RequestBuilder + */ + public class func logoutUserWithRequestBuilder() -> RequestBuilder { + let path = "/user/logout" + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: convertedParameters, isBody: true) + } + + /** + Updated user + + - parameter username: (path) name that need to be deleted + - parameter body: (body) Updated user object (optional) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func updateUser(username username: String, body: User? = nil, completion: ((error: ErrorType?) -> Void)) { + updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + Updated user + + - parameter username: (path) name that need to be deleted + - parameter body: (body) Updated user object (optional) + - returns: Observable + */ + public class func updateUser(username username: String, body: User? = nil) -> Observable { + return Observable.create { observer -> Disposable in + updateUser(username: username, body: body) { error in + if let error = error { + observer.on(.Error(error as ErrorType)) + } else { + observer.on(.Next()) + } + observer.on(.Completed) + } + return NopDisposable.instance + } + } + + /** + Updated user + - PUT /user/{username} + - This can only be done by the logged in user. + + - parameter username: (path) name that need to be deleted + - parameter body: (body) Updated user object (optional) + + - returns: RequestBuilder + */ + public class func updateUserWithRequestBuilder(username username: String, body: User? = nil) -> RequestBuilder { + var path = "/user/{username}" + path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "PUT", URLString: URLString, parameters: convertedParameters, isBody: true) + } + +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift new file mode 100644 index 00000000000..cabf67567b5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift @@ -0,0 +1,148 @@ +// AlamofireImplementations.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire + +class AlamofireRequestBuilderFactory: RequestBuilderFactory { + func getBuilder() -> RequestBuilder.Type { + return AlamofireRequestBuilder.self + } +} + +// Store manager to retain its reference +private var managerStore: [String: Alamofire.Manager] = [:] + +class AlamofireRequestBuilder: RequestBuilder { + required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) { + super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody) + } + + override func execute(completion: (response: Response?, error: ErrorType?) -> Void) { + let managerId = NSUUID().UUIDString + // Create a new manager for each request to customize its request header + let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() + configuration.HTTPAdditionalHeaders = buildHeaders() + let manager = Alamofire.Manager(configuration: configuration) + managerStore[managerId] = manager + + let encoding = isBody ? Alamofire.ParameterEncoding.JSON : Alamofire.ParameterEncoding.URL + let xMethod = Alamofire.Method(rawValue: method) + let fileKeys = parameters == nil ? [] : parameters!.filter { $1.isKindOfClass(NSURL) } + .map { $0.0 } + + if fileKeys.count > 0 { + manager.upload( + xMethod!, URLString, headers: nil, + multipartFormData: { mpForm in + for (k, v) in self.parameters! { + switch v { + case let fileURL as NSURL: + mpForm.appendBodyPart(fileURL: fileURL, name: k) + break + case let string as NSString: + mpForm.appendBodyPart(data: string.dataUsingEncoding(NSUTF8StringEncoding)!, name: k) + break + case let number as NSNumber: + mpForm.appendBodyPart(data: number.stringValue.dataUsingEncoding(NSUTF8StringEncoding)!, name: k) + break + default: + fatalError("Unprocessable value \(v) with key \(k)") + break + } + } + }, + encodingMemoryThreshold: Manager.MultipartFormDataEncodingMemoryThreshold, + encodingCompletion: { encodingResult in + switch encodingResult { + case .Success(let uploadRequest, _, _): + if let onProgressReady = self.onProgressReady { + onProgressReady(uploadRequest.progress) + } + self.processRequest(uploadRequest, managerId, completion) + case .Failure(let encodingError): + completion(response: nil, error: encodingError) + } + } + ) + } else { + let request = manager.request(xMethod!, URLString, parameters: parameters, encoding: encoding) + if let onProgressReady = self.onProgressReady { + onProgressReady(request.progress) + } + processRequest(request, managerId, completion) + } + + } + + private func processRequest(request: Request, _ managerId: String, _ completion: (response: Response?, error: ErrorType?) -> Void) { + if let credential = self.credential { + request.authenticate(usingCredential: credential) + } + + let cleanupRequest = { + managerStore.removeValueForKey(managerId) + } + + let validatedRequest = request.validate() + + switch T.self { + case is NSData.Type: + validatedRequest.responseData({ (dataResponse) in + cleanupRequest() + + if (dataResponse.result.isFailure) { + completion( + response: nil, + error: dataResponse.result.error + ) + return + } + + completion( + response: Response( + response: dataResponse.response!, + body: dataResponse.data as! T + ), + error: nil + ) + }) + default: + validatedRequest.responseJSON(options: .AllowFragments) { response in + cleanupRequest() + + if response.result.isFailure { + completion(response: nil, error: response.result.error) + return + } + + if () is T { + completion(response: Response(response: response.response!, body: () as! T), error: nil) + return + } + if let json: AnyObject = response.result.value { + let body = Decoders.decode(clazz: T.self, source: json) + completion(response: Response(response: response.response!, body: body), error: nil) + return + } else if "" is T { + // swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release + // https://github.com/swagger-api/swagger-parser/pull/34 + completion(response: Response(response: response.response!, body: "" as! T), error: nil) + return + } + + completion(response: nil, error: NSError(domain: "localhost", code: 500, userInfo: ["reason": "unreacheable code"])) + } + } + } + + private func buildHeaders() -> [String: AnyObject] { + var httpHeaders = Manager.defaultHTTPHeaders + for (key, value) in self.headers { + httpHeaders[key] = value + } + return httpHeaders + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Extensions.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Extensions.swift new file mode 100644 index 00000000000..1dbb47e625f --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Extensions.swift @@ -0,0 +1,84 @@ +// Extensions.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire + +extension Bool: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension Float: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension Int: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension Int32: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(int: self) } +} + +extension Int64: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(longLong: self) } +} + +extension Double: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension String: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +private func encodeIfPossible(object: T) -> AnyObject { + if object is JSONEncodable { + return (object as! JSONEncodable).encodeToJSON() + } else { + return object as! AnyObject + } +} + +extension Array: JSONEncodable { + func encodeToJSON() -> AnyObject { + return self.map(encodeIfPossible) + } +} + +extension Dictionary: JSONEncodable { + func encodeToJSON() -> AnyObject { + var dictionary = [NSObject:AnyObject]() + for (key, value) in self { + dictionary[key as! NSObject] = encodeIfPossible(value) + } + return dictionary + } +} + +extension NSData: JSONEncodable { + func encodeToJSON() -> AnyObject { + return self.base64EncodedStringWithOptions(NSDataBase64EncodingOptions()) + } +} + +private let dateFormatter: NSDateFormatter = { + let fmt = NSDateFormatter() + fmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + fmt.locale = NSLocale(localeIdentifier: "en_US_POSIX") + return fmt +}() + +extension NSDate: JSONEncodable { + func encodeToJSON() -> AnyObject { + return dateFormatter.stringFromDate(self) + } +} + +extension NSUUID: JSONEncodable { + func encodeToJSON() -> AnyObject { + return self.UUIDString + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models.swift new file mode 100644 index 00000000000..731bcc28d07 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models.swift @@ -0,0 +1,224 @@ +// Models.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +protocol JSONEncodable { + func encodeToJSON() -> AnyObject +} + +public class Response { + public let statusCode: Int + public let header: [String: String] + public let body: T + + public init(statusCode: Int, header: [String: String], body: T) { + self.statusCode = statusCode + self.header = header + self.body = body + } + + public convenience init(response: NSHTTPURLResponse, body: T) { + let rawHeader = response.allHeaderFields + var header = [String:String]() + for (key, value) in rawHeader { + header[key as! String] = value as? String + } + self.init(statusCode: response.statusCode, header: header, body: body) + } +} + +private var once = dispatch_once_t() +class Decoders { + static private var decoders = Dictionary AnyObject)>() + + static func addDecoder(clazz clazz: T.Type, decoder: ((AnyObject) -> T)) { + let key = "\(T.self)" + decoders[key] = { decoder($0) as! AnyObject } + } + + static func decode(clazz clazz: [T].Type, source: AnyObject) -> [T] { + let array = source as! [AnyObject] + return array.map { Decoders.decode(clazz: T.self, source: $0) } + } + + static func decode(clazz clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { + let sourceDictionary = source as! [Key: AnyObject] + var dictionary = [Key:T]() + for (key, value) in sourceDictionary { + dictionary[key] = Decoders.decode(clazz: T.self, source: value) + } + return dictionary + } + + static func decode(clazz clazz: T.Type, source: AnyObject) -> T { + initialize() + if T.self is Int32.Type && source is NSNumber { + return source.intValue as! T; + } + if T.self is Int64.Type && source is NSNumber { + return source.longLongValue as! T; + } + if T.self is NSUUID.Type && source is String { + return NSUUID(UUIDString: source as! String) as! T + } + if source is T { + return source as! T + } + if T.self is NSData.Type && source is String { + return NSData(base64EncodedString: source as! String, options: NSDataBase64DecodingOptions()) as! T + } + + let key = "\(T.self)" + if let decoder = decoders[key] { + return decoder(source) as! T + } else { + fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") + } + } + + static func decodeOptional(clazz clazz: T.Type, source: AnyObject?) -> T? { + if source is NSNull { + return nil + } + return source.map { (source: AnyObject) -> T in + Decoders.decode(clazz: clazz, source: source) + } + } + + static func decodeOptional(clazz clazz: [T].Type, source: AnyObject?) -> [T]? { + if source is NSNull { + return nil + } + return source.map { (someSource: AnyObject) -> [T] in + Decoders.decode(clazz: clazz, source: someSource) + } + } + + static func decodeOptional(clazz clazz: [Key:T].Type, source: AnyObject?) -> [Key:T]? { + if source is NSNull { + return nil + } + return source.map { (someSource: AnyObject) -> [Key:T] in + Decoders.decode(clazz: clazz, source: someSource) + } + } + + static private func initialize() { + dispatch_once(&once) { + let formatters = [ + "yyyy-MM-dd", + "yyyy-MM-dd'T'HH:mm:ssZZZZZ", + "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", + "yyyy-MM-dd'T'HH:mm:ss'Z'", + "yyyy-MM-dd'T'HH:mm:ss.SSS" + ].map { (format: String) -> NSDateFormatter in + let formatter = NSDateFormatter() + formatter.dateFormat = format + return formatter + } + // Decoder for NSDate + Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in + if let sourceString = source as? String { + for formatter in formatters { + if let date = formatter.dateFromString(sourceString) { + return date + } + } + + } + if let sourceInt = source as? Int { + // treat as a java date + return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) ) + } + fatalError("formatter failed to parse \(source)") + } + + // Decoder for [Category] + Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject) -> [Category] in + return Decoders.decode(clazz: [Category].self, source: source) + } + // Decoder for Category + Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Category() + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + return instance + } + + + // Decoder for [Order] + Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in + return Decoders.decode(clazz: [Order].self, source: source) + } + // Decoder for Order + Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Order() + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"]) + instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"]) + instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"]) + instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") + instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"]) + return instance + } + + + // Decoder for [Pet] + Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in + return Decoders.decode(clazz: [Pet].self, source: source) + } + // Decoder for Pet + Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Pet() + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"]) + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) + instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) + instance.status = Pet.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") + return instance + } + + + // Decoder for [Tag] + Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in + return Decoders.decode(clazz: [Tag].self, source: source) + } + // Decoder for Tag + Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Tag() + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + return instance + } + + + // Decoder for [User] + Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in + return Decoders.decode(clazz: [User].self, source: source) + } + // Decoder for User + Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = User() + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"]) + instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"]) + instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"]) + instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"]) + instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) + instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"]) + instance.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"]) + return instance + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Category.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Category.swift new file mode 100644 index 00000000000..89ce2ccb616 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Category.swift @@ -0,0 +1,25 @@ +// +// Category.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class Category: JSONEncodable { + public var id: Int64? + public var name: String? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["name"] = self.name + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Order.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Order.swift new file mode 100644 index 00000000000..14efcf0d0c9 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Order.swift @@ -0,0 +1,39 @@ +// +// Order.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class Order: JSONEncodable { + public enum Status: String { + case Placed = "placed" + case Approved = "approved" + case Delivered = "delivered" + } + public var id: Int64? + public var petId: Int64? + public var quantity: Int32? + public var shipDate: NSDate? + /** Order Status */ + public var status: Status? + public var complete: Bool? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["petId"] = self.petId?.encodeToJSON() + nillableDictionary["quantity"] = self.quantity?.encodeToJSON() + nillableDictionary["shipDate"] = self.shipDate?.encodeToJSON() + nillableDictionary["status"] = self.status?.rawValue + nillableDictionary["complete"] = self.complete + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Pet.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Pet.swift new file mode 100644 index 00000000000..7d1a6256121 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Pet.swift @@ -0,0 +1,39 @@ +// +// Pet.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class Pet: JSONEncodable { + public enum Status: String { + case Available = "available" + case Pending = "pending" + case Sold = "sold" + } + public var id: Int64? + public var category: Category? + public var name: String? + public var photoUrls: [String]? + public var tags: [Tag]? + /** pet status in the store */ + public var status: Status? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["category"] = self.category?.encodeToJSON() + nillableDictionary["name"] = self.name + nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() + nillableDictionary["tags"] = self.tags?.encodeToJSON() + nillableDictionary["status"] = self.status?.rawValue + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Tag.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Tag.swift new file mode 100644 index 00000000000..774f91557e6 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/Tag.swift @@ -0,0 +1,25 @@ +// +// Tag.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class Tag: JSONEncodable { + public var id: Int64? + public var name: String? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["name"] = self.name + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/User.swift b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/User.swift new file mode 100644 index 00000000000..67b72a61922 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/PetstoreClient/Classes/Swaggers/Models/User.swift @@ -0,0 +1,38 @@ +// +// User.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class User: JSONEncodable { + public var id: Int64? + public var username: String? + public var firstName: String? + public var lastName: String? + public var email: String? + public var password: String? + public var phone: String? + /** User Status */ + public var userStatus: Int32? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["username"] = self.username + nillableDictionary["firstName"] = self.firstName + nillableDictionary["lastName"] = self.lastName + nillableDictionary["email"] = self.email + nillableDictionary["password"] = self.password + nillableDictionary["phone"] = self.phone + nillableDictionary["userStatus"] = self.userStatus?.encodeToJSON() + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Podfile b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Podfile new file mode 100644 index 00000000000..29843508b65 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Podfile @@ -0,0 +1,10 @@ +use_frameworks! +source 'https://github.com/CocoaPods/Specs.git' + +target 'SwaggerClient' do + pod "PetstoreClient", :path => "../" + + target 'SwaggerClientTests' do + inherit! :search_paths + end +end diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/LICENSE b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/LICENSE new file mode 100644 index 00000000000..bf300e4482e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/README.md b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/README.md new file mode 100644 index 00000000000..a109cdf9b2f --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/README.md @@ -0,0 +1,1149 @@ +![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/Alamofire/Alamofire/assets/alamofire.png) + +[![Build Status](https://travis-ci.org/Alamofire/Alamofire.svg)](https://travis-ci.org/Alamofire/Alamofire) +[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/Alamofire.svg)](https://img.shields.io/cocoapods/v/Alamofire.svg) +[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Platform](https://img.shields.io/cocoapods/p/Alamofire.svg?style=flat)](http://cocoadocs.org/docsets/Alamofire) +[![Twitter](https://img.shields.io/badge/twitter-@AlamofireSF-blue.svg?style=flat)](http://twitter.com/AlamofireSF) + +Alamofire is an HTTP networking library written in Swift. + +## Features + +- [x] Chainable Request / Response methods +- [x] URL / JSON / plist Parameter Encoding +- [x] Upload File / Data / Stream / MultipartFormData +- [x] Download using Request or Resume data +- [x] Authentication with NSURLCredential +- [x] HTTP Response Validation +- [x] TLS Certificate and Public Key Pinning +- [x] Progress Closure & NSProgress +- [x] cURL Debug Output +- [x] Comprehensive Unit Test Coverage +- [x] [Complete Documentation](http://cocoadocs.org/docsets/Alamofire) + +## Requirements + +- iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+ +- Xcode 7.2+ + +## Migration Guides + +- [Alamofire 3.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%203.0%20Migration%20Guide.md) +- [Alamofire 2.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%202.0%20Migration%20Guide.md) + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/alamofire). (Tag 'alamofire') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/alamofire). +- If you **found a bug**, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +## Installation + +> **Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9).** +> +> Alamofire is no longer supported on iOS 7 due to the lack of support for frameworks. Without frameworks, running Travis-CI against iOS 7 would require a second duplicated test target. The separate test suite would need to import all the Swift files and the tests would need to be duplicated and re-written. This split would be too difficult to maintain to ensure the highest possible quality of the Alamofire ecosystem. + +### CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +> CocoaPods 0.39.0+ is required to build Alamofire 3.0.0+. + +To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' +use_frameworks! + +pod 'Alamofire', '~> 3.0' +``` + +Then, run the following command: + +```bash +$ pod install +``` + +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "Alamofire/Alamofire" ~> 3.0 +``` + +Run `carthage update` to build the framework and drag the built `Alamofire.framework` into your Xcode project. + +### Manually + +If you prefer not to use either of the aforementioned dependency managers, you can integrate Alamofire into your project manually. + +#### Embedded Framework + +- Open up Terminal, `cd` into your top-level project directory, and run the following command "if" your project is not initialized as a git repository: + +```bash +$ git init +``` + +- Add Alamofire as a git [submodule](http://git-scm.com/docs/git-submodule) by running the following command: + +```bash +$ git submodule add https://github.com/Alamofire/Alamofire.git +``` + +- Open the new `Alamofire` folder, and drag the `Alamofire.xcodeproj` into the Project Navigator of your application's Xcode project. + + > It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter. + +- Select the `Alamofire.xcodeproj` in the Project Navigator and verify the deployment target matches that of your application target. +- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar. +- In the tab bar at the top of that window, open the "General" panel. +- Click on the `+` button under the "Embedded Binaries" section. +- You will see two different `Alamofire.xcodeproj` folders each with two different versions of the `Alamofire.framework` nested inside a `Products` folder. + + > It does not matter which `Products` folder you choose from, but it does matter whether you choose the top or bottom `Alamofire.framework`. + +- Select the top `Alamofire.framework` for iOS and the bottom one for OS X. + + > You can verify which one you selected by inspecting the build log for your project. The build target for `Alamofire` will be listed as either `Alamofire iOS` or `Alamofire OSX`. + +- And that's it! + +> The `Alamofire.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device. + +--- + +## Usage + +### Making a Request + +```swift +import Alamofire + +Alamofire.request(.GET, "https://httpbin.org/get") +``` + +### Response Handling + +```swift +Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) + .responseJSON { response in + print(response.request) // original URL request + print(response.response) // URL response + print(response.data) // server data + print(response.result) // result of response serialization + + if let JSON = response.result.value { + print("JSON: \(JSON)") + } + } +``` + +> Networking in Alamofire is done _asynchronously_. Asynchronous programming may be a source of frustration to programmers unfamiliar with the concept, but there are [very good reasons](https://developer.apple.com/library/ios/qa/qa1693/_index.html) for doing it this way. + +> Rather than blocking execution to wait for a response from the server, a [callback](http://en.wikipedia.org/wiki/Callback_%28computer_programming%29) is specified to handle the response once it's received. The result of a request is only available inside the scope of a response handler. Any execution contingent on the response or data received from the server must be done within a handler. + +### Response Serialization + +**Built-in Response Methods** + +- `response()` +- `responseData()` +- `responseString(encoding: NSStringEncoding)` +- `responseJSON(options: NSJSONReadingOptions)` +- `responsePropertyList(options: NSPropertyListReadOptions)` + +#### Response Handler + +```swift +Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) + .response { request, response, data, error in + print(request) + print(response) + print(data) + print(error) + } +``` + +> The `response` serializer does NOT evaluate any of the response data. It merely forwards on all the information directly from the URL session delegate. We strongly encourage you to leverage the other responser serializers taking advantage of `Response` and `Result` types. + +#### Response Data Handler + +```swift +Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) + .responseData { response in + print(response.request) + print(response.response) + print(response.result) + } +``` + +#### Response String Handler + +```swift +Alamofire.request(.GET, "https://httpbin.org/get") + .responseString { response in + print("Success: \(response.result.isSuccess)") + print("Response String: \(response.result.value)") + } +``` + +#### Response JSON Handler + +```swift +Alamofire.request(.GET, "https://httpbin.org/get") + .responseJSON { response in + debugPrint(response) + } +``` + +#### Chained Response Handlers + +Response handlers can even be chained: + +```swift +Alamofire.request(.GET, "https://httpbin.org/get") + .responseString { response in + print("Response String: \(response.result.value)") + } + .responseJSON { response in + print("Response JSON: \(response.result.value)") + } +``` + +### HTTP Methods + +`Alamofire.Method` lists the HTTP methods defined in [RFC 7231 §4.3](http://tools.ietf.org/html/rfc7231#section-4.3): + +```swift +public enum Method: String { + case OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT +} +``` + +These values can be passed as the first argument of the `Alamofire.request` method: + +```swift +Alamofire.request(.POST, "https://httpbin.org/post") + +Alamofire.request(.PUT, "https://httpbin.org/put") + +Alamofire.request(.DELETE, "https://httpbin.org/delete") +``` + +### Parameters + +#### GET Request With URL-Encoded Parameters + +```swift +Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) +// https://httpbin.org/get?foo=bar +``` + +#### POST Request With URL-Encoded Parameters + +```swift +let parameters = [ + "foo": "bar", + "baz": ["a", 1], + "qux": [ + "x": 1, + "y": 2, + "z": 3 + ] +] + +Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters) +// HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3 +``` + +### Parameter Encoding + +Parameters can also be encoded as JSON, Property List, or any custom format, using the `ParameterEncoding` enum: + +```swift +enum ParameterEncoding { + case URL + case URLEncodedInURL + case JSON + case PropertyList(format: NSPropertyListFormat, options: NSPropertyListWriteOptions) + case Custom((URLRequestConvertible, [String: AnyObject]?) -> (NSMutableURLRequest, NSError?)) + + func encode(request: NSURLRequest, parameters: [String: AnyObject]?) -> (NSURLRequest, NSError?) + { ... } +} +``` + +- `URL`: A query string to be set as or appended to any existing URL query for `GET`, `HEAD`, and `DELETE` requests, or set as the body for requests with any other HTTP method. The `Content-Type` HTTP header field of an encoded request with HTTP body is set to `application/x-www-form-urlencoded`. _Since there is no published specification for how to encode collection types, Alamofire follows the convention of appending `[]` to the key for array values (`foo[]=1&foo[]=2`), and appending the key surrounded by square brackets for nested dictionary values (`foo[bar]=baz`)._ +- `URLEncodedInURL`: Creates query string to be set as or appended to any existing URL query. Uses the same implementation as the `.URL` case, but always applies the encoded result to the URL. +- `JSON`: Uses `NSJSONSerialization` to create a JSON representation of the parameters object, which is set as the body of the request. The `Content-Type` HTTP header field of an encoded request is set to `application/json`. +- `PropertyList`: Uses `NSPropertyListSerialization` to create a plist representation of the parameters object, according to the associated format and write options values, which is set as the body of the request. The `Content-Type` HTTP header field of an encoded request is set to `application/x-plist`. +- `Custom`: Uses the associated closure value to construct a new request given an existing request and parameters. + +#### Manual Parameter Encoding of an NSURLRequest + +```swift +let URL = NSURL(string: "https://httpbin.org/get")! +var request = NSMutableURLRequest(URL: URL) + +let parameters = ["foo": "bar"] +let encoding = Alamofire.ParameterEncoding.URL +(request, _) = encoding.encode(request, parameters: parameters) +``` + +#### POST Request with JSON-encoded Parameters + +```swift +let parameters = [ + "foo": [1,2,3], + "bar": [ + "baz": "qux" + ] +] + +Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON) +// HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}} +``` + +### HTTP Headers + +Adding a custom HTTP header to a `Request` is supported directly in the global `request` method. This makes it easy to attach HTTP headers to a `Request` that can be constantly changing. + +> For HTTP headers that do not change, it is recommended to set them on the `NSURLSessionConfiguration` so they are automatically applied to any `NSURLSessionTask` created by the underlying `NSURLSession`. + +```swift +let headers = [ + "Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", + "Content-Type": "application/x-www-form-urlencoded" +] + +Alamofire.request(.GET, "https://httpbin.org/get", headers: headers) + .responseJSON { response in + debugPrint(response) + } +``` + +### Caching + +Caching is handled on the system framework level by [`NSURLCache`](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLCache_Class/Reference/Reference.html#//apple_ref/occ/cl/NSURLCache). + +### Uploading + +**Supported Upload Types** + +- File +- Data +- Stream +- MultipartFormData + +#### Uploading a File + +```swift +let fileURL = NSBundle.mainBundle().URLForResource("Default", withExtension: "png") +Alamofire.upload(.POST, "https://httpbin.org/post", file: fileURL) +``` + +#### Uploading with Progress + +```swift +Alamofire.upload(.POST, "https://httpbin.org/post", file: fileURL) + .progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in + print(totalBytesWritten) + + // This closure is NOT called on the main queue for performance + // reasons. To update your ui, dispatch to the main queue. + dispatch_async(dispatch_get_main_queue()) { + print("Total bytes written on main queue: \(totalBytesWritten)") + } + } + .responseJSON { response in + debugPrint(response) + } +``` + +#### Uploading MultipartFormData + +```swift +Alamofire.upload( + .POST, + "https://httpbin.org/post", + multipartFormData: { multipartFormData in + multipartFormData.appendBodyPart(fileURL: unicornImageURL, name: "unicorn") + multipartFormData.appendBodyPart(fileURL: rainbowImageURL, name: "rainbow") + }, + encodingCompletion: { encodingResult in + switch encodingResult { + case .Success(let upload, _, _): + upload.responseJSON { response in + debugPrint(response) + } + case .Failure(let encodingError): + print(encodingError) + } + } +) +``` + +### Downloading + +**Supported Download Types** + +- Request +- Resume Data + +#### Downloading a File + +```swift +Alamofire.download(.GET, "https://httpbin.org/stream/100") { temporaryURL, response in + let fileManager = NSFileManager.defaultManager() + let directoryURL = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] + let pathComponent = response.suggestedFilename + + return directoryURL.URLByAppendingPathComponent(pathComponent!) +} +``` + +#### Using the Default Download Destination + +```swift +let destination = Alamofire.Request.suggestedDownloadDestination(directory: .DocumentDirectory, domain: .UserDomainMask) +Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination) +``` + +#### Downloading a File w/Progress + +```swift +Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination) + .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in + print(totalBytesRead) + + // This closure is NOT called on the main queue for performance + // reasons. To update your ui, dispatch to the main queue. + dispatch_async(dispatch_get_main_queue()) { + print("Total bytes read on main queue: \(totalBytesRead)") + } + } + .response { _, _, _, error in + if let error = error { + print("Failed with error: \(error)") + } else { + print("Downloaded file successfully") + } + } +``` + +#### Accessing Resume Data for Failed Downloads + +```swift +Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination) + .response { _, _, data, _ in + if let + data = data, + resumeDataString = NSString(data: data, encoding: NSUTF8StringEncoding) + { + print("Resume Data: \(resumeDataString)") + } else { + print("Resume Data was empty") + } + } +``` + +> The `data` parameter is automatically populated with the `resumeData` if available. + +```swift +let download = Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination) +download.response { _, _, _, _ in + if let + resumeData = download.resumeData, + resumeDataString = NSString(data: resumeData, encoding: NSUTF8StringEncoding) + { + print("Resume Data: \(resumeDataString)") + } else { + print("Resume Data was empty") + } +} +``` + +### Authentication + +Authentication is handled on the system framework level by [`NSURLCredential` and `NSURLAuthenticationChallenge`](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLAuthenticationChallenge_Class/Reference/Reference.html). + +**Supported Authentication Schemes** + +- [HTTP Basic](http://en.wikipedia.org/wiki/Basic_access_authentication) +- [HTTP Digest](http://en.wikipedia.org/wiki/Digest_access_authentication) +- [Kerberos](http://en.wikipedia.org/wiki/Kerberos_%28protocol%29) +- [NTLM](http://en.wikipedia.org/wiki/NT_LAN_Manager) + +#### HTTP Basic Authentication + +The `authenticate` method on a `Request` will automatically provide an `NSURLCredential` to an `NSURLAuthenticationChallenge` when appropriate: + +```swift +let user = "user" +let password = "password" + +Alamofire.request(.GET, "https://httpbin.org/basic-auth/\(user)/\(password)") + .authenticate(user: user, password: password) + .responseJSON { response in + debugPrint(response) + } +``` + +Depending upon your server implementation, an `Authorization` header may also be appropriate: + +```swift +let user = "user" +let password = "password" + +let credentialData = "\(user):\(password)".dataUsingEncoding(NSUTF8StringEncoding)! +let base64Credentials = credentialData.base64EncodedStringWithOptions([]) + +let headers = ["Authorization": "Basic \(base64Credentials)"] + +Alamofire.request(.GET, "https://httpbin.org/basic-auth/user/password", headers: headers) + .responseJSON { response in + debugPrint(response) + } +``` + +#### Authentication with NSURLCredential + +```swift +let user = "user" +let password = "password" + +let credential = NSURLCredential(user: user, password: password, persistence: .ForSession) + +Alamofire.request(.GET, "https://httpbin.org/basic-auth/\(user)/\(password)") + .authenticate(usingCredential: credential) + .responseJSON { response in + debugPrint(response) + } +``` + +### Validation + +By default, Alamofire treats any completed request to be successful, regardless of the content of the response. Calling `validate` before a response handler causes an error to be generated if the response had an unacceptable status code or MIME type. + +#### Manual Validation + +```swift +Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) + .validate(statusCode: 200..<300) + .validate(contentType: ["application/json"]) + .response { response in + print(response) + } +``` + +#### Automatic Validation + +Automatically validates status code within `200...299` range, and that the `Content-Type` header of the response matches the `Accept` header of the request, if one is provided. + +```swift +Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) + .validate() + .responseJSON { response in + switch response.result { + case .Success: + print("Validation Successful") + case .Failure(let error): + print(error) + } + } +``` + +### Printable + +```swift +let request = Alamofire.request(.GET, "https://httpbin.org/ip") + +print(request) +// GET https://httpbin.org/ip (200) +``` + +### DebugPrintable + +```swift +let request = Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) + +debugPrint(request) +``` + +#### Output (cURL) + +```bash +$ curl -i \ + -H "User-Agent: Alamofire" \ + -H "Accept-Encoding: Accept-Encoding: gzip;q=1.0,compress;q=0.5" \ + -H "Accept-Language: en;q=1.0,fr;q=0.9,de;q=0.8,zh-Hans;q=0.7,zh-Hant;q=0.6,ja;q=0.5" \ + "https://httpbin.org/get?foo=bar" +``` + +--- + +## Advanced Usage + +> Alamofire is built on `NSURLSession` and the Foundation URL Loading System. To make the most of +this framework, it is recommended that you be familiar with the concepts and capabilities of the underlying networking stack. + +**Recommended Reading** + +- [URL Loading System Programming Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html) +- [NSURLSession Class Reference](https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSURLSession_class/Introduction/Introduction.html#//apple_ref/occ/cl/NSURLSession) +- [NSURLCache Class Reference](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLCache_Class/Reference/Reference.html#//apple_ref/occ/cl/NSURLCache) +- [NSURLAuthenticationChallenge Class Reference](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLAuthenticationChallenge_Class/Reference/Reference.html) + +### Manager + +Top-level convenience methods like `Alamofire.request` use a shared instance of `Alamofire.Manager`, which is configured with the default `NSURLSessionConfiguration`. + +As such, the following two statements are equivalent: + +```swift +Alamofire.request(.GET, "https://httpbin.org/get") +``` + +```swift +let manager = Alamofire.Manager.sharedInstance +manager.request(NSURLRequest(URL: NSURL(string: "https://httpbin.org/get")!)) +``` + +Applications can create managers for background and ephemeral sessions, as well as new managers that customize the default session configuration, such as for default headers (`HTTPAdditionalHeaders`) or timeout interval (`timeoutIntervalForRequest`). + +#### Creating a Manager with Default Configuration + +```swift +let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() +let manager = Alamofire.Manager(configuration: configuration) +``` + +#### Creating a Manager with Background Configuration + +```swift +let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("com.example.app.background") +let manager = Alamofire.Manager(configuration: configuration) +``` + +#### Creating a Manager with Ephemeral Configuration + +```swift +let configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration() +let manager = Alamofire.Manager(configuration: configuration) +``` + +#### Modifying Session Configuration + +```swift +var defaultHeaders = Alamofire.Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders ?? [:] +defaultHeaders["DNT"] = "1 (Do Not Track Enabled)" + +let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() +configuration.HTTPAdditionalHeaders = defaultHeaders + +let manager = Alamofire.Manager(configuration: configuration) +``` + +> This is **not** recommended for `Authorization` or `Content-Type` headers. Instead, use `URLRequestConvertible` and `ParameterEncoding`, respectively. + +### Request + +The result of a `request`, `upload`, or `download` method is an instance of `Alamofire.Request`. A request is always created using a constructor method from an owning manager, and never initialized directly. + +Methods like `authenticate`, `validate` and `responseData` return the caller in order to facilitate chaining. + +Requests can be suspended, resumed, and cancelled: + +- `suspend()`: Suspends the underlying task and dispatch queue +- `resume()`: Resumes the underlying task and dispatch queue. If the owning manager does not have `startRequestsImmediately` set to `true`, the request must call `resume()` in order to start. +- `cancel()`: Cancels the underlying task, producing an error that is passed to any registered response handlers. + +### Response Serialization + +#### Creating a Custom Response Serializer + +Alamofire provides built-in response serialization for strings, JSON, and property lists, but others can be added in extensions on `Alamofire.Request`. + +For example, here's how a response handler using [Ono](https://github.com/mattt/Ono) might be implemented: + +```swift +extension Request { + public static func XMLResponseSerializer() -> ResponseSerializer { + return ResponseSerializer { request, response, data, error in + guard error == nil else { return .Failure(error!) } + + guard let validData = data else { + let failureReason = "Data could not be serialized. Input data was nil." + let error = Error.errorWithCode(.DataSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + + do { + let XML = try ONOXMLDocument(data: validData) + return .Success(XML) + } catch { + return .Failure(error as NSError) + } + } + } + + public func responseXMLDocument(completionHandler: Response -> Void) -> Self { + return response(responseSerializer: Request.XMLResponseSerializer(), completionHandler: completionHandler) + } +} +``` + +#### Generic Response Object Serialization + +Generics can be used to provide automatic, type-safe response object serialization. + +```swift +public protocol ResponseObjectSerializable { + init?(response: NSHTTPURLResponse, representation: AnyObject) +} + +extension Request { + public func responseObject(completionHandler: Response -> Void) -> Self { + let responseSerializer = ResponseSerializer { request, response, data, error in + guard error == nil else { return .Failure(error!) } + + let JSONResponseSerializer = Request.JSONResponseSerializer(options: .AllowFragments) + let result = JSONResponseSerializer.serializeResponse(request, response, data, error) + + switch result { + case .Success(let value): + if let + response = response, + responseObject = T(response: response, representation: value) + { + return .Success(responseObject) + } else { + let failureReason = "JSON could not be serialized into response object: \(value)" + let error = Error.errorWithCode(.JSONSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + case .Failure(let error): + return .Failure(error) + } + } + + return response(responseSerializer: responseSerializer, completionHandler: completionHandler) + } +} +``` + +```swift +final class User: ResponseObjectSerializable { + let username: String + let name: String + + init?(response: NSHTTPURLResponse, representation: AnyObject) { + self.username = response.URL!.lastPathComponent! + self.name = representation.valueForKeyPath("name") as! String + } +} +``` + +```swift +Alamofire.request(.GET, "https://example.com/users/mattt") + .responseObject { (response: Response) in + debugPrint(response) + } +``` + +The same approach can also be used to handle endpoints that return a representation of a collection of objects: + +```swift +public protocol ResponseCollectionSerializable { + static func collection(response response: NSHTTPURLResponse, representation: AnyObject) -> [Self] +} + +extension Alamofire.Request { + public func responseCollection(completionHandler: Response<[T], NSError> -> Void) -> Self { + let responseSerializer = ResponseSerializer<[T], NSError> { request, response, data, error in + guard error == nil else { return .Failure(error!) } + + let JSONSerializer = Request.JSONResponseSerializer(options: .AllowFragments) + let result = JSONSerializer.serializeResponse(request, response, data, error) + + switch result { + case .Success(let value): + if let response = response { + return .Success(T.collection(response: response, representation: value)) + } else { + let failureReason = "Response collection could not be serialized due to nil response" + let error = Error.errorWithCode(.JSONSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + case .Failure(let error): + return .Failure(error) + } + } + + return response(responseSerializer: responseSerializer, completionHandler: completionHandler) + } +} +``` + +```swift +final class User: ResponseObjectSerializable, ResponseCollectionSerializable { + let username: String + let name: String + + init?(response: NSHTTPURLResponse, representation: AnyObject) { + self.username = response.URL!.lastPathComponent! + self.name = representation.valueForKeyPath("name") as! String + } + + static func collection(response response: NSHTTPURLResponse, representation: AnyObject) -> [User] { + var users: [User] = [] + + if let representation = representation as? [[String: AnyObject]] { + for userRepresentation in representation { + if let user = User(response: response, representation: userRepresentation) { + users.append(user) + } + } + } + + return users + } +} +``` + +```swift +Alamofire.request(.GET, "http://example.com/users") + .responseCollection { (response: Response<[User], NSError>) in + debugPrint(response) + } +``` + +### URLStringConvertible + +Types adopting the `URLStringConvertible` protocol can be used to construct URL strings, which are then used to construct URL requests. `NSString`, `NSURL`, `NSURLComponents`, and `NSURLRequest` conform to `URLStringConvertible` by default, allowing any of them to be passed as `URLString` parameters to the `request`, `upload`, and `download` methods: + +```swift +let string = NSString(string: "https://httpbin.org/post") +Alamofire.request(.POST, string) + +let URL = NSURL(string: string)! +Alamofire.request(.POST, URL) + +let URLRequest = NSURLRequest(URL: URL) +Alamofire.request(.POST, URLRequest) // overrides `HTTPMethod` of `URLRequest` + +let URLComponents = NSURLComponents(URL: URL, resolvingAgainstBaseURL: true) +Alamofire.request(.POST, URLComponents) +``` + +Applications interacting with web applications in a significant manner are encouraged to have custom types conform to `URLStringConvertible` as a convenient way to map domain-specific models to server resources. + +#### Type-Safe Routing + +```swift +extension User: URLStringConvertible { + static let baseURLString = "http://example.com" + + var URLString: String { + return User.baseURLString + "/users/\(username)/" + } +} +``` + +```swift +let user = User(username: "mattt") +Alamofire.request(.GET, user) // http://example.com/users/mattt +``` + +### URLRequestConvertible + +Types adopting the `URLRequestConvertible` protocol can be used to construct URL requests. `NSURLRequest` conforms to `URLRequestConvertible` by default, allowing it to be passed into `request`, `upload`, and `download` methods directly (this is the recommended way to specify custom HTTP body for individual requests): + +```swift +let URL = NSURL(string: "https://httpbin.org/post")! +let mutableURLRequest = NSMutableURLRequest(URL: URL) +mutableURLRequest.HTTPMethod = "POST" + +let parameters = ["foo": "bar"] + +do { + mutableURLRequest.HTTPBody = try NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions()) +} catch { + // No-op +} + +mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + +Alamofire.request(mutableURLRequest) +``` + +Applications interacting with web applications in a significant manner are encouraged to have custom types conform to `URLRequestConvertible` as a way to ensure consistency of requested endpoints. Such an approach can be used to abstract away server-side inconsistencies and provide type-safe routing, as well as manage authentication credentials and other state. + +#### API Parameter Abstraction + +```swift +enum Router: URLRequestConvertible { + static let baseURLString = "http://example.com" + static let perPage = 50 + + case Search(query: String, page: Int) + + // MARK: URLRequestConvertible + + var URLRequest: NSMutableURLRequest { + let result: (path: String, parameters: [String: AnyObject]) = { + switch self { + case .Search(let query, let page) where page > 1: + return ("/search", ["q": query, "offset": Router.perPage * page]) + case .Search(let query, _): + return ("/search", ["q": query]) + } + }() + + let URL = NSURL(string: Router.baseURLString)! + let URLRequest = NSURLRequest(URL: URL.URLByAppendingPathComponent(result.path)) + let encoding = Alamofire.ParameterEncoding.URL + + return encoding.encode(URLRequest, parameters: result.parameters).0 + } +} +``` + +```swift +Alamofire.request(Router.Search(query: "foo bar", page: 1)) // ?q=foo%20bar&offset=50 +``` + +#### CRUD & Authorization + +```swift +enum Router: URLRequestConvertible { + static let baseURLString = "http://example.com" + static var OAuthToken: String? + + case CreateUser([String: AnyObject]) + case ReadUser(String) + case UpdateUser(String, [String: AnyObject]) + case DestroyUser(String) + + var method: Alamofire.Method { + switch self { + case .CreateUser: + return .POST + case .ReadUser: + return .GET + case .UpdateUser: + return .PUT + case .DestroyUser: + return .DELETE + } + } + + var path: String { + switch self { + case .CreateUser: + return "/users" + case .ReadUser(let username): + return "/users/\(username)" + case .UpdateUser(let username, _): + return "/users/\(username)" + case .DestroyUser(let username): + return "/users/\(username)" + } + } + + // MARK: URLRequestConvertible + + var URLRequest: NSMutableURLRequest { + let URL = NSURL(string: Router.baseURLString)! + let mutableURLRequest = NSMutableURLRequest(URL: URL.URLByAppendingPathComponent(path)) + mutableURLRequest.HTTPMethod = method.rawValue + + if let token = Router.OAuthToken { + mutableURLRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + } + + switch self { + case .CreateUser(let parameters): + return Alamofire.ParameterEncoding.JSON.encode(mutableURLRequest, parameters: parameters).0 + case .UpdateUser(_, let parameters): + return Alamofire.ParameterEncoding.URL.encode(mutableURLRequest, parameters: parameters).0 + default: + return mutableURLRequest + } + } +} +``` + +```swift +Alamofire.request(Router.ReadUser("mattt")) // GET /users/mattt +``` + +### Security + +Using a secure HTTPS connection when communicating with servers and web services is an important step in securing sensitive data. By default, Alamofire will evaluate the certificate chain provided by the server using Apple's built in validation provided by the Security framework. While this guarantees the certificate chain is valid, it does not prevent man-in-the-middle (MITM) attacks or other potential vulnerabilities. In order to mitigate MITM attacks, applications dealing with sensitive customer data or financial information should use certificate or public key pinning provided by the `ServerTrustPolicy`. + +#### ServerTrustPolicy + +The `ServerTrustPolicy` enumeration evaluates the server trust generally provided by an `NSURLAuthenticationChallenge` when connecting to a server over a secure HTTPS connection. + +```swift +let serverTrustPolicy = ServerTrustPolicy.PinCertificates( + certificates: ServerTrustPolicy.certificatesInBundle(), + validateCertificateChain: true, + validateHost: true +) +``` + +There are many different cases of server trust evaluation giving you complete control over the validation process: + +* `PerformDefaultEvaluation`: Uses the default server trust evaluation while allowing you to control whether to validate the host provided by the challenge. +* `PinCertificates`: Uses the pinned certificates to validate the server trust. The server trust is considered valid if one of the pinned certificates match one of the server certificates. +* `PinPublicKeys`: Uses the pinned public keys to validate the server trust. The server trust is considered valid if one of the pinned public keys match one of the server certificate public keys. +* `DisableEvaluation`: Disables all evaluation which in turn will always consider any server trust as valid. +* `CustomEvaluation`: Uses the associated closure to evaluate the validity of the server trust thus giving you complete control over the validation process. Use with caution. + +#### Server Trust Policy Manager + +The `ServerTrustPolicyManager` is responsible for storing an internal mapping of server trust policies to a particular host. This allows Alamofire to evaluate each host against a different server trust policy. + +```swift +let serverTrustPolicies: [String: ServerTrustPolicy] = [ + "test.example.com": .PinCertificates( + certificates: ServerTrustPolicy.certificatesInBundle(), + validateCertificateChain: true, + validateHost: true + ), + "insecure.expired-apis.com": .DisableEvaluation +] + +let manager = Manager( + serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies) +) +``` + +> Make sure to keep a reference to the new `Manager` instance, otherwise your requests will all get cancelled when your `manager` is deallocated. + +These server trust policies will result in the following behavior: + +* `test.example.com` will always use certificate pinning with certificate chain and host validation enabled thus requiring the following criteria to be met to allow the TLS handshake to succeed: + * Certificate chain MUST be valid. + * Certificate chain MUST include one of the pinned certificates. + * Challenge host MUST match the host in the certificate chain's leaf certificate. +* `insecure.expired-apis.com` will never evaluate the certificate chain and will always allow the TLS handshake to succeed. +* All other hosts will use the default evaluation provided by Apple. + +##### Subclassing Server Trust Policy Manager + +If you find yourself needing more flexible server trust policy matching behavior (i.e. wildcarded domains), then subclass the `ServerTrustPolicyManager` and override the `serverTrustPolicyForHost` method with your own custom implementation. + +```swift +class CustomServerTrustPolicyManager: ServerTrustPolicyManager { + override func serverTrustPolicyForHost(host: String) -> ServerTrustPolicy? { + var policy: ServerTrustPolicy? + + // Implement your custom domain matching behavior... + + return policy + } +} +``` + +#### Validating the Host + +The `.PerformDefaultEvaluation`, `.PinCertificates` and `.PinPublicKeys` server trust policies all take a `validateHost` parameter. Setting the value to `true` will cause the server trust evaluation to verify that hostname in the certificate matches the hostname of the challenge. If they do not match, evaluation will fail. A `validateHost` value of `false` will still evaluate the full certificate chain, but will not validate the hostname of the leaf certificate. + +> It is recommended that `validateHost` always be set to `true` in production environments. + +#### Validating the Certificate Chain + +Pinning certificates and public keys both have the option of validating the certificate chain using the `validateCertificateChain` parameter. By setting this value to `true`, the full certificate chain will be evaluated in addition to performing a byte equality check against the pinned certficates or public keys. A value of `false` will skip the certificate chain validation, but will still perform the byte equality check. + +There are several cases where it may make sense to disable certificate chain validation. The most common use cases for disabling validation are self-signed and expired certificates. The evaluation would always fail in both of these cases, but the byte equality check will still ensure you are receiving the certificate you expect from the server. + +> It is recommended that `validateCertificateChain` always be set to `true` in production environments. + +#### App Transport Security + +With the addition of App Transport Security (ATS) in iOS 9, it is possible that using a custom `ServerTrustPolicyManager` with several `ServerTrustPolicy` objects will have no effect. If you continuously see `CFNetwork SSLHandshake failed (-9806)` errors, you have probably run into this problem. Apple's ATS system overrides the entire challenge system unless you configure the ATS settings in your app's plist to disable enough of it to allow your app to evaluate the server trust. + +If you run into this problem (high probability with self-signed certificates), you can work around this issue by adding the following to your `Info.plist`. + +```xml + + NSAppTransportSecurity + + NSExceptionDomains + + example.com + + NSExceptionAllowsInsecureHTTPLoads + + NSExceptionRequiresForwardSecrecy + + NSIncludesSubdomains + + + NSTemporaryExceptionMinimumTLSVersion + TLSv1.2 + + + + +``` + +Whether you need to set the `NSExceptionRequiresForwardSecrecy` to `NO` depends on whether your TLS connection is using an allowed cipher suite. In certain cases, it will need to be set to `NO`. The `NSExceptionAllowsInsecureHTTPLoads` MUST be set to `YES` in order to allow the `SessionDelegate` to receive challenge callbacks. Once the challenge callbacks are being called, the `ServerTrustPolicyManager` will take over the server trust evaluation. You may also need to specify the `NSTemporaryExceptionMinimumTLSVersion` if you're trying to connect to a host that only supports TLS versions less than `1.2`. + +> It is recommended to always use valid certificates in production environments. + +--- + +## Component Libraries + +In order to keep Alamofire focused specifically on core networking implementations, additional component libraries have been created by the [Alamofire Software Foundation](https://github.com/Alamofire/Foundation) to bring additional functionality to the Alamofire ecosystem. + +* [AlamofireImage](https://github.com/Alamofire/AlamofireImage) - An image library including image response serializers, `UIImage` and `UIImageView` extensions, custom image filters, an auto-purging in-memory cache and a priority-based image downloading system. + +## Open Rdars + +The following rdars have some affect on the current implementation of Alamofire. + +* [rdar://21349340](http://www.openradar.me/radar?id=5517037090635776) - Compiler throwing warning due to toll-free bridging issue in test case + +## FAQ + +### What's the origin of the name Alamofire? + +Alamofire is named after the [Alamo Fire flower](https://aggie-horticulture.tamu.edu/wildseed/alamofire.html), a hybrid variant of the Bluebonnet, the official state flower of Texas. + +--- + +## Credits + +Alamofire is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). You can follow them on Twitter at [@AlamofireSF](https://twitter.com/AlamofireSF) for project updates and releases. + +### Security Disclosure + +If you believe you have identified a security vulnerability with Alamofire, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## License + +Alamofire is released under the MIT license. See LICENSE for details. diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Alamofire.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Alamofire.swift new file mode 100644 index 00000000000..5a8bf14e3bf --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Alamofire.swift @@ -0,0 +1,368 @@ +// Alamofire.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +// MARK: - URLStringConvertible + +/** + Types adopting the `URLStringConvertible` protocol can be used to construct URL strings, which are then used to + construct URL requests. +*/ +public protocol URLStringConvertible { + /** + A URL that conforms to RFC 2396. + + Methods accepting a `URLStringConvertible` type parameter parse it according to RFCs 1738 and 1808. + + See https://tools.ietf.org/html/rfc2396 + See https://tools.ietf.org/html/rfc1738 + See https://tools.ietf.org/html/rfc1808 + */ + var URLString: String { get } +} + +extension String: URLStringConvertible { + public var URLString: String { + return self + } +} + +extension NSURL: URLStringConvertible { + public var URLString: String { + return absoluteString + } +} + +extension NSURLComponents: URLStringConvertible { + public var URLString: String { + return URL!.URLString + } +} + +extension NSURLRequest: URLStringConvertible { + public var URLString: String { + return URL!.URLString + } +} + +// MARK: - URLRequestConvertible + +/** + Types adopting the `URLRequestConvertible` protocol can be used to construct URL requests. +*/ +public protocol URLRequestConvertible { + /// The URL request. + var URLRequest: NSMutableURLRequest { get } +} + +extension NSURLRequest: URLRequestConvertible { + public var URLRequest: NSMutableURLRequest { + return self.mutableCopy() as! NSMutableURLRequest + } +} + +// MARK: - Convenience + +func URLRequest( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil) + -> NSMutableURLRequest +{ + let mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: URLString.URLString)!) + mutableURLRequest.HTTPMethod = method.rawValue + + if let headers = headers { + for (headerField, headerValue) in headers { + mutableURLRequest.setValue(headerValue, forHTTPHeaderField: headerField) + } + } + + return mutableURLRequest +} + +// MARK: - Request Methods + +/** + Creates a request using the shared manager instance for the specified method, URL string, parameters, and + parameter encoding. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter parameters: The parameters. `nil` by default. + - parameter encoding: The parameter encoding. `.URL` by default. + - parameter headers: The HTTP headers. `nil` by default. + + - returns: The created request. +*/ +public func request( + method: Method, + _ URLString: URLStringConvertible, + parameters: [String: AnyObject]? = nil, + encoding: ParameterEncoding = .URL, + headers: [String: String]? = nil) + -> Request +{ + return Manager.sharedInstance.request( + method, + URLString, + parameters: parameters, + encoding: encoding, + headers: headers + ) +} + +/** + Creates a request using the shared manager instance for the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request + + - returns: The created request. +*/ +public func request(URLRequest: URLRequestConvertible) -> Request { + return Manager.sharedInstance.request(URLRequest.URLRequest) +} + +// MARK: - Upload Methods + +// MARK: File + +/** + Creates an upload request using the shared manager instance for the specified method, URL string, and file. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter file: The file to upload. + + - returns: The created upload request. +*/ +public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + file: NSURL) + -> Request +{ + return Manager.sharedInstance.upload(method, URLString, headers: headers, file: file) +} + +/** + Creates an upload request using the shared manager instance for the specified URL request and file. + + - parameter URLRequest: The URL request. + - parameter file: The file to upload. + + - returns: The created upload request. +*/ +public func upload(URLRequest: URLRequestConvertible, file: NSURL) -> Request { + return Manager.sharedInstance.upload(URLRequest, file: file) +} + +// MARK: Data + +/** + Creates an upload request using the shared manager instance for the specified method, URL string, and data. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter data: The data to upload. + + - returns: The created upload request. +*/ +public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + data: NSData) + -> Request +{ + return Manager.sharedInstance.upload(method, URLString, headers: headers, data: data) +} + +/** + Creates an upload request using the shared manager instance for the specified URL request and data. + + - parameter URLRequest: The URL request. + - parameter data: The data to upload. + + - returns: The created upload request. +*/ +public func upload(URLRequest: URLRequestConvertible, data: NSData) -> Request { + return Manager.sharedInstance.upload(URLRequest, data: data) +} + +// MARK: Stream + +/** + Creates an upload request using the shared manager instance for the specified method, URL string, and stream. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter stream: The stream to upload. + + - returns: The created upload request. +*/ +public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + stream: NSInputStream) + -> Request +{ + return Manager.sharedInstance.upload(method, URLString, headers: headers, stream: stream) +} + +/** + Creates an upload request using the shared manager instance for the specified URL request and stream. + + - parameter URLRequest: The URL request. + - parameter stream: The stream to upload. + + - returns: The created upload request. +*/ +public func upload(URLRequest: URLRequestConvertible, stream: NSInputStream) -> Request { + return Manager.sharedInstance.upload(URLRequest, stream: stream) +} + +// MARK: MultipartFormData + +/** + Creates an upload request using the shared manager instance for the specified method and URL string. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. + - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. + `MultipartFormDataEncodingMemoryThreshold` by default. + - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. +*/ +public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + multipartFormData: MultipartFormData -> Void, + encodingMemoryThreshold: UInt64 = Manager.MultipartFormDataEncodingMemoryThreshold, + encodingCompletion: (Manager.MultipartFormDataEncodingResult -> Void)?) +{ + return Manager.sharedInstance.upload( + method, + URLString, + headers: headers, + multipartFormData: multipartFormData, + encodingMemoryThreshold: encodingMemoryThreshold, + encodingCompletion: encodingCompletion + ) +} + +/** + Creates an upload request using the shared manager instance for the specified method and URL string. + + - parameter URLRequest: The URL request. + - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. + - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. + `MultipartFormDataEncodingMemoryThreshold` by default. + - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. +*/ +public func upload( + URLRequest: URLRequestConvertible, + multipartFormData: MultipartFormData -> Void, + encodingMemoryThreshold: UInt64 = Manager.MultipartFormDataEncodingMemoryThreshold, + encodingCompletion: (Manager.MultipartFormDataEncodingResult -> Void)?) +{ + return Manager.sharedInstance.upload( + URLRequest, + multipartFormData: multipartFormData, + encodingMemoryThreshold: encodingMemoryThreshold, + encodingCompletion: encodingCompletion + ) +} + +// MARK: - Download Methods + +// MARK: URL Request + +/** + Creates a download request using the shared manager instance for the specified method and URL string. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter parameters: The parameters. `nil` by default. + - parameter encoding: The parameter encoding. `.URL` by default. + - parameter headers: The HTTP headers. `nil` by default. + - parameter destination: The closure used to determine the destination of the downloaded file. + + - returns: The created download request. +*/ +public func download( + method: Method, + _ URLString: URLStringConvertible, + parameters: [String: AnyObject]? = nil, + encoding: ParameterEncoding = .URL, + headers: [String: String]? = nil, + destination: Request.DownloadFileDestination) + -> Request +{ + return Manager.sharedInstance.download( + method, + URLString, + parameters: parameters, + encoding: encoding, + headers: headers, + destination: destination + ) +} + +/** + Creates a download request using the shared manager instance for the specified URL request. + + - parameter URLRequest: The URL request. + - parameter destination: The closure used to determine the destination of the downloaded file. + + - returns: The created download request. +*/ +public func download(URLRequest: URLRequestConvertible, destination: Request.DownloadFileDestination) -> Request { + return Manager.sharedInstance.download(URLRequest, destination: destination) +} + +// MARK: Resume Data + +/** + Creates a request using the shared manager instance for downloading from the resume data produced from a + previous request cancellation. + + - parameter resumeData: The resume data. This is an opaque data blob produced by `NSURLSessionDownloadTask` + when a task is cancelled. See `NSURLSession -downloadTaskWithResumeData:` for additional + information. + - parameter destination: The closure used to determine the destination of the downloaded file. + + - returns: The created download request. +*/ +public func download(resumeData data: NSData, destination: Request.DownloadFileDestination) -> Request { + return Manager.sharedInstance.download(data, destination: destination) +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Download.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Download.swift new file mode 100644 index 00000000000..22dd402a765 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Download.swift @@ -0,0 +1,244 @@ +// Download.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +extension Manager { + private enum Downloadable { + case Request(NSURLRequest) + case ResumeData(NSData) + } + + private func download(downloadable: Downloadable, destination: Request.DownloadFileDestination) -> Request { + var downloadTask: NSURLSessionDownloadTask! + + switch downloadable { + case .Request(let request): + dispatch_sync(queue) { + downloadTask = self.session.downloadTaskWithRequest(request) + } + case .ResumeData(let resumeData): + dispatch_sync(queue) { + downloadTask = self.session.downloadTaskWithResumeData(resumeData) + } + } + + let request = Request(session: session, task: downloadTask) + + if let downloadDelegate = request.delegate as? Request.DownloadTaskDelegate { + downloadDelegate.downloadTaskDidFinishDownloadingToURL = { session, downloadTask, URL in + return destination(URL, downloadTask.response as! NSHTTPURLResponse) + } + } + + delegate[request.delegate.task] = request.delegate + + if startRequestsImmediately { + request.resume() + } + + return request + } + + // MARK: Request + + /** + Creates a download request for the specified method, URL string, parameters, parameter encoding, headers + and destination. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter parameters: The parameters. `nil` by default. + - parameter encoding: The parameter encoding. `.URL` by default. + - parameter headers: The HTTP headers. `nil` by default. + - parameter destination: The closure used to determine the destination of the downloaded file. + + - returns: The created download request. + */ + public func download( + method: Method, + _ URLString: URLStringConvertible, + parameters: [String: AnyObject]? = nil, + encoding: ParameterEncoding = .URL, + headers: [String: String]? = nil, + destination: Request.DownloadFileDestination) + -> Request + { + let mutableURLRequest = URLRequest(method, URLString, headers: headers) + let encodedURLRequest = encoding.encode(mutableURLRequest, parameters: parameters).0 + + return download(encodedURLRequest, destination: destination) + } + + /** + Creates a request for downloading from the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request + - parameter destination: The closure used to determine the destination of the downloaded file. + + - returns: The created download request. + */ + public func download(URLRequest: URLRequestConvertible, destination: Request.DownloadFileDestination) -> Request { + return download(.Request(URLRequest.URLRequest), destination: destination) + } + + // MARK: Resume Data + + /** + Creates a request for downloading from the resume data produced from a previous request cancellation. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter resumeData: The resume data. This is an opaque data blob produced by `NSURLSessionDownloadTask` + when a task is cancelled. See `NSURLSession -downloadTaskWithResumeData:` for + additional information. + - parameter destination: The closure used to determine the destination of the downloaded file. + + - returns: The created download request. + */ + public func download(resumeData: NSData, destination: Request.DownloadFileDestination) -> Request { + return download(.ResumeData(resumeData), destination: destination) + } +} + +// MARK: - + +extension Request { + /** + A closure executed once a request has successfully completed in order to determine where to move the temporary + file written to during the download process. The closure takes two arguments: the temporary file URL and the URL + response, and returns a single argument: the file URL where the temporary file should be moved. + */ + public typealias DownloadFileDestination = (NSURL, NSHTTPURLResponse) -> NSURL + + /** + Creates a download file destination closure which uses the default file manager to move the temporary file to a + file URL in the first available directory with the specified search path directory and search path domain mask. + + - parameter directory: The search path directory. `.DocumentDirectory` by default. + - parameter domain: The search path domain mask. `.UserDomainMask` by default. + + - returns: A download file destination closure. + */ + public class func suggestedDownloadDestination( + directory directory: NSSearchPathDirectory = .DocumentDirectory, + domain: NSSearchPathDomainMask = .UserDomainMask) + -> DownloadFileDestination + { + return { temporaryURL, response -> NSURL in + let directoryURLs = NSFileManager.defaultManager().URLsForDirectory(directory, inDomains: domain) + + if !directoryURLs.isEmpty { + return directoryURLs[0].URLByAppendingPathComponent(response.suggestedFilename!) + } + + return temporaryURL + } + } + + /// The resume data of the underlying download task if available after a failure. + public var resumeData: NSData? { + var data: NSData? + + if let delegate = delegate as? DownloadTaskDelegate { + data = delegate.resumeData + } + + return data + } + + // MARK: - DownloadTaskDelegate + + class DownloadTaskDelegate: TaskDelegate, NSURLSessionDownloadDelegate { + var downloadTask: NSURLSessionDownloadTask? { return task as? NSURLSessionDownloadTask } + var downloadProgress: ((Int64, Int64, Int64) -> Void)? + + var resumeData: NSData? + override var data: NSData? { return resumeData } + + // MARK: - NSURLSessionDownloadDelegate + + // MARK: Override Closures + + var downloadTaskDidFinishDownloadingToURL: ((NSURLSession, NSURLSessionDownloadTask, NSURL) -> NSURL)? + var downloadTaskDidWriteData: ((NSURLSession, NSURLSessionDownloadTask, Int64, Int64, Int64) -> Void)? + var downloadTaskDidResumeAtOffset: ((NSURLSession, NSURLSessionDownloadTask, Int64, Int64) -> Void)? + + // MARK: Delegate Methods + + func URLSession( + session: NSURLSession, + downloadTask: NSURLSessionDownloadTask, + didFinishDownloadingToURL location: NSURL) + { + if let downloadTaskDidFinishDownloadingToURL = downloadTaskDidFinishDownloadingToURL { + do { + let destination = downloadTaskDidFinishDownloadingToURL(session, downloadTask, location) + try NSFileManager.defaultManager().moveItemAtURL(location, toURL: destination) + } catch { + self.error = error as NSError + } + } + } + + func URLSession( + session: NSURLSession, + downloadTask: NSURLSessionDownloadTask, + didWriteData bytesWritten: Int64, + totalBytesWritten: Int64, + totalBytesExpectedToWrite: Int64) + { + if let downloadTaskDidWriteData = downloadTaskDidWriteData { + downloadTaskDidWriteData( + session, + downloadTask, + bytesWritten, + totalBytesWritten, + totalBytesExpectedToWrite + ) + } else { + progress.totalUnitCount = totalBytesExpectedToWrite + progress.completedUnitCount = totalBytesWritten + + downloadProgress?(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) + } + } + + func URLSession( + session: NSURLSession, + downloadTask: NSURLSessionDownloadTask, + didResumeAtOffset fileOffset: Int64, + expectedTotalBytes: Int64) + { + if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset { + downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes) + } else { + progress.totalUnitCount = expectedTotalBytes + progress.completedUnitCount = fileOffset + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Error.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Error.swift new file mode 100644 index 00000000000..7a813f1b813 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Error.swift @@ -0,0 +1,66 @@ +// Error.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/// The `Error` struct provides a convenience for creating custom Alamofire NSErrors. +public struct Error { + /// The domain used for creating all Alamofire errors. + public static let Domain = "com.alamofire.error" + + /// The custom error codes generated by Alamofire. + public enum Code: Int { + case InputStreamReadFailed = -6000 + case OutputStreamWriteFailed = -6001 + case ContentTypeValidationFailed = -6002 + case StatusCodeValidationFailed = -6003 + case DataSerializationFailed = -6004 + case StringSerializationFailed = -6005 + case JSONSerializationFailed = -6006 + case PropertyListSerializationFailed = -6007 + } + + /** + Creates an `NSError` with the given error code and failure reason. + + - parameter code: The error code. + - parameter failureReason: The failure reason. + + - returns: An `NSError` with the given error code and failure reason. + */ + public static func errorWithCode(code: Code, failureReason: String) -> NSError { + return errorWithCode(code.rawValue, failureReason: failureReason) + } + + /** + Creates an `NSError` with the given error code and failure reason. + + - parameter code: The error code. + - parameter failureReason: The failure reason. + + - returns: An `NSError` with the given error code and failure reason. + */ + public static func errorWithCode(code: Int, failureReason: String) -> NSError { + let userInfo = [NSLocalizedFailureReasonErrorKey: failureReason] + return NSError(domain: Domain, code: code, userInfo: userInfo) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Manager.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Manager.swift new file mode 100644 index 00000000000..4051baf2403 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Manager.swift @@ -0,0 +1,693 @@ +// Manager.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/** + Responsible for creating and managing `Request` objects, as well as their underlying `NSURLSession`. +*/ +public class Manager { + + // MARK: - Properties + + /** + A shared instance of `Manager`, used by top-level Alamofire request methods, and suitable for use directly + for any ad hoc requests. + */ + public static let sharedInstance: Manager = { + let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() + configuration.HTTPAdditionalHeaders = Manager.defaultHTTPHeaders + + return Manager(configuration: configuration) + }() + + /** + Creates default values for the "Accept-Encoding", "Accept-Language" and "User-Agent" headers. + */ + public static let defaultHTTPHeaders: [String: String] = { + // Accept-Encoding HTTP Header; see https://tools.ietf.org/html/rfc7230#section-4.2.3 + let acceptEncoding: String = "gzip;q=1.0, compress;q=0.5" + + // Accept-Language HTTP Header; see https://tools.ietf.org/html/rfc7231#section-5.3.5 + let acceptLanguage = NSLocale.preferredLanguages().prefix(6).enumerate().map { index, languageCode in + let quality = 1.0 - (Double(index) * 0.1) + return "\(languageCode);q=\(quality)" + }.joinWithSeparator(", ") + + // User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3 + let userAgent: String = { + if let info = NSBundle.mainBundle().infoDictionary { + let executable: AnyObject = info[kCFBundleExecutableKey as String] ?? "Unknown" + let bundle: AnyObject = info[kCFBundleIdentifierKey as String] ?? "Unknown" + let version: AnyObject = info[kCFBundleVersionKey as String] ?? "Unknown" + let os: AnyObject = NSProcessInfo.processInfo().operatingSystemVersionString ?? "Unknown" + + var mutableUserAgent = NSMutableString(string: "\(executable)/\(bundle) (\(version); OS \(os))") as CFMutableString + let transform = NSString(string: "Any-Latin; Latin-ASCII; [:^ASCII:] Remove") as CFString + + if CFStringTransform(mutableUserAgent, UnsafeMutablePointer(nil), transform, false) { + return mutableUserAgent as String + } + } + + return "Alamofire" + }() + + return [ + "Accept-Encoding": acceptEncoding, + "Accept-Language": acceptLanguage, + "User-Agent": userAgent + ] + }() + + let queue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL) + + /// The underlying session. + public let session: NSURLSession + + /// The session delegate handling all the task and session delegate callbacks. + public let delegate: SessionDelegate + + /// Whether to start requests immediately after being constructed. `true` by default. + public var startRequestsImmediately: Bool = true + + /** + The background completion handler closure provided by the UIApplicationDelegate + `application:handleEventsForBackgroundURLSession:completionHandler:` method. By setting the background + completion handler, the SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` closure implementation + will automatically call the handler. + + If you need to handle your own events before the handler is called, then you need to override the + SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` and manually call the handler when finished. + + `nil` by default. + */ + public var backgroundCompletionHandler: (() -> Void)? + + // MARK: - Lifecycle + + /** + Initializes the `Manager` instance with the specified configuration, delegate and server trust policy. + + - parameter configuration: The configuration used to construct the managed session. + `NSURLSessionConfiguration.defaultSessionConfiguration()` by default. + - parameter delegate: The delegate used when initializing the session. `SessionDelegate()` by + default. + - parameter serverTrustPolicyManager: The server trust policy manager to use for evaluating all server trust + challenges. `nil` by default. + + - returns: The new `Manager` instance. + */ + public init( + configuration: NSURLSessionConfiguration = NSURLSessionConfiguration.defaultSessionConfiguration(), + delegate: SessionDelegate = SessionDelegate(), + serverTrustPolicyManager: ServerTrustPolicyManager? = nil) + { + self.delegate = delegate + self.session = NSURLSession(configuration: configuration, delegate: delegate, delegateQueue: nil) + + commonInit(serverTrustPolicyManager: serverTrustPolicyManager) + } + + /** + Initializes the `Manager` instance with the specified session, delegate and server trust policy. + + - parameter session: The URL session. + - parameter delegate: The delegate of the URL session. Must equal the URL session's delegate. + - parameter serverTrustPolicyManager: The server trust policy manager to use for evaluating all server trust + challenges. `nil` by default. + + - returns: The new `Manager` instance if the URL session's delegate matches the delegate parameter. + */ + public init?( + session: NSURLSession, + delegate: SessionDelegate, + serverTrustPolicyManager: ServerTrustPolicyManager? = nil) + { + self.delegate = delegate + self.session = session + + guard delegate === session.delegate else { return nil } + + commonInit(serverTrustPolicyManager: serverTrustPolicyManager) + } + + private func commonInit(serverTrustPolicyManager serverTrustPolicyManager: ServerTrustPolicyManager?) { + session.serverTrustPolicyManager = serverTrustPolicyManager + + delegate.sessionDidFinishEventsForBackgroundURLSession = { [weak self] session in + guard let strongSelf = self else { return } + dispatch_async(dispatch_get_main_queue()) { strongSelf.backgroundCompletionHandler?() } + } + } + + deinit { + session.invalidateAndCancel() + } + + // MARK: - Request + + /** + Creates a request for the specified method, URL string, parameters, parameter encoding and headers. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter parameters: The parameters. `nil` by default. + - parameter encoding: The parameter encoding. `.URL` by default. + - parameter headers: The HTTP headers. `nil` by default. + + - returns: The created request. + */ + public func request( + method: Method, + _ URLString: URLStringConvertible, + parameters: [String: AnyObject]? = nil, + encoding: ParameterEncoding = .URL, + headers: [String: String]? = nil) + -> Request + { + let mutableURLRequest = URLRequest(method, URLString, headers: headers) + let encodedURLRequest = encoding.encode(mutableURLRequest, parameters: parameters).0 + return request(encodedURLRequest) + } + + /** + Creates a request for the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request + + - returns: The created request. + */ + public func request(URLRequest: URLRequestConvertible) -> Request { + var dataTask: NSURLSessionDataTask! + dispatch_sync(queue) { dataTask = self.session.dataTaskWithRequest(URLRequest.URLRequest) } + + let request = Request(session: session, task: dataTask) + delegate[request.delegate.task] = request.delegate + + if startRequestsImmediately { + request.resume() + } + + return request + } + + // MARK: - SessionDelegate + + /** + Responsible for handling all delegate callbacks for the underlying session. + */ + public final class SessionDelegate: NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate { + private var subdelegates: [Int: Request.TaskDelegate] = [:] + private let subdelegateQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_CONCURRENT) + + subscript(task: NSURLSessionTask) -> Request.TaskDelegate? { + get { + var subdelegate: Request.TaskDelegate? + dispatch_sync(subdelegateQueue) { subdelegate = self.subdelegates[task.taskIdentifier] } + + return subdelegate + } + + set { + dispatch_barrier_async(subdelegateQueue) { self.subdelegates[task.taskIdentifier] = newValue } + } + } + + /** + Initializes the `SessionDelegate` instance. + + - returns: The new `SessionDelegate` instance. + */ + public override init() { + super.init() + } + + // MARK: - NSURLSessionDelegate + + // MARK: Override Closures + + /// Overrides default behavior for NSURLSessionDelegate method `URLSession:didBecomeInvalidWithError:`. + public var sessionDidBecomeInvalidWithError: ((NSURLSession, NSError?) -> Void)? + + /// Overrides default behavior for NSURLSessionDelegate method `URLSession:didReceiveChallenge:completionHandler:`. + public var sessionDidReceiveChallenge: ((NSURLSession, NSURLAuthenticationChallenge) -> (NSURLSessionAuthChallengeDisposition, NSURLCredential?))? + + /// Overrides default behavior for NSURLSessionDelegate method `URLSessionDidFinishEventsForBackgroundURLSession:`. + public var sessionDidFinishEventsForBackgroundURLSession: ((NSURLSession) -> Void)? + + // MARK: Delegate Methods + + /** + Tells the delegate that the session has been invalidated. + + - parameter session: The session object that was invalidated. + - parameter error: The error that caused invalidation, or nil if the invalidation was explicit. + */ + public func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) { + sessionDidBecomeInvalidWithError?(session, error) + } + + /** + Requests credentials from the delegate in response to a session-level authentication request from the remote server. + + - parameter session: The session containing the task that requested authentication. + - parameter challenge: An object that contains the request for authentication. + - parameter completionHandler: A handler that your delegate method must call providing the disposition and credential. + */ + public func URLSession( + session: NSURLSession, + didReceiveChallenge challenge: NSURLAuthenticationChallenge, + completionHandler: ((NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void)) + { + var disposition: NSURLSessionAuthChallengeDisposition = .PerformDefaultHandling + var credential: NSURLCredential? + + if let sessionDidReceiveChallenge = sessionDidReceiveChallenge { + (disposition, credential) = sessionDidReceiveChallenge(session, challenge) + } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { + let host = challenge.protectionSpace.host + + if let + serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicyForHost(host), + serverTrust = challenge.protectionSpace.serverTrust + { + if serverTrustPolicy.evaluateServerTrust(serverTrust, isValidForHost: host) { + disposition = .UseCredential + credential = NSURLCredential(forTrust: serverTrust) + } else { + disposition = .CancelAuthenticationChallenge + } + } + } + + completionHandler(disposition, credential) + } + + /** + Tells the delegate that all messages enqueued for a session have been delivered. + + - parameter session: The session that no longer has any outstanding requests. + */ + public func URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession) { + sessionDidFinishEventsForBackgroundURLSession?(session) + } + + // MARK: - NSURLSessionTaskDelegate + + // MARK: Override Closures + + /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:`. + public var taskWillPerformHTTPRedirection: ((NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest) -> NSURLRequest?)? + + /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didReceiveChallenge:completionHandler:`. + public var taskDidReceiveChallenge: ((NSURLSession, NSURLSessionTask, NSURLAuthenticationChallenge) -> (NSURLSessionAuthChallengeDisposition, NSURLCredential?))? + + /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:session:task:needNewBodyStream:`. + public var taskNeedNewBodyStream: ((NSURLSession, NSURLSessionTask) -> NSInputStream!)? + + /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + public var taskDidSendBodyData: ((NSURLSession, NSURLSessionTask, Int64, Int64, Int64) -> Void)? + + /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didCompleteWithError:`. + public var taskDidComplete: ((NSURLSession, NSURLSessionTask, NSError?) -> Void)? + + // MARK: Delegate Methods + + /** + Tells the delegate that the remote server requested an HTTP redirect. + + - parameter session: The session containing the task whose request resulted in a redirect. + - parameter task: The task whose request resulted in a redirect. + - parameter response: An object containing the server’s response to the original request. + - parameter request: A URL request object filled out with the new location. + - parameter completionHandler: A closure that your handler should call with either the value of the request + parameter, a modified URL request object, or NULL to refuse the redirect and + return the body of the redirect response. + */ + public func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + willPerformHTTPRedirection response: NSHTTPURLResponse, + newRequest request: NSURLRequest, + completionHandler: ((NSURLRequest?) -> Void)) + { + var redirectRequest: NSURLRequest? = request + + if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection { + redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request) + } + + completionHandler(redirectRequest) + } + + /** + Requests credentials from the delegate in response to an authentication request from the remote server. + + - parameter session: The session containing the task whose request requires authentication. + - parameter task: The task whose request requires authentication. + - parameter challenge: An object that contains the request for authentication. + - parameter completionHandler: A handler that your delegate method must call providing the disposition and credential. + */ + public func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + didReceiveChallenge challenge: NSURLAuthenticationChallenge, + completionHandler: ((NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void)) + { + if let taskDidReceiveChallenge = taskDidReceiveChallenge { + completionHandler(taskDidReceiveChallenge(session, task, challenge)) + } else if let delegate = self[task] { + delegate.URLSession( + session, + task: task, + didReceiveChallenge: challenge, + completionHandler: completionHandler + ) + } else { + URLSession(session, didReceiveChallenge: challenge, completionHandler: completionHandler) + } + } + + /** + Tells the delegate when a task requires a new request body stream to send to the remote server. + + - parameter session: The session containing the task that needs a new body stream. + - parameter task: The task that needs a new body stream. + - parameter completionHandler: A completion handler that your delegate method should call with the new body stream. + */ + public func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + needNewBodyStream completionHandler: ((NSInputStream?) -> Void)) + { + if let taskNeedNewBodyStream = taskNeedNewBodyStream { + completionHandler(taskNeedNewBodyStream(session, task)) + } else if let delegate = self[task] { + delegate.URLSession(session, task: task, needNewBodyStream: completionHandler) + } + } + + /** + Periodically informs the delegate of the progress of sending body content to the server. + + - parameter session: The session containing the data task. + - parameter task: The data task. + - parameter bytesSent: The number of bytes sent since the last time this delegate method was called. + - parameter totalBytesSent: The total number of bytes sent so far. + - parameter totalBytesExpectedToSend: The expected length of the body data. + */ + public func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + didSendBodyData bytesSent: Int64, + totalBytesSent: Int64, + totalBytesExpectedToSend: Int64) + { + if let taskDidSendBodyData = taskDidSendBodyData { + taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend) + } else if let delegate = self[task] as? Request.UploadTaskDelegate { + delegate.URLSession( + session, + task: task, + didSendBodyData: bytesSent, + totalBytesSent: totalBytesSent, + totalBytesExpectedToSend: totalBytesExpectedToSend + ) + } + } + + /** + Tells the delegate that the task finished transferring data. + + - parameter session: The session containing the task whose request finished transferring data. + - parameter task: The task whose request finished transferring data. + - parameter error: If an error occurred, an error object indicating how the transfer failed, otherwise nil. + */ + public func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) { + if let taskDidComplete = taskDidComplete { + taskDidComplete(session, task, error) + } else if let delegate = self[task] { + delegate.URLSession(session, task: task, didCompleteWithError: error) + } + + self[task] = nil + } + + // MARK: - NSURLSessionDataDelegate + + // MARK: Override Closures + + /// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + public var dataTaskDidReceiveResponse: ((NSURLSession, NSURLSessionDataTask, NSURLResponse) -> NSURLSessionResponseDisposition)? + + /// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didBecomeDownloadTask:`. + public var dataTaskDidBecomeDownloadTask: ((NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask) -> Void)? + + /// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didReceiveData:`. + public var dataTaskDidReceiveData: ((NSURLSession, NSURLSessionDataTask, NSData) -> Void)? + + /// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:willCacheResponse:completionHandler:`. + public var dataTaskWillCacheResponse: ((NSURLSession, NSURLSessionDataTask, NSCachedURLResponse) -> NSCachedURLResponse!)? + + // MARK: Delegate Methods + + /** + Tells the delegate that the data task received the initial reply (headers) from the server. + + - parameter session: The session containing the data task that received an initial reply. + - parameter dataTask: The data task that received an initial reply. + - parameter response: A URL response object populated with headers. + - parameter completionHandler: A completion handler that your code calls to continue the transfer, passing a + constant to indicate whether the transfer should continue as a data task or + should become a download task. + */ + public func URLSession( + session: NSURLSession, + dataTask: NSURLSessionDataTask, + didReceiveResponse response: NSURLResponse, + completionHandler: ((NSURLSessionResponseDisposition) -> Void)) + { + var disposition: NSURLSessionResponseDisposition = .Allow + + if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse { + disposition = dataTaskDidReceiveResponse(session, dataTask, response) + } + + completionHandler(disposition) + } + + /** + Tells the delegate that the data task was changed to a download task. + + - parameter session: The session containing the task that was replaced by a download task. + - parameter dataTask: The data task that was replaced by a download task. + - parameter downloadTask: The new download task that replaced the data task. + */ + public func URLSession( + session: NSURLSession, + dataTask: NSURLSessionDataTask, + didBecomeDownloadTask downloadTask: NSURLSessionDownloadTask) + { + if let dataTaskDidBecomeDownloadTask = dataTaskDidBecomeDownloadTask { + dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask) + } else { + let downloadDelegate = Request.DownloadTaskDelegate(task: downloadTask) + self[downloadTask] = downloadDelegate + } + } + + /** + Tells the delegate that the data task has received some of the expected data. + + - parameter session: The session containing the data task that provided data. + - parameter dataTask: The data task that provided data. + - parameter data: A data object containing the transferred data. + */ + public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData) { + if let dataTaskDidReceiveData = dataTaskDidReceiveData { + dataTaskDidReceiveData(session, dataTask, data) + } else if let delegate = self[dataTask] as? Request.DataTaskDelegate { + delegate.URLSession(session, dataTask: dataTask, didReceiveData: data) + } + } + + /** + Asks the delegate whether the data (or upload) task should store the response in the cache. + + - parameter session: The session containing the data (or upload) task. + - parameter dataTask: The data (or upload) task. + - parameter proposedResponse: The default caching behavior. This behavior is determined based on the current + caching policy and the values of certain received headers, such as the Pragma + and Cache-Control headers. + - parameter completionHandler: A block that your handler must call, providing either the original proposed + response, a modified version of that response, or NULL to prevent caching the + response. If your delegate implements this method, it must call this completion + handler; otherwise, your app leaks memory. + */ + public func URLSession( + session: NSURLSession, + dataTask: NSURLSessionDataTask, + willCacheResponse proposedResponse: NSCachedURLResponse, + completionHandler: ((NSCachedURLResponse?) -> Void)) + { + if let dataTaskWillCacheResponse = dataTaskWillCacheResponse { + completionHandler(dataTaskWillCacheResponse(session, dataTask, proposedResponse)) + } else if let delegate = self[dataTask] as? Request.DataTaskDelegate { + delegate.URLSession( + session, + dataTask: dataTask, + willCacheResponse: proposedResponse, + completionHandler: completionHandler + ) + } else { + completionHandler(proposedResponse) + } + } + + // MARK: - NSURLSessionDownloadDelegate + + // MARK: Override Closures + + /// Overrides default behavior for NSURLSessionDownloadDelegate method `URLSession:downloadTask:didFinishDownloadingToURL:`. + public var downloadTaskDidFinishDownloadingToURL: ((NSURLSession, NSURLSessionDownloadTask, NSURL) -> Void)? + + /// Overrides default behavior for NSURLSessionDownloadDelegate method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`. + public var downloadTaskDidWriteData: ((NSURLSession, NSURLSessionDownloadTask, Int64, Int64, Int64) -> Void)? + + /// Overrides default behavior for NSURLSessionDownloadDelegate method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + public var downloadTaskDidResumeAtOffset: ((NSURLSession, NSURLSessionDownloadTask, Int64, Int64) -> Void)? + + // MARK: Delegate Methods + + /** + Tells the delegate that a download task has finished downloading. + + - parameter session: The session containing the download task that finished. + - parameter downloadTask: The download task that finished. + - parameter location: A file URL for the temporary file. Because the file is temporary, you must either + open the file for reading or move it to a permanent location in your app’s sandbox + container directory before returning from this delegate method. + */ + public func URLSession( + session: NSURLSession, + downloadTask: NSURLSessionDownloadTask, + didFinishDownloadingToURL location: NSURL) + { + if let downloadTaskDidFinishDownloadingToURL = downloadTaskDidFinishDownloadingToURL { + downloadTaskDidFinishDownloadingToURL(session, downloadTask, location) + } else if let delegate = self[downloadTask] as? Request.DownloadTaskDelegate { + delegate.URLSession(session, downloadTask: downloadTask, didFinishDownloadingToURL: location) + } + } + + /** + Periodically informs the delegate about the download’s progress. + + - parameter session: The session containing the download task. + - parameter downloadTask: The download task. + - parameter bytesWritten: The number of bytes transferred since the last time this delegate + method was called. + - parameter totalBytesWritten: The total number of bytes transferred so far. + - parameter totalBytesExpectedToWrite: The expected length of the file, as provided by the Content-Length + header. If this header was not provided, the value is + `NSURLSessionTransferSizeUnknown`. + */ + public func URLSession( + session: NSURLSession, + downloadTask: NSURLSessionDownloadTask, + didWriteData bytesWritten: Int64, + totalBytesWritten: Int64, + totalBytesExpectedToWrite: Int64) + { + if let downloadTaskDidWriteData = downloadTaskDidWriteData { + downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) + } else if let delegate = self[downloadTask] as? Request.DownloadTaskDelegate { + delegate.URLSession( + session, + downloadTask: downloadTask, + didWriteData: bytesWritten, + totalBytesWritten: totalBytesWritten, + totalBytesExpectedToWrite: totalBytesExpectedToWrite + ) + } + } + + /** + Tells the delegate that the download task has resumed downloading. + + - parameter session: The session containing the download task that finished. + - parameter downloadTask: The download task that resumed. See explanation in the discussion. + - parameter fileOffset: If the file's cache policy or last modified date prevents reuse of the + existing content, then this value is zero. Otherwise, this value is an + integer representing the number of bytes on disk that do not need to be + retrieved again. + - parameter expectedTotalBytes: The expected length of the file, as provided by the Content-Length header. + If this header was not provided, the value is NSURLSessionTransferSizeUnknown. + */ + public func URLSession( + session: NSURLSession, + downloadTask: NSURLSessionDownloadTask, + didResumeAtOffset fileOffset: Int64, + expectedTotalBytes: Int64) + { + if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset { + downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes) + } else if let delegate = self[downloadTask] as? Request.DownloadTaskDelegate { + delegate.URLSession( + session, + downloadTask: downloadTask, + didResumeAtOffset: fileOffset, + expectedTotalBytes: expectedTotalBytes + ) + } + } + + // MARK: - NSURLSessionStreamDelegate + + var _streamTaskReadClosed: Any? + var _streamTaskWriteClosed: Any? + var _streamTaskBetterRouteDiscovered: Any? + var _streamTaskDidBecomeInputStream: Any? + + // MARK: - NSObject + + public override func respondsToSelector(selector: Selector) -> Bool { + switch selector { + case "URLSession:didBecomeInvalidWithError:": + return sessionDidBecomeInvalidWithError != nil + case "URLSession:didReceiveChallenge:completionHandler:": + return sessionDidReceiveChallenge != nil + case "URLSessionDidFinishEventsForBackgroundURLSession:": + return sessionDidFinishEventsForBackgroundURLSession != nil + case "URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:": + return taskWillPerformHTTPRedirection != nil + case "URLSession:dataTask:didReceiveResponse:completionHandler:": + return dataTaskDidReceiveResponse != nil + default: + return self.dynamicType.instancesRespondToSelector(selector) + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/MultipartFormData.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/MultipartFormData.swift new file mode 100644 index 00000000000..9e9b26c8b44 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/MultipartFormData.swift @@ -0,0 +1,669 @@ +// MultipartFormData.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +#if os(iOS) || os(watchOS) || os(tvOS) +import MobileCoreServices +#elseif os(OSX) +import CoreServices +#endif + +/** + Constructs `multipart/form-data` for uploads within an HTTP or HTTPS body. There are currently two ways to encode + multipart form data. The first way is to encode the data directly in memory. This is very efficient, but can lead + to memory issues if the dataset is too large. The second way is designed for larger datasets and will write all the + data to a single file on disk with all the proper boundary segmentation. The second approach MUST be used for + larger datasets such as video content, otherwise your app may run out of memory when trying to encode the dataset. + + For more information on `multipart/form-data` in general, please refer to the RFC-2388 and RFC-2045 specs as well + and the w3 form documentation. + + - https://www.ietf.org/rfc/rfc2388.txt + - https://www.ietf.org/rfc/rfc2045.txt + - https://www.w3.org/TR/html401/interact/forms.html#h-17.13 +*/ +public class MultipartFormData { + + // MARK: - Helper Types + + struct EncodingCharacters { + static let CRLF = "\r\n" + } + + struct BoundaryGenerator { + enum BoundaryType { + case Initial, Encapsulated, Final + } + + static func randomBoundary() -> String { + return String(format: "alamofire.boundary.%08x%08x", arc4random(), arc4random()) + } + + static func boundaryData(boundaryType boundaryType: BoundaryType, boundary: String) -> NSData { + let boundaryText: String + + switch boundaryType { + case .Initial: + boundaryText = "--\(boundary)\(EncodingCharacters.CRLF)" + case .Encapsulated: + boundaryText = "\(EncodingCharacters.CRLF)--\(boundary)\(EncodingCharacters.CRLF)" + case .Final: + boundaryText = "\(EncodingCharacters.CRLF)--\(boundary)--\(EncodingCharacters.CRLF)" + } + + return boundaryText.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! + } + } + + class BodyPart { + let headers: [String: String] + let bodyStream: NSInputStream + let bodyContentLength: UInt64 + var hasInitialBoundary = false + var hasFinalBoundary = false + + init(headers: [String: String], bodyStream: NSInputStream, bodyContentLength: UInt64) { + self.headers = headers + self.bodyStream = bodyStream + self.bodyContentLength = bodyContentLength + } + } + + // MARK: - Properties + + /// The `Content-Type` header value containing the boundary used to generate the `multipart/form-data`. + public var contentType: String { return "multipart/form-data; boundary=\(boundary)" } + + /// The content length of all body parts used to generate the `multipart/form-data` not including the boundaries. + public var contentLength: UInt64 { return bodyParts.reduce(0) { $0 + $1.bodyContentLength } } + + /// The boundary used to separate the body parts in the encoded form data. + public let boundary: String + + private var bodyParts: [BodyPart] + private var bodyPartError: NSError? + private let streamBufferSize: Int + + // MARK: - Lifecycle + + /** + Creates a multipart form data object. + + - returns: The multipart form data object. + */ + public init() { + self.boundary = BoundaryGenerator.randomBoundary() + self.bodyParts = [] + + /** + * The optimal read/write buffer size in bytes for input and output streams is 1024 (1KB). For more + * information, please refer to the following article: + * - https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Streams/Articles/ReadingInputStreams.html + */ + + self.streamBufferSize = 1024 + } + + // MARK: - Body Parts + + /** + Creates a body part from the data and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - `Content-Disposition: form-data; name=#{name}` (HTTP Header) + - Encoded data + - Multipart form boundary + + - parameter data: The data to encode into the multipart form data. + - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. + */ + public func appendBodyPart(data data: NSData, name: String) { + let headers = contentHeaders(name: name) + let stream = NSInputStream(data: data) + let length = UInt64(data.length) + + appendBodyPart(stream: stream, length: length, headers: headers) + } + + /** + Creates a body part from the data and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - `Content-Disposition: form-data; name=#{name}` (HTTP Header) + - `Content-Type: #{generated mimeType}` (HTTP Header) + - Encoded data + - Multipart form boundary + + - parameter data: The data to encode into the multipart form data. + - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. + - parameter mimeType: The MIME type to associate with the data content type in the `Content-Type` HTTP header. + */ + public func appendBodyPart(data data: NSData, name: String, mimeType: String) { + let headers = contentHeaders(name: name, mimeType: mimeType) + let stream = NSInputStream(data: data) + let length = UInt64(data.length) + + appendBodyPart(stream: stream, length: length, headers: headers) + } + + /** + Creates a body part from the data and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - `Content-Disposition: form-data; name=#{name}; filename=#{filename}` (HTTP Header) + - `Content-Type: #{mimeType}` (HTTP Header) + - Encoded file data + - Multipart form boundary + + - parameter data: The data to encode into the multipart form data. + - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header. + - parameter fileName: The filename to associate with the data in the `Content-Disposition` HTTP header. + - parameter mimeType: The MIME type to associate with the data in the `Content-Type` HTTP header. + */ + public func appendBodyPart(data data: NSData, name: String, fileName: String, mimeType: String) { + let headers = contentHeaders(name: name, fileName: fileName, mimeType: mimeType) + let stream = NSInputStream(data: data) + let length = UInt64(data.length) + + appendBodyPart(stream: stream, length: length, headers: headers) + } + + /** + Creates a body part from the file and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - `Content-Disposition: form-data; name=#{name}; filename=#{generated filename}` (HTTP Header) + - `Content-Type: #{generated mimeType}` (HTTP Header) + - Encoded file data + - Multipart form boundary + + The filename in the `Content-Disposition` HTTP header is generated from the last path component of the + `fileURL`. The `Content-Type` HTTP header MIME type is generated by mapping the `fileURL` extension to the + system associated MIME type. + + - parameter fileURL: The URL of the file whose content will be encoded into the multipart form data. + - parameter name: The name to associate with the file content in the `Content-Disposition` HTTP header. + */ + public func appendBodyPart(fileURL fileURL: NSURL, name: String) { + if let + fileName = fileURL.lastPathComponent, + pathExtension = fileURL.pathExtension + { + let mimeType = mimeTypeForPathExtension(pathExtension) + appendBodyPart(fileURL: fileURL, name: name, fileName: fileName, mimeType: mimeType) + } else { + let failureReason = "Failed to extract the fileName of the provided URL: \(fileURL)" + setBodyPartError(Error.errorWithCode(NSURLErrorBadURL, failureReason: failureReason)) + } + } + + /** + Creates a body part from the file and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - Content-Disposition: form-data; name=#{name}; filename=#{filename} (HTTP Header) + - Content-Type: #{mimeType} (HTTP Header) + - Encoded file data + - Multipart form boundary + + - parameter fileURL: The URL of the file whose content will be encoded into the multipart form data. + - parameter name: The name to associate with the file content in the `Content-Disposition` HTTP header. + - parameter fileName: The filename to associate with the file content in the `Content-Disposition` HTTP header. + - parameter mimeType: The MIME type to associate with the file content in the `Content-Type` HTTP header. + */ + public func appendBodyPart(fileURL fileURL: NSURL, name: String, fileName: String, mimeType: String) { + let headers = contentHeaders(name: name, fileName: fileName, mimeType: mimeType) + + //============================================================ + // Check 1 - is file URL? + //============================================================ + + guard fileURL.fileURL else { + let failureReason = "The file URL does not point to a file URL: \(fileURL)" + let error = Error.errorWithCode(NSURLErrorBadURL, failureReason: failureReason) + setBodyPartError(error) + return + } + + //============================================================ + // Check 2 - is file URL reachable? + //============================================================ + + var isReachable = true + + if #available(OSX 10.10, *) { + isReachable = fileURL.checkPromisedItemIsReachableAndReturnError(nil) + } + + guard isReachable else { + let error = Error.errorWithCode(NSURLErrorBadURL, failureReason: "The file URL is not reachable: \(fileURL)") + setBodyPartError(error) + return + } + + //============================================================ + // Check 3 - is file URL a directory? + //============================================================ + + var isDirectory: ObjCBool = false + + guard let + path = fileURL.path + where NSFileManager.defaultManager().fileExistsAtPath(path, isDirectory: &isDirectory) && !isDirectory else + { + let failureReason = "The file URL is a directory, not a file: \(fileURL)" + let error = Error.errorWithCode(NSURLErrorBadURL, failureReason: failureReason) + setBodyPartError(error) + return + } + + //============================================================ + // Check 4 - can the file size be extracted? + //============================================================ + + var bodyContentLength: UInt64? + + do { + if let + path = fileURL.path, + fileSize = try NSFileManager.defaultManager().attributesOfItemAtPath(path)[NSFileSize] as? NSNumber + { + bodyContentLength = fileSize.unsignedLongLongValue + } + } catch { + // No-op + } + + guard let length = bodyContentLength else { + let failureReason = "Could not fetch attributes from the file URL: \(fileURL)" + let error = Error.errorWithCode(NSURLErrorBadURL, failureReason: failureReason) + setBodyPartError(error) + return + } + + //============================================================ + // Check 5 - can a stream be created from file URL? + //============================================================ + + guard let stream = NSInputStream(URL: fileURL) else { + let failureReason = "Failed to create an input stream from the file URL: \(fileURL)" + let error = Error.errorWithCode(NSURLErrorCannotOpenFile, failureReason: failureReason) + setBodyPartError(error) + return + } + + appendBodyPart(stream: stream, length: length, headers: headers) + } + + /** + Creates a body part from the stream and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - `Content-Disposition: form-data; name=#{name}; filename=#{filename}` (HTTP Header) + - `Content-Type: #{mimeType}` (HTTP Header) + - Encoded stream data + - Multipart form boundary + + - parameter stream: The input stream to encode in the multipart form data. + - parameter length: The content length of the stream. + - parameter name: The name to associate with the stream content in the `Content-Disposition` HTTP header. + - parameter fileName: The filename to associate with the stream content in the `Content-Disposition` HTTP header. + - parameter mimeType: The MIME type to associate with the stream content in the `Content-Type` HTTP header. + */ + public func appendBodyPart( + stream stream: NSInputStream, + length: UInt64, + name: String, + fileName: String, + mimeType: String) + { + let headers = contentHeaders(name: name, fileName: fileName, mimeType: mimeType) + appendBodyPart(stream: stream, length: length, headers: headers) + } + + /** + Creates a body part with the headers, stream and length and appends it to the multipart form data object. + + The body part data will be encoded using the following format: + + - HTTP headers + - Encoded stream data + - Multipart form boundary + + - parameter stream: The input stream to encode in the multipart form data. + - parameter length: The content length of the stream. + - parameter headers: The HTTP headers for the body part. + */ + public func appendBodyPart(stream stream: NSInputStream, length: UInt64, headers: [String: String]) { + let bodyPart = BodyPart(headers: headers, bodyStream: stream, bodyContentLength: length) + bodyParts.append(bodyPart) + } + + // MARK: - Data Encoding + + /** + Encodes all the appended body parts into a single `NSData` object. + + It is important to note that this method will load all the appended body parts into memory all at the same + time. This method should only be used when the encoded data will have a small memory footprint. For large data + cases, please use the `writeEncodedDataToDisk(fileURL:completionHandler:)` method. + + - throws: An `NSError` if encoding encounters an error. + + - returns: The encoded `NSData` if encoding is successful. + */ + public func encode() throws -> NSData { + if let bodyPartError = bodyPartError { + throw bodyPartError + } + + let encoded = NSMutableData() + + bodyParts.first?.hasInitialBoundary = true + bodyParts.last?.hasFinalBoundary = true + + for bodyPart in bodyParts { + let encodedData = try encodeBodyPart(bodyPart) + encoded.appendData(encodedData) + } + + return encoded + } + + /** + Writes the appended body parts into the given file URL. + + This process is facilitated by reading and writing with input and output streams, respectively. Thus, + this approach is very memory efficient and should be used for large body part data. + + - parameter fileURL: The file URL to write the multipart form data into. + + - throws: An `NSError` if encoding encounters an error. + */ + public func writeEncodedDataToDisk(fileURL: NSURL) throws { + if let bodyPartError = bodyPartError { + throw bodyPartError + } + + if let path = fileURL.path where NSFileManager.defaultManager().fileExistsAtPath(path) { + let failureReason = "A file already exists at the given file URL: \(fileURL)" + throw Error.errorWithCode(NSURLErrorBadURL, failureReason: failureReason) + } else if !fileURL.fileURL { + let failureReason = "The URL does not point to a valid file: \(fileURL)" + throw Error.errorWithCode(NSURLErrorBadURL, failureReason: failureReason) + } + + let outputStream: NSOutputStream + + if let possibleOutputStream = NSOutputStream(URL: fileURL, append: false) { + outputStream = possibleOutputStream + } else { + let failureReason = "Failed to create an output stream with the given URL: \(fileURL)" + throw Error.errorWithCode(NSURLErrorCannotOpenFile, failureReason: failureReason) + } + + outputStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode) + outputStream.open() + + self.bodyParts.first?.hasInitialBoundary = true + self.bodyParts.last?.hasFinalBoundary = true + + for bodyPart in self.bodyParts { + try writeBodyPart(bodyPart, toOutputStream: outputStream) + } + + outputStream.close() + outputStream.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode) + } + + // MARK: - Private - Body Part Encoding + + private func encodeBodyPart(bodyPart: BodyPart) throws -> NSData { + let encoded = NSMutableData() + + let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData() + encoded.appendData(initialData) + + let headerData = encodeHeaderDataForBodyPart(bodyPart) + encoded.appendData(headerData) + + let bodyStreamData = try encodeBodyStreamDataForBodyPart(bodyPart) + encoded.appendData(bodyStreamData) + + if bodyPart.hasFinalBoundary { + encoded.appendData(finalBoundaryData()) + } + + return encoded + } + + private func encodeHeaderDataForBodyPart(bodyPart: BodyPart) -> NSData { + var headerText = "" + + for (key, value) in bodyPart.headers { + headerText += "\(key): \(value)\(EncodingCharacters.CRLF)" + } + headerText += EncodingCharacters.CRLF + + return headerText.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! + } + + private func encodeBodyStreamDataForBodyPart(bodyPart: BodyPart) throws -> NSData { + let inputStream = bodyPart.bodyStream + inputStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode) + inputStream.open() + + var error: NSError? + let encoded = NSMutableData() + + while inputStream.hasBytesAvailable { + var buffer = [UInt8](count: streamBufferSize, repeatedValue: 0) + let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize) + + if inputStream.streamError != nil { + error = inputStream.streamError + break + } + + if bytesRead > 0 { + encoded.appendBytes(buffer, length: bytesRead) + } else if bytesRead < 0 { + let failureReason = "Failed to read from input stream: \(inputStream)" + error = Error.errorWithCode(.InputStreamReadFailed, failureReason: failureReason) + break + } else { + break + } + } + + inputStream.close() + inputStream.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode) + + if let error = error { + throw error + } + + return encoded + } + + // MARK: - Private - Writing Body Part to Output Stream + + private func writeBodyPart(bodyPart: BodyPart, toOutputStream outputStream: NSOutputStream) throws { + try writeInitialBoundaryDataForBodyPart(bodyPart, toOutputStream: outputStream) + try writeHeaderDataForBodyPart(bodyPart, toOutputStream: outputStream) + try writeBodyStreamForBodyPart(bodyPart, toOutputStream: outputStream) + try writeFinalBoundaryDataForBodyPart(bodyPart, toOutputStream: outputStream) + } + + private func writeInitialBoundaryDataForBodyPart( + bodyPart: BodyPart, + toOutputStream outputStream: NSOutputStream) + throws + { + let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData() + return try writeData(initialData, toOutputStream: outputStream) + } + + private func writeHeaderDataForBodyPart(bodyPart: BodyPart, toOutputStream outputStream: NSOutputStream) throws { + let headerData = encodeHeaderDataForBodyPart(bodyPart) + return try writeData(headerData, toOutputStream: outputStream) + } + + private func writeBodyStreamForBodyPart(bodyPart: BodyPart, toOutputStream outputStream: NSOutputStream) throws { + let inputStream = bodyPart.bodyStream + inputStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode) + inputStream.open() + + while inputStream.hasBytesAvailable { + var buffer = [UInt8](count: streamBufferSize, repeatedValue: 0) + let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize) + + if let streamError = inputStream.streamError { + throw streamError + } + + if bytesRead > 0 { + if buffer.count != bytesRead { + buffer = Array(buffer[0.. 0 { + if outputStream.hasSpaceAvailable { + let bytesWritten = outputStream.write(buffer, maxLength: bytesToWrite) + + if let streamError = outputStream.streamError { + throw streamError + } + + if bytesWritten < 0 { + let failureReason = "Failed to write to output stream: \(outputStream)" + throw Error.errorWithCode(.OutputStreamWriteFailed, failureReason: failureReason) + } + + bytesToWrite -= bytesWritten + + if bytesToWrite > 0 { + buffer = Array(buffer[bytesWritten.. String { + if let + id = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension, nil)?.takeRetainedValue(), + contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?.takeRetainedValue() + { + return contentType as String + } + + return "application/octet-stream" + } + + // MARK: - Private - Content Headers + + private func contentHeaders(name name: String) -> [String: String] { + return ["Content-Disposition": "form-data; name=\"\(name)\""] + } + + private func contentHeaders(name name: String, mimeType: String) -> [String: String] { + return [ + "Content-Disposition": "form-data; name=\"\(name)\"", + "Content-Type": "\(mimeType)" + ] + } + + private func contentHeaders(name name: String, fileName: String, mimeType: String) -> [String: String] { + return [ + "Content-Disposition": "form-data; name=\"\(name)\"; filename=\"\(fileName)\"", + "Content-Type": "\(mimeType)" + ] + } + + // MARK: - Private - Boundary Encoding + + private func initialBoundaryData() -> NSData { + return BoundaryGenerator.boundaryData(boundaryType: .Initial, boundary: boundary) + } + + private func encapsulatedBoundaryData() -> NSData { + return BoundaryGenerator.boundaryData(boundaryType: .Encapsulated, boundary: boundary) + } + + private func finalBoundaryData() -> NSData { + return BoundaryGenerator.boundaryData(boundaryType: .Final, boundary: boundary) + } + + // MARK: - Private - Errors + + private func setBodyPartError(error: NSError) { + if bodyPartError == nil { + bodyPartError = error + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ParameterEncoding.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ParameterEncoding.swift new file mode 100644 index 00000000000..09ea00f812c --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ParameterEncoding.swift @@ -0,0 +1,251 @@ +// ParameterEncoding.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/** + HTTP method definitions. + + See https://tools.ietf.org/html/rfc7231#section-4.3 +*/ +public enum Method: String { + case OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT +} + +// MARK: ParameterEncoding + +/** + Used to specify the way in which a set of parameters are applied to a URL request. + + - `URL`: Creates a query string to be set as or appended to any existing URL query for `GET`, `HEAD`, + and `DELETE` requests, or set as the body for requests with any other HTTP method. The + `Content-Type` HTTP header field of an encoded request with HTTP body is set to + `application/x-www-form-urlencoded; charset=utf-8`. Since there is no published specification + for how to encode collection types, the convention of appending `[]` to the key for array + values (`foo[]=1&foo[]=2`), and appending the key surrounded by square brackets for nested + dictionary values (`foo[bar]=baz`). + + - `URLEncodedInURL`: Creates query string to be set as or appended to any existing URL query. Uses the same + implementation as the `.URL` case, but always applies the encoded result to the URL. + + - `JSON`: Uses `NSJSONSerialization` to create a JSON representation of the parameters object, which is + set as the body of the request. The `Content-Type` HTTP header field of an encoded request is + set to `application/json`. + + - `PropertyList`: Uses `NSPropertyListSerialization` to create a plist representation of the parameters object, + according to the associated format and write options values, which is set as the body of the + request. The `Content-Type` HTTP header field of an encoded request is set to + `application/x-plist`. + + - `Custom`: Uses the associated closure value to construct a new request given an existing request and + parameters. +*/ +public enum ParameterEncoding { + case URL + case URLEncodedInURL + case JSON + case PropertyList(NSPropertyListFormat, NSPropertyListWriteOptions) + case Custom((URLRequestConvertible, [String: AnyObject]?) -> (NSMutableURLRequest, NSError?)) + + /** + 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 + + - returns: A tuple containing the constructed request and the error that occurred during parameter encoding, + if any. + */ + public func encode( + URLRequest: URLRequestConvertible, + parameters: [String: AnyObject]?) + -> (NSMutableURLRequest, NSError?) + { + var mutableURLRequest = URLRequest.URLRequest + + guard let parameters = parameters where !parameters.isEmpty else { + return (mutableURLRequest, nil) + } + + var encodingError: NSError? = nil + + switch self { + case .URL, .URLEncodedInURL: + func query(parameters: [String: AnyObject]) -> String { + var components: [(String, String)] = [] + + for key in parameters.keys.sort(<) { + let value = parameters[key]! + components += queryComponents(key, value) + } + + return (components.map { "\($0)=\($1)" } as [String]).joinWithSeparator("&") + } + + func encodesParametersInURL(method: Method) -> Bool { + switch self { + case .URLEncodedInURL: + return true + default: + break + } + + switch method { + case .GET, .HEAD, .DELETE: + return true + default: + return false + } + } + + if let method = Method(rawValue: mutableURLRequest.HTTPMethod) where encodesParametersInURL(method) { + if let URLComponents = NSURLComponents(URL: mutableURLRequest.URL!, resolvingAgainstBaseURL: false) { + let percentEncodedQuery = (URLComponents.percentEncodedQuery.map { $0 + "&" } ?? "") + query(parameters) + URLComponents.percentEncodedQuery = percentEncodedQuery + mutableURLRequest.URL = URLComponents.URL + } + } else { + if mutableURLRequest.valueForHTTPHeaderField("Content-Type") == nil { + mutableURLRequest.setValue( + "application/x-www-form-urlencoded; charset=utf-8", + forHTTPHeaderField: "Content-Type" + ) + } + + mutableURLRequest.HTTPBody = query(parameters).dataUsingEncoding( + NSUTF8StringEncoding, + allowLossyConversion: false + ) + } + case .JSON: + do { + let options = NSJSONWritingOptions() + let data = try NSJSONSerialization.dataWithJSONObject(parameters, options: options) + + mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + mutableURLRequest.HTTPBody = data + } catch { + encodingError = error as NSError + } + case .PropertyList(let format, let options): + do { + let data = try NSPropertyListSerialization.dataWithPropertyList( + parameters, + format: format, + options: options + ) + mutableURLRequest.setValue("application/x-plist", forHTTPHeaderField: "Content-Type") + mutableURLRequest.HTTPBody = data + } catch { + encodingError = error as NSError + } + case .Custom(let closure): + (mutableURLRequest, encodingError) = closure(mutableURLRequest, parameters) + } + + return (mutableURLRequest, encodingError) + } + + /** + Creates percent-escaped, URL encoded query string components from the given key-value pair using recursion. + + - parameter key: The key of the query component. + - parameter value: The value of the query component. + + - returns: The percent-escaped, URL encoded query string components. + */ + public func queryComponents(key: String, _ value: AnyObject) -> [(String, String)] { + var components: [(String, String)] = [] + + if let dictionary = value as? [String: AnyObject] { + for (nestedKey, value) in dictionary { + components += queryComponents("\(key)[\(nestedKey)]", value) + } + } else if let array = value as? [AnyObject] { + for value in array { + components += queryComponents("\(key)[]", value) + } + } else { + components.append((escape(key), escape("\(value)"))) + } + + return components + } + + /** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + + RFC 3986 states that the following characters are "reserved" characters. + + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + + - parameter string: The string to be percent-escaped. + + - returns: The percent-escaped string. + */ + public func escape(string: String) -> String { + let generalDelimitersToEncode = ":#[]@" // does not include "?" or "/" due to RFC 3986 - Section 3.4 + let subDelimitersToEncode = "!$&'()*+,;=" + + let allowedCharacterSet = NSCharacterSet.URLQueryAllowedCharacterSet().mutableCopy() as! NSMutableCharacterSet + allowedCharacterSet.removeCharactersInString(generalDelimitersToEncode + subDelimitersToEncode) + + var escaped = "" + + //========================================================================================================== + // + // Batching is required for escaping due to an internal bug in iOS 8.1 and 8.2. Encoding more than a few + // hundred Chinense characters causes various malloc error crashes. To avoid this issue until iOS 8 is no + // longer supported, batching MUST be used for encoding. This introduces roughly a 20% overhead. For more + // info, please refer to: + // + // - https://github.com/Alamofire/Alamofire/issues/206 + // + //========================================================================================================== + + if #available(iOS 8.3, OSX 10.10, *) { + escaped = string.stringByAddingPercentEncodingWithAllowedCharacters(allowedCharacterSet) ?? string + } else { + let batchSize = 50 + var index = string.startIndex + + while index != string.endIndex { + let startIndex = index + let endIndex = index.advancedBy(batchSize, limit: string.endIndex) + let range = Range(start: startIndex, end: endIndex) + + let substring = string.substringWithRange(range) + + escaped += substring.stringByAddingPercentEncodingWithAllowedCharacters(allowedCharacterSet) ?? substring + + index = endIndex + } + } + + return escaped + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Request.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Request.swift new file mode 100644 index 00000000000..93a7acb2ab2 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Request.swift @@ -0,0 +1,538 @@ +// Request.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/** + Responsible for sending a request and receiving the response and associated data from the server, as well as + managing its underlying `NSURLSessionTask`. +*/ +public class Request { + + // MARK: - Properties + + /// The delegate for the underlying task. + public let delegate: TaskDelegate + + /// The underlying task. + public var task: NSURLSessionTask { return delegate.task } + + /// The session belonging to the underlying task. + public let session: NSURLSession + + /// The request sent or to be sent to the server. + public var request: NSURLRequest? { return task.originalRequest } + + /// The response received from the server, if any. + public var response: NSHTTPURLResponse? { return task.response as? NSHTTPURLResponse } + + /// The progress of the request lifecycle. + public var progress: NSProgress { return delegate.progress } + + // MARK: - Lifecycle + + init(session: NSURLSession, task: NSURLSessionTask) { + self.session = session + + switch task { + case is NSURLSessionUploadTask: + self.delegate = UploadTaskDelegate(task: task) + case is NSURLSessionDataTask: + self.delegate = DataTaskDelegate(task: task) + case is NSURLSessionDownloadTask: + self.delegate = DownloadTaskDelegate(task: task) + default: + self.delegate = TaskDelegate(task: task) + } + } + + // MARK: - Authentication + + /** + Associates an HTTP Basic credential with the request. + + - parameter user: The user. + - parameter password: The password. + - parameter persistence: The URL credential persistence. `.ForSession` by default. + + - returns: The request. + */ + public func authenticate( + user user: String, + password: String, + persistence: NSURLCredentialPersistence = .ForSession) + -> Self + { + let credential = NSURLCredential(user: user, password: password, persistence: persistence) + + return authenticate(usingCredential: credential) + } + + /** + Associates a specified credential with the request. + + - parameter credential: The credential. + + - returns: The request. + */ + public func authenticate(usingCredential credential: NSURLCredential) -> Self { + delegate.credential = credential + + return self + } + + // MARK: - Progress + + /** + Sets a closure to be called periodically during the lifecycle of the request as data is written to or read + from the server. + + - For uploads, the progress closure returns the bytes written, total bytes written, and total bytes expected + to write. + - For downloads and data tasks, the progress closure returns the bytes read, total bytes read, and total bytes + expected to read. + + - parameter closure: The code to be executed periodically during the lifecycle of the request. + + - returns: The request. + */ + public func progress(closure: ((Int64, Int64, Int64) -> Void)? = nil) -> Self { + if let uploadDelegate = delegate as? UploadTaskDelegate { + uploadDelegate.uploadProgress = closure + } else if let dataDelegate = delegate as? DataTaskDelegate { + dataDelegate.dataProgress = closure + } else if let downloadDelegate = delegate as? DownloadTaskDelegate { + downloadDelegate.downloadProgress = closure + } + + return self + } + + /** + Sets a closure to be called periodically during the lifecycle of the request as data is read from the server. + + This closure returns the bytes most recently received from the server, not including data from previous calls. + If this closure is set, data will only be available within this closure, and will not be saved elsewhere. It is + also important to note that the `response` closure will be called with nil `responseData`. + + - parameter closure: The code to be executed periodically during the lifecycle of the request. + + - returns: The request. + */ + public func stream(closure: (NSData -> Void)? = nil) -> Self { + if let dataDelegate = delegate as? DataTaskDelegate { + dataDelegate.dataStream = closure + } + + return self + } + + // MARK: - State + + /** + Suspends the request. + */ + public func suspend() { + task.suspend() + } + + /** + Resumes the request. + */ + public func resume() { + task.resume() + } + + /** + Cancels the request. + */ + public func cancel() { + if let + downloadDelegate = delegate as? DownloadTaskDelegate, + downloadTask = downloadDelegate.downloadTask + { + downloadTask.cancelByProducingResumeData { data in + downloadDelegate.resumeData = data + } + } else { + task.cancel() + } + } + + // MARK: - TaskDelegate + + /** + The task delegate is responsible for handling all delegate callbacks for the underlying task as well as + executing all operations attached to the serial operation queue upon task completion. + */ + public class TaskDelegate: NSObject { + + /// The serial operation queue used to execute all operations after the task completes. + public let queue: NSOperationQueue + + let task: NSURLSessionTask + let progress: NSProgress + + var data: NSData? { return nil } + var error: NSError? + + var credential: NSURLCredential? + + init(task: NSURLSessionTask) { + self.task = task + self.progress = NSProgress(totalUnitCount: 0) + self.queue = { + let operationQueue = NSOperationQueue() + operationQueue.maxConcurrentOperationCount = 1 + operationQueue.suspended = true + + if #available(OSX 10.10, *) { + operationQueue.qualityOfService = NSQualityOfService.Utility + } + + return operationQueue + }() + } + + deinit { + queue.cancelAllOperations() + queue.suspended = false + } + + // MARK: - NSURLSessionTaskDelegate + + // MARK: Override Closures + + var taskWillPerformHTTPRedirection: ((NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest) -> NSURLRequest?)? + var taskDidReceiveChallenge: ((NSURLSession, NSURLSessionTask, NSURLAuthenticationChallenge) -> (NSURLSessionAuthChallengeDisposition, NSURLCredential?))? + var taskNeedNewBodyStream: ((NSURLSession, NSURLSessionTask) -> NSInputStream?)? + var taskDidCompleteWithError: ((NSURLSession, NSURLSessionTask, NSError?) -> Void)? + + // MARK: Delegate Methods + + func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + willPerformHTTPRedirection response: NSHTTPURLResponse, + newRequest request: NSURLRequest, + completionHandler: ((NSURLRequest?) -> Void)) + { + var redirectRequest: NSURLRequest? = request + + if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection { + redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request) + } + + completionHandler(redirectRequest) + } + + func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + didReceiveChallenge challenge: NSURLAuthenticationChallenge, + completionHandler: ((NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void)) + { + var disposition: NSURLSessionAuthChallengeDisposition = .PerformDefaultHandling + var credential: NSURLCredential? + + if let taskDidReceiveChallenge = taskDidReceiveChallenge { + (disposition, credential) = taskDidReceiveChallenge(session, task, challenge) + } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { + let host = challenge.protectionSpace.host + + if let + serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicyForHost(host), + serverTrust = challenge.protectionSpace.serverTrust + { + if serverTrustPolicy.evaluateServerTrust(serverTrust, isValidForHost: host) { + disposition = .UseCredential + credential = NSURLCredential(forTrust: serverTrust) + } else { + disposition = .CancelAuthenticationChallenge + } + } + } else { + if challenge.previousFailureCount > 0 { + disposition = .CancelAuthenticationChallenge + } else { + credential = self.credential ?? session.configuration.URLCredentialStorage?.defaultCredentialForProtectionSpace(challenge.protectionSpace) + + if credential != nil { + disposition = .UseCredential + } + } + } + + completionHandler(disposition, credential) + } + + func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + needNewBodyStream completionHandler: ((NSInputStream?) -> Void)) + { + var bodyStream: NSInputStream? + + if let taskNeedNewBodyStream = taskNeedNewBodyStream { + bodyStream = taskNeedNewBodyStream(session, task) + } + + completionHandler(bodyStream) + } + + func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) { + if let taskDidCompleteWithError = taskDidCompleteWithError { + taskDidCompleteWithError(session, task, error) + } else { + if let error = error { + self.error = error + + if let + downloadDelegate = self as? DownloadTaskDelegate, + userInfo = error.userInfo as? [String: AnyObject], + resumeData = userInfo[NSURLSessionDownloadTaskResumeData] as? NSData + { + downloadDelegate.resumeData = resumeData + } + } + + queue.suspended = false + } + } + } + + // MARK: - DataTaskDelegate + + class DataTaskDelegate: TaskDelegate, NSURLSessionDataDelegate { + var dataTask: NSURLSessionDataTask? { return task as? NSURLSessionDataTask } + + private var totalBytesReceived: Int64 = 0 + private var mutableData: NSMutableData + override var data: NSData? { + if dataStream != nil { + return nil + } else { + return mutableData + } + } + + private var expectedContentLength: Int64? + private var dataProgress: ((bytesReceived: Int64, totalBytesReceived: Int64, totalBytesExpectedToReceive: Int64) -> Void)? + private var dataStream: ((data: NSData) -> Void)? + + override init(task: NSURLSessionTask) { + mutableData = NSMutableData() + super.init(task: task) + } + + // MARK: - NSURLSessionDataDelegate + + // MARK: Override Closures + + var dataTaskDidReceiveResponse: ((NSURLSession, NSURLSessionDataTask, NSURLResponse) -> NSURLSessionResponseDisposition)? + var dataTaskDidBecomeDownloadTask: ((NSURLSession, NSURLSessionDataTask, NSURLSessionDownloadTask) -> Void)? + var dataTaskDidReceiveData: ((NSURLSession, NSURLSessionDataTask, NSData) -> Void)? + var dataTaskWillCacheResponse: ((NSURLSession, NSURLSessionDataTask, NSCachedURLResponse) -> NSCachedURLResponse?)? + + // MARK: Delegate Methods + + func URLSession( + session: NSURLSession, + dataTask: NSURLSessionDataTask, + didReceiveResponse response: NSURLResponse, + completionHandler: (NSURLSessionResponseDisposition -> Void)) + { + var disposition: NSURLSessionResponseDisposition = .Allow + + expectedContentLength = response.expectedContentLength + + if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse { + disposition = dataTaskDidReceiveResponse(session, dataTask, response) + } + + completionHandler(disposition) + } + + func URLSession( + session: NSURLSession, + dataTask: NSURLSessionDataTask, + didBecomeDownloadTask downloadTask: NSURLSessionDownloadTask) + { + dataTaskDidBecomeDownloadTask?(session, dataTask, downloadTask) + } + + func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData) { + if let dataTaskDidReceiveData = dataTaskDidReceiveData { + dataTaskDidReceiveData(session, dataTask, data) + } else { + if let dataStream = dataStream { + dataStream(data: data) + } else { + mutableData.appendData(data) + } + + totalBytesReceived += data.length + let totalBytesExpected = dataTask.response?.expectedContentLength ?? NSURLSessionTransferSizeUnknown + + progress.totalUnitCount = totalBytesExpected + progress.completedUnitCount = totalBytesReceived + + dataProgress?( + bytesReceived: Int64(data.length), + totalBytesReceived: totalBytesReceived, + totalBytesExpectedToReceive: totalBytesExpected + ) + } + } + + func URLSession( + session: NSURLSession, + dataTask: NSURLSessionDataTask, + willCacheResponse proposedResponse: NSCachedURLResponse, + completionHandler: ((NSCachedURLResponse?) -> Void)) + { + var cachedResponse: NSCachedURLResponse? = proposedResponse + + if let dataTaskWillCacheResponse = dataTaskWillCacheResponse { + cachedResponse = dataTaskWillCacheResponse(session, dataTask, proposedResponse) + } + + completionHandler(cachedResponse) + } + } +} + +// MARK: - CustomStringConvertible + +extension Request: CustomStringConvertible { + + /** + The textual representation used when written to an output stream, which includes the HTTP method and URL, as + well as the response status code if a response has been received. + */ + public var description: String { + var components: [String] = [] + + if let HTTPMethod = request?.HTTPMethod { + components.append(HTTPMethod) + } + + if let URLString = request?.URL?.absoluteString { + components.append(URLString) + } + + if let response = response { + components.append("(\(response.statusCode))") + } + + return components.joinWithSeparator(" ") + } +} + +// MARK: - CustomDebugStringConvertible + +extension Request: CustomDebugStringConvertible { + func cURLRepresentation() -> String { + var components = ["$ curl -i"] + + guard let + request = self.request, + URL = request.URL, + host = URL.host + else { + return "$ curl command could not be created" + } + + if let HTTPMethod = request.HTTPMethod where HTTPMethod != "GET" { + components.append("-X \(HTTPMethod)") + } + + if let credentialStorage = self.session.configuration.URLCredentialStorage { + let protectionSpace = NSURLProtectionSpace( + host: host, + port: URL.port?.integerValue ?? 0, + `protocol`: URL.scheme, + realm: host, + authenticationMethod: NSURLAuthenticationMethodHTTPBasic + ) + + if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values { + for credential in credentials { + components.append("-u \(credential.user!):\(credential.password!)") + } + } else { + if let credential = delegate.credential { + components.append("-u \(credential.user!):\(credential.password!)") + } + } + } + + if session.configuration.HTTPShouldSetCookies { + if let + cookieStorage = session.configuration.HTTPCookieStorage, + cookies = cookieStorage.cookiesForURL(URL) where !cookies.isEmpty + { + let string = cookies.reduce("") { $0 + "\($1.name)=\($1.value ?? String());" } + components.append("-b \"\(string.substringToIndex(string.endIndex.predecessor()))\"") + } + } + + if let headerFields = request.allHTTPHeaderFields { + for (field, value) in headerFields { + switch field { + case "Cookie": + continue + default: + components.append("-H \"\(field): \(value)\"") + } + } + } + + if let additionalHeaders = session.configuration.HTTPAdditionalHeaders { + for (field, value) in additionalHeaders { + switch field { + case "Cookie": + continue + default: + components.append("-H \"\(field): \(value)\"") + } + } + } + + if let + HTTPBodyData = request.HTTPBody, + HTTPBody = String(data: HTTPBodyData, encoding: NSUTF8StringEncoding) + { + let escapedBody = HTTPBody.stringByReplacingOccurrencesOfString("\"", withString: "\\\"") + components.append("-d \"\(escapedBody)\"") + } + + components.append("\"\(URL.absoluteString)\"") + + return components.joinWithSeparator(" \\\n\t") + } + + /// The textual representation used when written to an output stream, in the form of a cURL command. + public var debugDescription: String { + return cURLRepresentation() + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Response.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Response.swift new file mode 100644 index 00000000000..f79f9f302e4 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Response.swift @@ -0,0 +1,83 @@ +// Response.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/// Used to store all response data returned from a completed `Request`. +public struct Response { + /// The URL request sent to the server. + public let request: NSURLRequest? + + /// The server's response to the URL request. + public let response: NSHTTPURLResponse? + + /// The data returned by the server. + public let data: NSData? + + /// The result of response serialization. + public let result: Result + + /** + Initializes the `Response` instance with the specified URL request, URL response, server data and response + serialization result. + + - parameter request: The URL request sent to the server. + - parameter response: The server's response to the URL request. + - parameter data: The data returned by the server. + - parameter result: The result of response serialization. + + - returns: the new `Response` instance. + */ + public init(request: NSURLRequest?, response: NSHTTPURLResponse?, data: NSData?, result: Result) { + self.request = request + self.response = response + self.data = data + self.result = result + } +} + +// MARK: - CustomStringConvertible + +extension Response: CustomStringConvertible { + /// The textual representation used when written to an output stream, which includes whether the result was a + /// success or failure. + public var description: String { + return result.debugDescription + } +} + +// MARK: - CustomDebugStringConvertible + +extension Response: CustomDebugStringConvertible { + /// The debug textual representation used when written to an output stream, which includes the URL request, the URL + /// response, the server data and the response serialization result. + public var debugDescription: String { + var output: [String] = [] + + output.append(request != nil ? "[Request]: \(request!)" : "[Request]: nil") + output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil") + output.append("[Data]: \(data?.length ?? 0) bytes") + output.append("[Result]: \(result.debugDescription)") + + return output.joinWithSeparator("\n") + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ResponseSerialization.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ResponseSerialization.swift new file mode 100644 index 00000000000..0ba6f2b718a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ResponseSerialization.swift @@ -0,0 +1,355 @@ +// ResponseSerialization.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +// MARK: ResponseSerializer + +/** + The type in which all response serializers must conform to in order to serialize a response. +*/ +public protocol ResponseSerializerType { + /// The type of serialized object to be created by this `ResponseSerializerType`. + typealias SerializedObject + + /// The type of error to be created by this `ResponseSerializer` if serialization fails. + typealias ErrorObject: ErrorType + + /** + A closure used by response handlers that takes a request, response, data and error and returns a result. + */ + var serializeResponse: (NSURLRequest?, NSHTTPURLResponse?, NSData?, NSError?) -> Result { get } +} + +// MARK: - + +/** + A generic `ResponseSerializerType` used to serialize a request, response, and data into a serialized object. +*/ +public struct ResponseSerializer: ResponseSerializerType { + /// The type of serialized object to be created by this `ResponseSerializer`. + public typealias SerializedObject = Value + + /// The type of error to be created by this `ResponseSerializer` if serialization fails. + public typealias ErrorObject = Error + + /** + A closure used by response handlers that takes a request, response, data and error and returns a result. + */ + public var serializeResponse: (NSURLRequest?, NSHTTPURLResponse?, NSData?, NSError?) -> Result + + /** + Initializes the `ResponseSerializer` instance with the given serialize response closure. + + - parameter serializeResponse: The closure used to serialize the response. + + - returns: The new generic response serializer instance. + */ + public init(serializeResponse: (NSURLRequest?, NSHTTPURLResponse?, NSData?, NSError?) -> Result) { + self.serializeResponse = serializeResponse + } +} + +// MARK: - Default + +extension Request { + + /** + Adds a handler to be called once the request has finished. + + - parameter queue: The queue on which the completion handler is dispatched. + - parameter completionHandler: The code to be executed once the request has finished. + + - returns: The request. + */ + public func response( + queue queue: dispatch_queue_t? = nil, + completionHandler: (NSURLRequest?, NSHTTPURLResponse?, NSData?, NSError?) -> Void) + -> Self + { + delegate.queue.addOperationWithBlock { + dispatch_async(queue ?? dispatch_get_main_queue()) { + completionHandler(self.request, self.response, self.delegate.data, self.delegate.error) + } + } + + return self + } + + /** + Adds a handler to be called once the request has finished. + + - parameter queue: The queue on which the completion handler is dispatched. + - parameter responseSerializer: The response serializer responsible for serializing the request, response, + and data. + - parameter completionHandler: The code to be executed once the request has finished. + + - returns: The request. + */ + public func response( + queue queue: dispatch_queue_t? = nil, + responseSerializer: T, + completionHandler: Response -> Void) + -> Self + { + delegate.queue.addOperationWithBlock { + let result = responseSerializer.serializeResponse( + self.request, + self.response, + self.delegate.data, + self.delegate.error + ) + + dispatch_async(queue ?? dispatch_get_main_queue()) { + let response = Response( + request: self.request, + response: self.response, + data: self.delegate.data, + result: result + ) + + completionHandler(response) + } + } + + return self + } +} + +// MARK: - Data + +extension Request { + + /** + Creates a response serializer that returns the associated data as-is. + + - returns: A data response serializer. + */ + public static func dataResponseSerializer() -> ResponseSerializer { + return ResponseSerializer { _, response, data, error in + guard error == nil else { return .Failure(error!) } + + if let response = response where response.statusCode == 204 { return .Success(NSData()) } + + guard let validData = data else { + let failureReason = "Data could not be serialized. Input data was nil." + let error = Error.errorWithCode(.DataSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + + return .Success(validData) + } + } + + /** + Adds a handler to be called once the request has finished. + + - parameter completionHandler: The code to be executed once the request has finished. + + - returns: The request. + */ + public func responseData(completionHandler: Response -> Void) -> Self { + return response(responseSerializer: Request.dataResponseSerializer(), completionHandler: completionHandler) + } +} + +// MARK: - String + +extension Request { + + /** + Creates a response serializer that returns a string initialized from the response data with the specified + string encoding. + + - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server + response, falling back to the default HTTP default character set, ISO-8859-1. + + - returns: A string response serializer. + */ + public static func stringResponseSerializer( + var encoding encoding: NSStringEncoding? = nil) + -> ResponseSerializer + { + return ResponseSerializer { _, response, data, error in + guard error == nil else { return .Failure(error!) } + + if let response = response where response.statusCode == 204 { return .Success("") } + + guard let validData = data else { + let failureReason = "String could not be serialized. Input data was nil." + let error = Error.errorWithCode(.StringSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + + if let encodingName = response?.textEncodingName where encoding == nil { + encoding = CFStringConvertEncodingToNSStringEncoding( + CFStringConvertIANACharSetNameToEncoding(encodingName) + ) + } + + let actualEncoding = encoding ?? NSISOLatin1StringEncoding + + if let string = String(data: validData, encoding: actualEncoding) { + return .Success(string) + } else { + let failureReason = "String could not be serialized with encoding: \(actualEncoding)" + let error = Error.errorWithCode(.StringSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + } + } + + /** + Adds a handler to be called once the request has finished. + + - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the + server response, falling back to the default HTTP default character set, + ISO-8859-1. + - parameter completionHandler: A closure to be executed once the request has finished. + + - returns: The request. + */ + public func responseString( + encoding encoding: NSStringEncoding? = nil, + completionHandler: Response -> Void) + -> Self + { + return response( + responseSerializer: Request.stringResponseSerializer(encoding: encoding), + completionHandler: completionHandler + ) + } +} + +// MARK: - JSON + +extension Request { + + /** + Creates a response serializer that returns a JSON object constructed from the response data using + `NSJSONSerialization` with the specified reading options. + + - parameter options: The JSON serialization reading options. `.AllowFragments` by default. + + - returns: A JSON object response serializer. + */ + public static func JSONResponseSerializer( + options options: NSJSONReadingOptions = .AllowFragments) + -> ResponseSerializer + { + return ResponseSerializer { _, response, data, error in + guard error == nil else { return .Failure(error!) } + + if let response = response where response.statusCode == 204 { return .Success(NSNull()) } + + guard let validData = data where validData.length > 0 else { + let failureReason = "JSON could not be serialized. Input data was nil or zero length." + let error = Error.errorWithCode(.JSONSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + + do { + let JSON = try NSJSONSerialization.JSONObjectWithData(validData, options: options) + return .Success(JSON) + } catch { + return .Failure(error as NSError) + } + } + } + + /** + Adds a handler to be called once the request has finished. + + - parameter options: The JSON serialization reading options. `.AllowFragments` by default. + - parameter completionHandler: A closure to be executed once the request has finished. + + - returns: The request. + */ + public func responseJSON( + options options: NSJSONReadingOptions = .AllowFragments, + completionHandler: Response -> Void) + -> Self + { + return response( + responseSerializer: Request.JSONResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} + +// MARK: - Property List + +extension Request { + + /** + Creates a response serializer that returns an object constructed from the response data using + `NSPropertyListSerialization` with the specified reading options. + + - parameter options: The property list reading options. `NSPropertyListReadOptions()` by default. + + - returns: A property list object response serializer. + */ + public static func propertyListResponseSerializer( + options options: NSPropertyListReadOptions = NSPropertyListReadOptions()) + -> ResponseSerializer + { + return ResponseSerializer { _, response, data, error in + guard error == nil else { return .Failure(error!) } + + if let response = response where response.statusCode == 204 { return .Success(NSNull()) } + + guard let validData = data where validData.length > 0 else { + let failureReason = "Property list could not be serialized. Input data was nil or zero length." + let error = Error.errorWithCode(.PropertyListSerializationFailed, failureReason: failureReason) + return .Failure(error) + } + + do { + let plist = try NSPropertyListSerialization.propertyListWithData(validData, options: options, format: nil) + return .Success(plist) + } catch { + return .Failure(error as NSError) + } + } + } + + /** + Adds a handler to be called once the request has finished. + + - parameter options: The property list reading options. `0` by default. + - parameter completionHandler: A closure to be executed once the request has finished. The closure takes 3 + arguments: the URL request, the URL response, the server data and the result + produced while creating the property list. + + - returns: The request. + */ + public func responsePropertyList( + options options: NSPropertyListReadOptions = NSPropertyListReadOptions(), + completionHandler: Response -> Void) + -> Self + { + return response( + responseSerializer: Request.propertyListResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Result.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Result.swift new file mode 100644 index 00000000000..614a3529ac6 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Result.swift @@ -0,0 +1,101 @@ +// Result.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/** + Used to represent whether a request was successful or encountered an error. + + - Success: The request and all post processing operations were successful resulting in the serialization of the + provided associated value. + - Failure: The request encountered an error resulting in a failure. The associated values are the original data + provided by the server as well as the error that caused the failure. +*/ +public enum Result { + case Success(Value) + case Failure(Error) + + /// Returns `true` if the result is a success, `false` otherwise. + public var isSuccess: Bool { + switch self { + case .Success: + return true + case .Failure: + return false + } + } + + /// Returns `true` if the result is a failure, `false` otherwise. + public var isFailure: Bool { + return !isSuccess + } + + /// Returns the associated value if the result is a success, `nil` otherwise. + public var value: Value? { + switch self { + case .Success(let value): + return value + case .Failure: + return nil + } + } + + /// Returns the associated error value if the result is a failure, `nil` otherwise. + public var error: Error? { + switch self { + case .Success: + return nil + case .Failure(let error): + return error + } + } +} + +// MARK: - CustomStringConvertible + +extension Result: CustomStringConvertible { + /// The textual representation used when written to an output stream, which includes whether the result was a + /// success or failure. + public var description: String { + switch self { + case .Success: + return "SUCCESS" + case .Failure: + return "FAILURE" + } + } +} + +// MARK: - CustomDebugStringConvertible + +extension Result: CustomDebugStringConvertible { + /// The debug textual representation used when written to an output stream, which includes whether the result was a + /// success or failure in addition to the value or error. + public var debugDescription: String { + switch self { + case .Success(let value): + return "SUCCESS: \(value)" + case .Failure(let error): + return "FAILURE: \(error)" + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ServerTrustPolicy.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ServerTrustPolicy.swift new file mode 100644 index 00000000000..6887d778d23 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/ServerTrustPolicy.swift @@ -0,0 +1,302 @@ +// ServerTrustPolicy.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +/// Responsible for managing the mapping of `ServerTrustPolicy` objects to a given host. +public class ServerTrustPolicyManager { + /// The dictionary of policies mapped to a particular host. + public let policies: [String: ServerTrustPolicy] + + /** + Initializes the `ServerTrustPolicyManager` instance with the given policies. + + Since different servers and web services can have different leaf certificates, intermediate and even root + certficates, it is important to have the flexibility to specify evaluation policies on a per host basis. This + allows for scenarios such as using default evaluation for host1, certificate pinning for host2, public key + pinning for host3 and disabling evaluation for host4. + + - parameter policies: A dictionary of all policies mapped to a particular host. + + - returns: The new `ServerTrustPolicyManager` instance. + */ + public init(policies: [String: ServerTrustPolicy]) { + self.policies = policies + } + + /** + Returns the `ServerTrustPolicy` for the given host if applicable. + + By default, this method will return the policy that perfectly matches the given host. Subclasses could override + this method and implement more complex mapping implementations such as wildcards. + + - parameter host: The host to use when searching for a matching policy. + + - returns: The server trust policy for the given host if found. + */ + public func serverTrustPolicyForHost(host: String) -> ServerTrustPolicy? { + return policies[host] + } +} + +// MARK: - + +extension NSURLSession { + private struct AssociatedKeys { + static var ManagerKey = "NSURLSession.ServerTrustPolicyManager" + } + + var serverTrustPolicyManager: ServerTrustPolicyManager? { + get { + return objc_getAssociatedObject(self, &AssociatedKeys.ManagerKey) as? ServerTrustPolicyManager + } + set (manager) { + objc_setAssociatedObject(self, &AssociatedKeys.ManagerKey, manager, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } +} + +// MARK: - ServerTrustPolicy + +/** + The `ServerTrustPolicy` evaluates the server trust generally provided by an `NSURLAuthenticationChallenge` when + connecting to a server over a secure HTTPS connection. The policy configuration then evaluates the server trust + with a given set of criteria to determine whether the server trust is valid and the connection should be made. + + Using pinned certificates or public keys for evaluation helps prevent man-in-the-middle (MITM) attacks and other + vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged + to route all communication over an HTTPS connection with pinning enabled. + + - PerformDefaultEvaluation: Uses the default server trust evaluation while allowing you to control whether to + validate the host provided by the challenge. Applications are encouraged to always + validate the host in production environments to guarantee the validity of the server's + certificate chain. + + - PinCertificates: Uses the pinned certificates to validate the server trust. The server trust is + considered valid if one of the pinned certificates match one of the server certificates. + By validating both the certificate chain and host, certificate pinning provides a very + secure form of server trust validation mitigating most, if not all, MITM attacks. + Applications are encouraged to always validate the host and require a valid certificate + chain in production environments. + + - PinPublicKeys: Uses the pinned public keys to validate the server trust. The server trust is considered + valid if one of the pinned public keys match one of the server certificate public keys. + By validating both the certificate chain and host, public key pinning provides a very + secure form of server trust validation mitigating most, if not all, MITM attacks. + Applications are encouraged to always validate the host and require a valid certificate + chain in production environments. + + - DisableEvaluation: Disables all evaluation which in turn will always consider any server trust as valid. + + - CustomEvaluation: Uses the associated closure to evaluate the validity of the server trust. +*/ +public enum ServerTrustPolicy { + case PerformDefaultEvaluation(validateHost: Bool) + case PinCertificates(certificates: [SecCertificate], validateCertificateChain: Bool, validateHost: Bool) + case PinPublicKeys(publicKeys: [SecKey], validateCertificateChain: Bool, validateHost: Bool) + case DisableEvaluation + case CustomEvaluation((serverTrust: SecTrust, host: String) -> Bool) + + // MARK: - Bundle Location + + /** + Returns all certificates within the given bundle with a `.cer` file extension. + + - parameter bundle: The bundle to search for all `.cer` files. + + - returns: All certificates within the given bundle. + */ + public static func certificatesInBundle(bundle: NSBundle = NSBundle.mainBundle()) -> [SecCertificate] { + var certificates: [SecCertificate] = [] + + let paths = Set([".cer", ".CER", ".crt", ".CRT", ".der", ".DER"].map { fileExtension in + bundle.pathsForResourcesOfType(fileExtension, inDirectory: nil) + }.flatten()) + + for path in paths { + if let + certificateData = NSData(contentsOfFile: path), + certificate = SecCertificateCreateWithData(nil, certificateData) + { + certificates.append(certificate) + } + } + + return certificates + } + + /** + Returns all public keys within the given bundle with a `.cer` file extension. + + - parameter bundle: The bundle to search for all `*.cer` files. + + - returns: All public keys within the given bundle. + */ + public static func publicKeysInBundle(bundle: NSBundle = NSBundle.mainBundle()) -> [SecKey] { + var publicKeys: [SecKey] = [] + + for certificate in certificatesInBundle(bundle) { + if let publicKey = publicKeyForCertificate(certificate) { + publicKeys.append(publicKey) + } + } + + return publicKeys + } + + // MARK: - Evaluation + + /** + Evaluates whether the server trust is valid for the given host. + + - parameter serverTrust: The server trust to evaluate. + - parameter host: The host of the challenge protection space. + + - returns: Whether the server trust is valid. + */ + public func evaluateServerTrust(serverTrust: SecTrust, isValidForHost host: String) -> Bool { + var serverTrustIsValid = false + + switch self { + case let .PerformDefaultEvaluation(validateHost): + let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + SecTrustSetPolicies(serverTrust, [policy]) + + serverTrustIsValid = trustIsValid(serverTrust) + case let .PinCertificates(pinnedCertificates, validateCertificateChain, validateHost): + if validateCertificateChain { + let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + SecTrustSetPolicies(serverTrust, [policy]) + + SecTrustSetAnchorCertificates(serverTrust, pinnedCertificates) + SecTrustSetAnchorCertificatesOnly(serverTrust, true) + + serverTrustIsValid = trustIsValid(serverTrust) + } else { + let serverCertificatesDataArray = certificateDataForTrust(serverTrust) + let pinnedCertificatesDataArray = certificateDataForCertificates(pinnedCertificates) + + outerLoop: for serverCertificateData in serverCertificatesDataArray { + for pinnedCertificateData in pinnedCertificatesDataArray { + if serverCertificateData.isEqualToData(pinnedCertificateData) { + serverTrustIsValid = true + break outerLoop + } + } + } + } + case let .PinPublicKeys(pinnedPublicKeys, validateCertificateChain, validateHost): + var certificateChainEvaluationPassed = true + + if validateCertificateChain { + let policy = SecPolicyCreateSSL(true, validateHost ? host as CFString : nil) + SecTrustSetPolicies(serverTrust, [policy]) + + certificateChainEvaluationPassed = trustIsValid(serverTrust) + } + + if certificateChainEvaluationPassed { + outerLoop: for serverPublicKey in ServerTrustPolicy.publicKeysForTrust(serverTrust) as [AnyObject] { + for pinnedPublicKey in pinnedPublicKeys as [AnyObject] { + if serverPublicKey.isEqual(pinnedPublicKey) { + serverTrustIsValid = true + break outerLoop + } + } + } + } + case .DisableEvaluation: + serverTrustIsValid = true + case let .CustomEvaluation(closure): + serverTrustIsValid = closure(serverTrust: serverTrust, host: host) + } + + return serverTrustIsValid + } + + // MARK: - Private - Trust Validation + + private func trustIsValid(trust: SecTrust) -> Bool { + var isValid = false + + var result = SecTrustResultType(kSecTrustResultInvalid) + let status = SecTrustEvaluate(trust, &result) + + if status == errSecSuccess { + let unspecified = SecTrustResultType(kSecTrustResultUnspecified) + let proceed = SecTrustResultType(kSecTrustResultProceed) + + isValid = result == unspecified || result == proceed + } + + return isValid + } + + // MARK: - Private - Certificate Data + + private func certificateDataForTrust(trust: SecTrust) -> [NSData] { + var certificates: [SecCertificate] = [] + + for index in 0.. [NSData] { + return certificates.map { SecCertificateCopyData($0) as NSData } + } + + // MARK: - Private - Public Key Extraction + + private static func publicKeysForTrust(trust: SecTrust) -> [SecKey] { + var publicKeys: [SecKey] = [] + + for index in 0.. SecKey? { + var publicKey: SecKey? + + let policy = SecPolicyCreateBasicX509() + var trust: SecTrust? + let trustCreationStatus = SecTrustCreateWithCertificates(certificate, policy, &trust) + + if let trust = trust where trustCreationStatus == errSecSuccess { + publicKey = SecTrustCopyPublicKey(trust) + } + + return publicKey + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Stream.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Stream.swift new file mode 100644 index 00000000000..bc9ee450c5a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Stream.swift @@ -0,0 +1,180 @@ +// Stream.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +#if !os(watchOS) + +@available(iOS 9.0, OSX 10.11, *) +extension Manager { + private enum Streamable { + case Stream(String, Int) + case NetService(NSNetService) + } + + private func stream(streamable: Streamable) -> Request { + var streamTask: NSURLSessionStreamTask! + + switch streamable { + case .Stream(let hostName, let port): + dispatch_sync(queue) { + streamTask = self.session.streamTaskWithHostName(hostName, port: port) + } + case .NetService(let netService): + dispatch_sync(queue) { + streamTask = self.session.streamTaskWithNetService(netService) + } + } + + let request = Request(session: session, task: streamTask) + + delegate[request.delegate.task] = request.delegate + + if startRequestsImmediately { + request.resume() + } + + return request + } + + /** + Creates a request for bidirectional streaming with the given hostname and port. + + - parameter hostName: The hostname of the server to connect to. + - parameter port: The port of the server to connect to. + + :returns: The created stream request. + */ + public func stream(hostName hostName: String, port: Int) -> Request { + return stream(.Stream(hostName, port)) + } + + /** + Creates a request for bidirectional streaming with the given `NSNetService`. + + - parameter netService: The net service used to identify the endpoint. + + - returns: The created stream request. + */ + public func stream(netService netService: NSNetService) -> Request { + return stream(.NetService(netService)) + } +} + +// MARK: - + +@available(iOS 9.0, OSX 10.11, *) +extension Manager.SessionDelegate: NSURLSessionStreamDelegate { + + // MARK: Override Closures + + /// Overrides default behavior for NSURLSessionStreamDelegate method `URLSession:readClosedForStreamTask:`. + public var streamTaskReadClosed: ((NSURLSession, NSURLSessionStreamTask) -> Void)? { + get { + return _streamTaskReadClosed as? (NSURLSession, NSURLSessionStreamTask) -> Void + } + set { + _streamTaskReadClosed = newValue + } + } + + /// Overrides default behavior for NSURLSessionStreamDelegate method `URLSession:writeClosedForStreamTask:`. + public var streamTaskWriteClosed: ((NSURLSession, NSURLSessionStreamTask) -> Void)? { + get { + return _streamTaskWriteClosed as? (NSURLSession, NSURLSessionStreamTask) -> Void + } + set { + _streamTaskWriteClosed = newValue + } + } + + /// Overrides default behavior for NSURLSessionStreamDelegate method `URLSession:betterRouteDiscoveredForStreamTask:`. + public var streamTaskBetterRouteDiscovered: ((NSURLSession, NSURLSessionStreamTask) -> Void)? { + get { + return _streamTaskBetterRouteDiscovered as? (NSURLSession, NSURLSessionStreamTask) -> Void + } + set { + _streamTaskBetterRouteDiscovered = newValue + } + } + + /// Overrides default behavior for NSURLSessionStreamDelegate method `URLSession:streamTask:didBecomeInputStream:outputStream:`. + public var streamTaskDidBecomeInputStream: ((NSURLSession, NSURLSessionStreamTask, NSInputStream, NSOutputStream) -> Void)? { + get { + return _streamTaskDidBecomeInputStream as? (NSURLSession, NSURLSessionStreamTask, NSInputStream, NSOutputStream) -> Void + } + set { + _streamTaskDidBecomeInputStream = newValue + } + } + + // MARK: Delegate Methods + + /** + Tells the delegate that the read side of the connection has been closed. + + - parameter session: The session. + - parameter streamTask: The stream task. + */ + public func URLSession(session: NSURLSession, readClosedForStreamTask streamTask: NSURLSessionStreamTask) { + streamTaskReadClosed?(session, streamTask) + } + + /** + Tells the delegate that the write side of the connection has been closed. + + - parameter session: The session. + - parameter streamTask: The stream task. + */ + public func URLSession(session: NSURLSession, writeClosedForStreamTask streamTask: NSURLSessionStreamTask) { + streamTaskWriteClosed?(session, streamTask) + } + + /** + Tells the delegate that the system has determined that a better route to the host is available. + + - parameter session: The session. + - parameter streamTask: The stream task. + */ + public func URLSession(session: NSURLSession, betterRouteDiscoveredForStreamTask streamTask: NSURLSessionStreamTask) { + streamTaskBetterRouteDiscovered?(session, streamTask) + } + + /** + Tells the delegate that the stream task has been completed and provides the unopened stream objects. + + - parameter session: The session. + - parameter streamTask: The stream task. + - parameter inputStream: The new input stream. + - parameter outputStream: The new output stream. + */ + public func URLSession( + session: NSURLSession, + streamTask: NSURLSessionStreamTask, + didBecomeInputStream inputStream: NSInputStream, + outputStream: NSOutputStream) + { + streamTaskDidBecomeInputStream?(session, streamTask, inputStream, outputStream) + } +} + +#endif diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Upload.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Upload.swift new file mode 100644 index 00000000000..640b05c8775 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Upload.swift @@ -0,0 +1,372 @@ +// Upload.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +extension Manager { + private enum Uploadable { + case Data(NSURLRequest, NSData) + case File(NSURLRequest, NSURL) + case Stream(NSURLRequest, NSInputStream) + } + + private func upload(uploadable: Uploadable) -> Request { + var uploadTask: NSURLSessionUploadTask! + var HTTPBodyStream: NSInputStream? + + switch uploadable { + case .Data(let request, let data): + dispatch_sync(queue) { + uploadTask = self.session.uploadTaskWithRequest(request, fromData: data) + } + case .File(let request, let fileURL): + dispatch_sync(queue) { + uploadTask = self.session.uploadTaskWithRequest(request, fromFile: fileURL) + } + case .Stream(let request, let stream): + dispatch_sync(queue) { + uploadTask = self.session.uploadTaskWithStreamedRequest(request) + } + + HTTPBodyStream = stream + } + + let request = Request(session: session, task: uploadTask) + + if HTTPBodyStream != nil { + request.delegate.taskNeedNewBodyStream = { _, _ in + return HTTPBodyStream + } + } + + delegate[request.delegate.task] = request.delegate + + if startRequestsImmediately { + request.resume() + } + + return request + } + + // MARK: File + + /** + Creates a request for uploading a file to the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request + - parameter file: The file to upload + + - returns: The created upload request. + */ + public func upload(URLRequest: URLRequestConvertible, file: NSURL) -> Request { + return upload(.File(URLRequest.URLRequest, file)) + } + + /** + Creates a request for uploading a file to the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter file: The file to upload + + - returns: The created upload request. + */ + public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + file: NSURL) + -> Request + { + let mutableURLRequest = URLRequest(method, URLString, headers: headers) + return upload(mutableURLRequest, file: file) + } + + // MARK: Data + + /** + Creates a request for uploading data to the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request. + - parameter data: The data to upload. + + - returns: The created upload request. + */ + public func upload(URLRequest: URLRequestConvertible, data: NSData) -> Request { + return upload(.Data(URLRequest.URLRequest, data)) + } + + /** + Creates a request for uploading data to the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter data: The data to upload + + - returns: The created upload request. + */ + public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + data: NSData) + -> Request + { + let mutableURLRequest = URLRequest(method, URLString, headers: headers) + + return upload(mutableURLRequest, data: data) + } + + // MARK: Stream + + /** + Creates a request for uploading a stream to the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request. + - parameter stream: The stream to upload. + + - returns: The created upload request. + */ + public func upload(URLRequest: URLRequestConvertible, stream: NSInputStream) -> Request { + return upload(.Stream(URLRequest.URLRequest, stream)) + } + + /** + Creates a request for uploading a stream to the specified URL request. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter stream: The stream to upload. + + - returns: The created upload request. + */ + public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + stream: NSInputStream) + -> Request + { + let mutableURLRequest = URLRequest(method, URLString, headers: headers) + + return upload(mutableURLRequest, stream: stream) + } + + // MARK: MultipartFormData + + /// Default memory threshold used when encoding `MultipartFormData`. + public static let MultipartFormDataEncodingMemoryThreshold: UInt64 = 10 * 1024 * 1024 + + /** + Defines whether the `MultipartFormData` encoding was successful and contains result of the encoding as + associated values. + + - Success: Represents a successful `MultipartFormData` encoding and contains the new `Request` along with + streaming information. + - Failure: Used to represent a failure in the `MultipartFormData` encoding and also contains the encoding + error. + */ + public enum MultipartFormDataEncodingResult { + case Success(request: Request, streamingFromDisk: Bool, streamFileURL: NSURL?) + case Failure(ErrorType) + } + + /** + Encodes the `MultipartFormData` and creates a request to upload the result to the specified URL request. + + It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative + payload is small, encoding the data in-memory and directly uploading to a server is the by far the most + efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to + be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory + footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be + used for larger payloads such as video content. + + The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory + or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, + encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk + during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding + technique was used. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter method: The HTTP method. + - parameter URLString: The URL string. + - parameter headers: The HTTP headers. `nil` by default. + - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. + - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. + `MultipartFormDataEncodingMemoryThreshold` by default. + - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. + */ + public func upload( + method: Method, + _ URLString: URLStringConvertible, + headers: [String: String]? = nil, + multipartFormData: MultipartFormData -> Void, + encodingMemoryThreshold: UInt64 = Manager.MultipartFormDataEncodingMemoryThreshold, + encodingCompletion: (MultipartFormDataEncodingResult -> Void)?) + { + let mutableURLRequest = URLRequest(method, URLString, headers: headers) + + return upload( + mutableURLRequest, + multipartFormData: multipartFormData, + encodingMemoryThreshold: encodingMemoryThreshold, + encodingCompletion: encodingCompletion + ) + } + + /** + Encodes the `MultipartFormData` and creates a request to upload the result to the specified URL request. + + It is important to understand the memory implications of uploading `MultipartFormData`. If the cummulative + payload is small, encoding the data in-memory and directly uploading to a server is the by far the most + efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to + be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory + footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be + used for larger payloads such as video content. + + The `encodingMemoryThreshold` parameter allows Alamofire to automatically determine whether to encode in-memory + or stream from disk. If the content length of the `MultipartFormData` is below the `encodingMemoryThreshold`, + encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk + during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding + technique was used. + + If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned. + + - parameter URLRequest: The URL request. + - parameter multipartFormData: The closure used to append body parts to the `MultipartFormData`. + - parameter encodingMemoryThreshold: The encoding memory threshold in bytes. + `MultipartFormDataEncodingMemoryThreshold` by default. + - parameter encodingCompletion: The closure called when the `MultipartFormData` encoding is complete. + */ + public func upload( + URLRequest: URLRequestConvertible, + multipartFormData: MultipartFormData -> Void, + encodingMemoryThreshold: UInt64 = Manager.MultipartFormDataEncodingMemoryThreshold, + encodingCompletion: (MultipartFormDataEncodingResult -> Void)?) + { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { + let formData = MultipartFormData() + multipartFormData(formData) + + let URLRequestWithContentType = URLRequest.URLRequest + URLRequestWithContentType.setValue(formData.contentType, forHTTPHeaderField: "Content-Type") + + let isBackgroundSession = self.session.configuration.identifier != nil + + if formData.contentLength < encodingMemoryThreshold && !isBackgroundSession { + do { + let data = try formData.encode() + let encodingResult = MultipartFormDataEncodingResult.Success( + request: self.upload(URLRequestWithContentType, data: data), + streamingFromDisk: false, + streamFileURL: nil + ) + + dispatch_async(dispatch_get_main_queue()) { + encodingCompletion?(encodingResult) + } + } catch { + dispatch_async(dispatch_get_main_queue()) { + encodingCompletion?(.Failure(error as NSError)) + } + } + } else { + let fileManager = NSFileManager.defaultManager() + let tempDirectoryURL = NSURL(fileURLWithPath: NSTemporaryDirectory()) + let directoryURL = tempDirectoryURL.URLByAppendingPathComponent("com.alamofire.manager/multipart.form.data") + let fileName = NSUUID().UUIDString + let fileURL = directoryURL.URLByAppendingPathComponent(fileName) + + do { + try fileManager.createDirectoryAtURL(directoryURL, withIntermediateDirectories: true, attributes: nil) + try formData.writeEncodedDataToDisk(fileURL) + + dispatch_async(dispatch_get_main_queue()) { + let encodingResult = MultipartFormDataEncodingResult.Success( + request: self.upload(URLRequestWithContentType, file: fileURL), + streamingFromDisk: true, + streamFileURL: fileURL + ) + encodingCompletion?(encodingResult) + } + } catch { + dispatch_async(dispatch_get_main_queue()) { + encodingCompletion?(.Failure(error as NSError)) + } + } + } + } + } +} + +// MARK: - + +extension Request { + + // MARK: - UploadTaskDelegate + + class UploadTaskDelegate: DataTaskDelegate { + var uploadTask: NSURLSessionUploadTask? { return task as? NSURLSessionUploadTask } + var uploadProgress: ((Int64, Int64, Int64) -> Void)! + + // MARK: - NSURLSessionTaskDelegate + + // MARK: Override Closures + + var taskDidSendBodyData: ((NSURLSession, NSURLSessionTask, Int64, Int64, Int64) -> Void)? + + // MARK: Delegate Methods + + func URLSession( + session: NSURLSession, + task: NSURLSessionTask, + didSendBodyData bytesSent: Int64, + totalBytesSent: Int64, + totalBytesExpectedToSend: Int64) + { + if let taskDidSendBodyData = taskDidSendBodyData { + taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend) + } else { + progress.totalUnitCount = totalBytesExpectedToSend + progress.completedUnitCount = totalBytesSent + + uploadProgress?(bytesSent, totalBytesSent, totalBytesExpectedToSend) + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Validation.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Validation.swift new file mode 100644 index 00000000000..88234551965 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Alamofire/Source/Validation.swift @@ -0,0 +1,189 @@ +// Validation.swift +// +// Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +extension Request { + + /** + Used to represent whether validation was successful or encountered an error resulting in a failure. + + - Success: The validation was successful. + - Failure: The validation failed encountering the provided error. + */ + public enum ValidationResult { + case Success + case Failure(NSError) + } + + /** + A closure used to validate a request that takes a URL request and URL response, and returns whether the + request was valid. + */ + public typealias Validation = (NSURLRequest?, NSHTTPURLResponse) -> ValidationResult + + /** + Validates the request, using the specified closure. + + If validation fails, subsequent calls to response handlers will have an associated error. + + - parameter validation: A closure to validate the request. + + - returns: The request. + */ + public func validate(validation: Validation) -> Self { + delegate.queue.addOperationWithBlock { + if let + response = self.response where self.delegate.error == nil, + case let .Failure(error) = validation(self.request, response) + { + self.delegate.error = error + } + } + + return self + } + + // MARK: - Status Code + + /** + Validates that the response has a status code in the specified range. + + If validation fails, subsequent calls to response handlers will have an associated error. + + - parameter range: The range of acceptable status codes. + + - returns: The request. + */ + public func validate(statusCode acceptableStatusCode: S) -> Self { + return validate { _, response in + if acceptableStatusCode.contains(response.statusCode) { + return .Success + } else { + let failureReason = "Response status code was unacceptable: \(response.statusCode)" + return .Failure(Error.errorWithCode(.StatusCodeValidationFailed, failureReason: failureReason)) + } + } + } + + // MARK: - Content-Type + + private struct MIMEType { + let type: String + let subtype: String + + init?(_ string: String) { + let components: [String] = { + let stripped = string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) + let split = stripped.substringToIndex(stripped.rangeOfString(";")?.startIndex ?? stripped.endIndex) + return split.componentsSeparatedByString("/") + }() + + if let + type = components.first, + subtype = components.last + { + self.type = type + self.subtype = subtype + } else { + return nil + } + } + + func matches(MIME: MIMEType) -> Bool { + switch (type, subtype) { + case (MIME.type, MIME.subtype), (MIME.type, "*"), ("*", MIME.subtype), ("*", "*"): + return true + default: + return false + } + } + } + + /** + Validates that the response has a content type in the specified array. + + If validation fails, subsequent calls to response handlers will have an associated error. + + - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes. + + - returns: The request. + */ + public func validate(contentType acceptableContentTypes: S) -> Self { + return validate { _, response in + guard let validData = self.delegate.data where validData.length > 0 else { return .Success } + + if let + responseContentType = response.MIMEType, + responseMIMEType = MIMEType(responseContentType) + { + for contentType in acceptableContentTypes { + if let acceptableMIMEType = MIMEType(contentType) where acceptableMIMEType.matches(responseMIMEType) { + return .Success + } + } + } else { + for contentType in acceptableContentTypes { + if let MIMEType = MIMEType(contentType) where MIMEType.type == "*" && MIMEType.subtype == "*" { + return .Success + } + } + } + + let failureReason: String + + if let responseContentType = response.MIMEType { + failureReason = ( + "Response content type \"\(responseContentType)\" does not match any acceptable " + + "content types: \(acceptableContentTypes)" + ) + } else { + failureReason = "Response content type was missing and acceptable content type does not match \"*/*\"" + } + + return .Failure(Error.errorWithCode(.ContentTypeValidationFailed, failureReason: failureReason)) + } + } + + // MARK: - Automatic + + /** + Validates that the response has a status code in the default acceptable range of 200...299, and that the content + type matches any specified in the Accept HTTP header field. + + If validation fails, subsequent calls to response handlers will have an associated error. + + - returns: The request. + */ + public func validate() -> Self { + let acceptableStatusCodes: Range = 200..<300 + let acceptableContentTypes: [String] = { + if let accept = request?.valueForHTTPHeaderField("Accept") { + return accept.componentsSeparatedByString(",") + } + + return ["*/*"] + }() + + return validate(statusCode: acceptableStatusCodes).validate(contentType: acceptableContentTypes) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json new file mode 100644 index 00000000000..ca12bdffe3b --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json @@ -0,0 +1,25 @@ +{ + "name": "PetstoreClient", + "platforms": { + "ios": "8.0", + "osx": "10.9" + }, + "version": "0.0.1", + "source": { + "git": "git@github.com:swagger-api/swagger-mustache.git", + "tag": "v1.0.0" + }, + "authors": "", + "license": "Apache License, Version 2.0", + "homepage": "https://github.com/swagger-api/swagger-codegen", + "summary": "PetstoreClient", + "source_files": "PetstoreClient/Classes/Swaggers/**/*.swift", + "dependencies": { + "RxSwift": [ + "~> 2.0" + ], + "Alamofire": [ + "~> 3.1.5" + ] + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Manifest.lock b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Manifest.lock new file mode 100644 index 00000000000..9ea49e930da --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Manifest.lock @@ -0,0 +1,22 @@ +PODS: + - Alamofire (3.1.5) + - PetstoreClient (0.0.1): + - Alamofire (~> 3.1.5) + - RxSwift (~> 2.0) + - RxSwift (2.6.0) + +DEPENDENCIES: + - PetstoreClient (from `../`) + +EXTERNAL SOURCES: + PetstoreClient: + :path: "../" + +SPEC CHECKSUMS: + Alamofire: 5f730ba29fd113b7ddd71c1e65d0c630acf5d7b0 + PetstoreClient: 0baad893079f270b6bcf2e868ba68d8b9ce36812 + RxSwift: 77f3a0b15324baa7a1c9bfa9f199648a82424e26 + +PODFILE CHECKSUM: cedb3058b02f4776d7c31f6d92ae2f674fdf424d + +COCOAPODS: 1.0.1 diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Pods.xcodeproj/project.pbxproj b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..a56a15dfc60 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1731 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 00A528BBED5B1D5DF26B8ADE64C5B3F2 /* CompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FF9A09AF9E0D7751789D55FDDDCA2 /* CompositeDisposable.swift */; }; + 00D1D0E4C3E6F9EA952C2EDEF2C13DE9 /* NopDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6156CD5049D33CC68DF29760B398B408 /* NopDisposable.swift */; }; + 0268E70939A7BFBC91C0557D16DDD027 /* ScheduledDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17881314399342A30A86EF8655AFD35C /* ScheduledDisposable.swift */; }; + 028C4C90CAA75222DAA6CA7B37F16A84 /* ConcurrentDispatchQueueScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A95956A18890D406F52B50CE636C417 /* ConcurrentDispatchQueueScheduler.swift */; }; + 030667BEF4154402A2317126A893E459 /* ConnectableObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76485D1ACD1F13E0E68638CA3D9E175C /* ConnectableObservable.swift */; }; + 03F494989CC1A8857B68A317D5D6860F /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB61DA897ED3DE273EC2B5824A42DF0 /* Response.swift */; }; + 04509FBE687E186C45C9E2F78E6F6946 /* CombineLatest+CollectionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CF9673331C58F7D9396CDEC9CE940A9 /* CombineLatest+CollectionType.swift */; }; + 0487B12B08D927162A20CB2A56A2D077 /* Just.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72AAAA3FE5DDA94BC0636A15F9F4F7EF /* Just.swift */; }; + 04923B3851BD1F857A9B207EE9EC8CDB /* SubjectType.swift in Sources */ = {isa = PBXBuildFile; fileRef = E64D15D1795EA999578C393A507A882F /* SubjectType.swift */; }; + 0607BCCDD781FF7FFD3629BF4A8BAD23 /* Sample.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC29FB0F89F4B2B863A122A41D07007 /* Sample.swift */; }; + 0681ADC8BAE2C3185F13487BAAB4D9DD /* Upload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E78A6B0E3334E11FE5615FE4CC506E8 /* Upload.swift */; }; + 07E83400AACF1430C5B3DF482167A0F1 /* Reduce.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5438FA602118A769102A572D66E5EDD /* Reduce.swift */; }; + 08D2C4B252A264F837733A22CBFB2481 /* APIs.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8072E1108951F272C003553FC8926C7 /* APIs.swift */; }; + 0A5F6F590DCE147853B2E21487ABA4AA /* RetryWhen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7678CC14BE55592C2250C4C122EADEF3 /* RetryWhen.swift */; }; + 0A9698AC9DD60FC3721809C6AB9BCE81 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B248364ABF60ACD7DB31A17DCFDFD0C /* User.swift */; }; + 0AEB6185484DD9137068A40CE70D4B85 /* SchedulerServices+Emulation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D1C22E4BBFB16E5C966FF77E92F296 /* SchedulerServices+Emulation.swift */; }; + 0BD8B4E55E72312366130E97A1204CD8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9610BA4403551C05999CF892D495F516 /* Foundation.framework */; }; + 0D6AD3708152BB59E38D5839A0B0377F /* Map.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A3658B178A16F05FFD28C46A18EF8E8 /* Map.swift */; }; + 107E73472222CFD28A8C640F332DA52A /* Scan.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD709EBAF5345AC238B7849DE5BCB273 /* Scan.swift */; }; + 110E6B43666A729745E9980F080944C4 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA9C5856BEAE5090A7D1EB450A10C04F /* Alamofire.framework */; }; + 12999CCB3E22F57CB230F85534EF6930 /* SingleAssignmentDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE3076AFBC266A6E88C8171467D6C5A5 /* SingleAssignmentDisposable.swift */; }; + 14DD51004DF8C27A7D0491AEFEC5F464 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9610BA4403551C05999CF892D495F516 /* Foundation.framework */; }; + 159C262BD23A08981D11D3B94340848B /* SynchronizedSubscribeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4D4B50A66CA7EB372C9BCE21D117CEC /* SynchronizedSubscribeType.swift */; }; + 165531B0C3FF4D343825C3DB0B79FD68 /* Observable+Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EFB1B59D84F8B11F82B8DF1A2150846 /* Observable+Time.swift */; }; + 1A11209BABC1DE84187BFAEA3E91602D /* RxMutableBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0C939A9E2A83A661C6EA3D4EE8DC54 /* RxMutableBox.swift */; }; + 1CBCB4FF2C9CDB144871C2A0856EB44D /* ConnectableObservableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39E5209D93CDC3C851C2F4454601FF04 /* ConnectableObservableType.swift */; }; + 2023E24B94C04CC05DDFB499ECA760FB /* Never.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF668BEB868B23FA177F79EA8B5D5CF /* Never.swift */; }; + 207AB9AAE48F202AF774554ED7545D98 /* InvocableScheduledItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C46F9E4863BA39300A28EEBB2FED44 /* InvocableScheduledItem.swift */; }; + 22C91CF507223CEE1A7E1302E912DC8B /* AddRef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C4BE1760C078A0188C4A66807F2C29 /* AddRef.swift */; }; + 22C9E40BB4DFB30DAAFD8555EF69BC08 /* HistoricalScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52611EC9CCB565A24C2C007F5A2CB6C3 /* HistoricalScheduler.swift */; }; + 23CA1BD96C4742DE71082211C8DBFF5F /* SchedulerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC88FCE0410EAE3C16E64A8A8108D142 /* SchedulerType.swift */; }; + 252E1D07E589566E0B8F49C2B9131976 /* WithLatestFrom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E2F61612759130FD3873E3FBE0E2CC0 /* WithLatestFrom.swift */; }; + 26E95A382D3F6848E571EF506D91B1C1 /* InvocableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97A3908B642D476F00987B50894F4C9 /* InvocableType.swift */; }; + 2BEA24EE395DA16EFEBC08B8D450F00A /* ObservableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A371B67E1A1BC9D198E470D4B54FEE87 /* ObservableType.swift */; }; + 2C5450AC69398958CF6F7539EF7D99E5 /* Alamofire-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 3341D7B714515136B34354D7D32202DB /* Alamofire-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2DF21CC164C25ED6947C67198879DE12 /* Variable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 101E84FB1E5F4A753DAF7518FB9BF0A7 /* Variable.swift */; }; + 313FCC5057970674AB6016DEF7A05902 /* SynchronizedUnsubscribeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292B4E8722DE17F6767ABED8D62A4C9E /* SynchronizedUnsubscribeType.swift */; }; + 3200EF8FA76EE92E0108DF928FB39CCB /* Switch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 636788473300310D67C31CCE1A571AC4 /* Switch.swift */; }; + 33393FE8FB3933A22617E02FA3FFA780 /* Skip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A31BA1E446FA35628A7DED964EF04F /* Skip.swift */; }; + 393372CC0F931D0D192179C4B16DF65E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9610BA4403551C05999CF892D495F516 /* Foundation.framework */; }; + 39F4B474510DFC1711DD2EF809EA101B /* Catch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE2208C0198E8412BDD034563E2B1A7 /* Catch.swift */; }; + 3AAB4B14DB0A02456F909B482400C142 /* DistinctUntilChanged.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0567A0BF989778CA9FF9575D62613B8E /* DistinctUntilChanged.swift */; }; + 3ADB6687421BF63BCC8A8C8D62E0C4F2 /* RefCount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADB3F22CC2D987B4C7E76A7B502DE81 /* RefCount.swift */; }; + 3DAFF4DA4C977B85B5C5B35728001AF2 /* Concat.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8B5CE5592D5B0BD393B7D599B053BFA /* Concat.swift */; }; + 3EE9F1D7EB9C05CB5821E18136EF812E /* SingleAsync.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA1AAD8792DE618CDBBF78CA8E642111 /* SingleAsync.swift */; }; + 402BB7DBAC4D93AD381A0075D7BDDDBA /* Zip+CollectionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6204091F721976FA7C97D74AC93B9637 /* Zip+CollectionType.swift */; }; + 4266AE0D8F9A4FA69F408AAC9118320A /* Merge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9144FDC8DC22962DE80692307106EF74 /* Merge.swift */; }; + 434C2C5108A8B9EEA916566F7DB0EDF6 /* Deferred.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6E7F9EA5FCA01B648E37743D97B9D57 /* Deferred.swift */; }; + 437C3354F611D5412125ADF24F4FDEE1 /* Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98250195E2C07F9A7DB5E4BB333ACE9 /* Rx.swift */; }; + 480B2F9937EF953E12DE12FCB177C32A /* TakeLast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D5E40EFDE70F2D69310639B473B817 /* TakeLast.swift */; }; + 498A556404BCE59DD962113CD29165A0 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = F250B545A022C0627A401DF08D2B7339 /* Errors.swift */; }; + 4A216C127342712EDE589085CBB58962 /* ElementAt.swift in Sources */ = {isa = PBXBuildFile; fileRef = DABFA04B3B312B12F4703582A14EEE51 /* ElementAt.swift */; }; + 4AE52A909A95E3E4A6DC2F48BD8FC758 /* SerialDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7FA9B23245D415690FB894178BBF20F /* SerialDisposable.swift */; }; + 4B059D5D108F9D2A4E51A6D1B477A2F5 /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211F73A46D90346F7FC6D0D29640EE4F /* Tag.swift */; }; + 4C5244B7F2D69F1DFC083E31070E3B0F /* Sink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37E5E51602A7EC243D3CC5A8B0FBC7E3 /* Sink.swift */; }; + 4CA85A5CF8897D7D46BC6D0D76C8189A /* Producer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD0626709B8BF22F5F6B42379D4C1EB /* Producer.swift */; }; + 4DB1B23F5FAF7C5E02520AFE08646AF2 /* BinaryDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5124609C66364357A0450CE5890AB140 /* BinaryDisposable.swift */; }; + 4DE5FCC41D100B113B6645EA64410F16 /* ParameterEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3107BC52C0E01198FAE330F1ADC0BF3C /* ParameterEncoding.swift */; }; + 4E1394BCD39E2E3470805196E884B68B /* PetstoreClient-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A8E0328DC896E0893B565FE8742167 /* PetstoreClient-dummy.m */; }; + 4EF8849290BCC9D36D8D75969F6753E7 /* ScheduledItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72DC2CBE50494D6723773E2C3E89C3C1 /* ScheduledItem.swift */; }; + 4F8D754FA3405C5B692B644166A0F02A /* AnonymousObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2CEC38D6994E89F7BD53BCE73AB7F89 /* AnonymousObservable.swift */; }; + 501A111A5AE07BC13E3265DB49EE0A1B /* Observable+Debug.swift in Sources */ = {isa = PBXBuildFile; fileRef = 051BE7827FDD01F32E6822EC2DE1CE1C /* Observable+Debug.swift */; }; + 527C7425A5831BFC30CC9EC216506393 /* TailRecursiveSink.swift in Sources */ = {isa = PBXBuildFile; fileRef = D02FE9C7BBEB944DACB0B057F631B40C /* TailRecursiveSink.swift */; }; + 54325B7F87498350C604C429751BEC97 /* APIHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2BAD338E56EF3CAA6E54490FE0C5DF9 /* APIHelper.swift */; }; + 55D355CC26824B52E1A7420802FB5DC5 /* ImmediateSchedulerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09BD8ACFD826D9E6CCCAAB5DDB0132BF /* ImmediateSchedulerType.swift */; }; + 569684CF06CEDCEA569BEC7910FC6E5B /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4DF0604EDC1460935E6E445A47023A4 /* Category.swift */; }; + 58023FA401993154E36E604471265263 /* DisposeBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983586C602A5C7D5B4FD91982F3711D0 /* DisposeBase.swift */; }; + 58344FE826FA6ED012A3450ACB0BF93D /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 19296A8C5E948345E5744A748B1CC720 /* RxSwift.framework */; }; + 5997C0F97BD6687648224D5C6442B862 /* DelaySubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0CED57E33C91E281A79EE0195FCAC2 /* DelaySubscription.swift */; }; + 5B721FAF55FEDB8046F23843565833A2 /* Repeat.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B14E7D38A4727796ABDFA4079BD210 /* Repeat.swift */; }; + 5BD263D28F10A84969A6521CA166957C /* Empty.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE69C5E6F8BF09D066522463F69EB8A6 /* Empty.swift */; }; + 5BDF0811AEFBD49A7DE4AF35DA3BD34F /* Multicast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D488959FBBFCF0351F42E7D150C1942 /* Multicast.swift */; }; + 5C8C1A80AB947F293430868D52A910C2 /* HistoricalSchedulerTimeConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9064EE8CEF10A602EFC90A26D1DC39 /* HistoricalSchedulerTimeConverter.swift */; }; + 5CF87E88489D3832C46FAFCE191F78F9 /* TakeWhile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72F5796E9AA6A65EA2149A206ADE4289 /* TakeWhile.swift */; }; + 6007585CC5912D979404BDB047CD36C4 /* Platform.Darwin.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC3B7613AC16E246F73123670BAED3F5 /* Platform.Darwin.swift */; }; + 618251D2C3027F214154D2CDFE1900AB /* Observable+Creation.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBED49C45F40708D9355E7D2CFFE4602 /* Observable+Creation.swift */; }; + 6414AAC9ED1AD7417B005D50D04341F5 /* ObserveOn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 315D8F39A79B562AA2268250BED93150 /* ObserveOn.swift */; }; + 66D9046FEDE40E6732F8B3E090007268 /* RefCountDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC50E209B29C93EAECE01AD46DBAE7 /* RefCountDisposable.swift */; }; + 68614EDB167FFFA6FBEC851368044FB3 /* Observable+Multiple.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B0F57917A904327F2D141C7E2E8623F /* Observable+Multiple.swift */; }; + 69AC467220269CE474E1C1156912C9DD /* RxSwift-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = BDA5F3724FE84CF94299E36A8DF89017 /* RxSwift-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 717576C9ABD8ABE8163D441ABE1C4A8D /* SynchronizedOnType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7B5D80C0F71324ED10DBE73D28402DB /* SynchronizedOnType.swift */; }; + 725EED04ED27CA8159CB2683F1EFD45A /* Pods-SwaggerClient-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EEBA91980AEC8774CF7EC08035B089A /* Pods-SwaggerClient-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 72CF8071AF37B85C1DE763805C39A3AB /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1974F6C69B156C91AE3DD56FAC5A3808 /* Lock.swift */; }; + 731E6ACE4939DCE8F6AF47FA1A00D595 /* Observable+Single.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8033FB9B41A3E314A0CC6C50015B835D /* Observable+Single.swift */; }; + 751E794A58F9FCB7738D4ED30D10DD19 /* AnyObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF0E5B19D36827BBE8598B8ACC2EC189 /* AnyObserver.swift */; }; + 7574EBA19BA114D77C76D2CC1B58E73C /* Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC79FC8F9A849970B716868E7F51D2C /* Timeout.swift */; }; + 75D86B4420906282E6B3393E98837360 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5412898DEB10F1983487A10453C6B9CB /* Extensions.swift */; }; + 77D1DB57FAA744C6ECBA7242836D6479 /* AnonymousObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914B1C0C6B1C0BB87F3EB1E7F1060425 /* AnonymousObserver.swift */; }; + 79F6454BBF28D094A211494E22A07327 /* SkipUntil.swift in Sources */ = {isa = PBXBuildFile; fileRef = D69A080DF8671D7B4CEB7E706EF4667F /* SkipUntil.swift */; }; + 7A6597623E723E6F8350D2CA30A2CD9C /* Observable+Aggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2489BF8D3C006E1A6E9FA8E1275FC1 /* Observable+Aggregate.swift */; }; + 7E11CAC09AC72BD412078441E2F7BC21 /* VirtualTimeConverterType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B5E5E7372652C9D351B65002A966365 /* VirtualTimeConverterType.swift */; }; + 7E6DD4CEE210B03B7E3A0F01A36A7624 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 075BA1FDBF8D0B4B1D383DF8FD3BE509 /* Sequence.swift */; }; + 7F8297BE677C9A67B915F044DB16C0BE /* ShareReplay1WhileConnected.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35A3C82BD63330195DE669D3836B7E41 /* ShareReplay1WhileConnected.swift */; }; + 7F82F4EE1BA91C32CE75312176ACD4F0 /* Take.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CAF565A8B834CB6FD86DDFF010D4E4B /* Take.swift */; }; + 80F496237530D382A045A29654D8C11C /* ServerTrustPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C4F5E9ABF91F6B2FF369456D3804258 /* ServerTrustPolicy.swift */; }; + 82971968CBDAB224212EEB4607C9FB8D /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = BABA671A27CF29C8AA31D5C66D34CBA3 /* Result.swift */; }; + 82DB09296E2BC713C6D363528657A3FD /* ToArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17534D83D8298C9D739F4506816D218F /* ToArray.swift */; }; + 8399DBEE3E2D98EB1F466132E476F4D9 /* MultipartFormData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D21C15998D42252EF80A55181C7D18 /* MultipartFormData.swift */; }; + 84B43422CBE09278E477D1BFF27B07A1 /* Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81BA6471D19E57603D3AF0A0A49939B9 /* Window.swift */; }; + 84B93CFEFA6412E49988C92153998357 /* AnonymousInvocable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 257C3EC4A4AA8458E5B4BE717014B450 /* AnonymousInvocable.swift */; }; + 85E0465919F9DC7C97DD593CB49BB5E0 /* ShareReplay1.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFB51688711C8369A2961F69330DCC99 /* ShareReplay1.swift */; }; + 8634F37209E5506667C604C1973F630D /* StoreAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E5E3CD673B025FD8AC260E67AB47E /* StoreAPI.swift */; }; + 88CCC2ADA43F75CB4708A701F5031643 /* ObserverBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F1954F056E7EC88AD642B7E7D937664 /* ObserverBase.swift */; }; + 897283A0B7F5299913327CC8FD6CC997 /* Pods-SwaggerClientTests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = F22FE315AC1C04A8749BD18281EE9028 /* Pods-SwaggerClientTests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8B68A752ED9CC80E5478E4FEC5A5F721 /* Pods-SwaggerClient-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 291054DAA3207AFC1F6B3D7AD6C25E5C /* Pods-SwaggerClient-dummy.m */; }; + 8BDC4F0F424CA9A8190F28E7A02417A8 /* Cancelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09414F47E12D9B51147335D651E0D536 /* Cancelable.swift */; }; + 8D3CD54E3BACC9DB116DDA2DC30420CF /* ObserverType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B9FE8B611FD713A03D461C686322726 /* ObserverType.swift */; }; + 92450B928E8001F2B28A80072611F4C1 /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14EB178F75EE27270C8F21ADA50D9C41 /* Error.swift */; }; + 9543E1505CCD2189D86456DAA0D55A22 /* BehaviorSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88A83A4C472835F0F6BDC178F2EF51A6 /* BehaviorSubject.swift */; }; + 956216483BCB853794F52B0292831E9C /* DispatchQueueSchedulerQOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 609B0D6771C363A74DDB9B2FFF4A9BAC /* DispatchQueueSchedulerQOS.swift */; }; + 96A03A2C4325A59DE2B02913FE351815 /* BooleanDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B81B0D0B0B21977235410AAD4CFECB /* BooleanDisposable.swift */; }; + 97AB8959ABA0C9B8D4F400FD814BBB65 /* UserAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552D15E0340BF58CC1922B82E864AEC9 /* UserAPI.swift */; }; + 983C8A7CA7087B8FD905B6392B05B790 /* AlamofireImplementations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92734297B64DFE0EB0EDE1EA821163DB /* AlamofireImplementations.swift */; }; + 98FA1CFF63A5E74A7DB3255DA60C1843 /* DisposeBag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B72DF27B30B51C1091F485174052F1D /* DisposeBag.swift */; }; + 99F6DFF51E7C238DF99CA788144C732A /* CombineLatest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516C671101243A9465AF2A689641D598 /* CombineLatest.swift */; }; + 9C3C83B09DE882AA526C40FDA31B69C8 /* Throttle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D3B68FA022AAECF54F3CBFB928B666 /* Throttle.swift */; }; + 9C824A364077ED1458CEF9776F2FB44A /* String+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64FED6C504DC2686A1BF8615B1D0213F /* String+Rx.swift */; }; + 9FDB94097AD437CDE44A507037AE4010 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9610BA4403551C05999CF892D495F516 /* Foundation.framework */; }; + A0A18CB5F889D7C2F80D6024EA568BEA /* Observable+Concurrency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CA8E405CD1F1D51078388FDE3498848 /* Observable+Concurrency.swift */; }; + A1B963DD34D20B255430C99DD78A1D43 /* Order.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A545673F09F49CDD60A13B4B0AF1020 /* Order.swift */; }; + A23E9C4262ED3ED9FF20A9E6E1FA2121 /* SerialDispatchQueueScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE009E15582DF43271F4102E7EC30F5 /* SerialDispatchQueueScheduler.swift */; }; + A2C172FE407C0BC3478ADCA91A6C9CEC /* Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25A12681F026446EDBE1C55D22872F9D /* Manager.swift */; }; + A3505FA2FB3067D53847AD288AC04F03 /* Download.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64491633490DB74E1E8D2CED2021C746 /* Download.swift */; }; + A4FBC2BD1A93FA52B5C97E79CDB9302F /* ImmediateScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E056012594D80C40AF86E23AAD413A0 /* ImmediateScheduler.swift */; }; + A606E44DA4B92B1FFBA177125D55F6AA /* Buffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31889B2EAD6E61A01714C04A70E0DF6F /* Buffer.swift */; }; + A67CCBFC004EF58E785FA7ED4A1B69B6 /* Generate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F68420AE4974226AE95592AB01F5C3 /* Generate.swift */; }; + AC265ECE8E2AF91D58A755022E7DF802 /* PriorityQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F9095E4F9CC417FB1536F011BCAFACA /* PriorityQueue.swift */; }; + AD9D268210ED449C3BE591513FD0CFB8 /* RecursiveScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DEE36ACBCF70F5F1553D055175D1622 /* RecursiveScheduler.swift */; }; + ADC582F488BC636CC4292513053F6992 /* AsyncLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEC4CF736B6956856103762EC255EEA2 /* AsyncLock.swift */; }; + AF3E5D2CE5E3448DB881E0F40F2F334F /* Do.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D1009B6CD1857E5025278FDFACF63C /* Do.swift */; }; + AFF9AA31B242BF7F011D018D1B2A12FC /* PetAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 261F03A3C73374FD19333EEA59CCD59F /* PetAPI.swift */; }; + B0EAF63B91ABFD39C96353392D157D19 /* Zip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 321E8BEC99166D3ED7E88CDBACBE407A /* Zip.swift */; }; + B0F20FEA2B9A800D016EF5B46EFDECE9 /* CombineLatest+arity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D9A8D2D89ACE5DBF27150F182DE34E /* CombineLatest+arity.swift */; }; + B0FB4B01682814B9E3D32F9DC4A5E762 /* Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621056D7E34F3276D7ECDB147918DBEC /* Alamofire.swift */; }; + B22405A127912A4943AEFBDD57E7A267 /* AnonymousDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DE7F5B430FDC646F58271F85B672788 /* AnonymousDisposable.swift */; }; + B28CA824CA5CD903042D8A07E9C5950E /* ReplaySubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0FF31F56DFA84FE0CDF777CF56845 /* ReplaySubject.swift */; }; + B33369A55E29C11FA5F5977B5A47F1D4 /* RxSwift-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 24D7DE1FFF6AE5D438E4DAC777A8B8F2 /* RxSwift-dummy.m */; }; + B45CADB404E006E0EA39D7239C81C64F /* StableCompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC813A2800E1E5B7D9C9A9A095B0D51E /* StableCompositeDisposable.swift */; }; + B590B3C59D3A327452D2532766F2F630 /* MainScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B77AAD2C4150B81817D5833C2B78B7C /* MainScheduler.swift */; }; + B6D2DC3E3DA44CD382B9B425F40E11C1 /* Alamofire-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 14BA42A836361E4416D38DECBEFE25C0 /* Alamofire-dummy.m */; }; + B754E33E17893DF35DECA754DE819A66 /* Queue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C78DB1DE41EDF5A70DBAB37DA9904B /* Queue.swift */; }; + B7DCF4199B0EEF4CB2FE0DFF23F99049 /* SkipWhile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F329D6196F35CB573BEBA0D2379035F /* SkipWhile.swift */; }; + BB03FC085AE6A19821878DE92116DDD5 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0266C5AE0B23A436291F6647902086 /* Models.swift */; }; + BB3A568E8ED6C1792B43708A36A66F3D /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAB8BECDF386291E0D615DE5171B181 /* Event.swift */; }; + BB5C8DC43B5072BBC05F56BF4DFD8CC5 /* Zip+arity.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF6B90536554BCC5A32E2DC7731D9FD /* Zip+arity.swift */; }; + BC10CEE813861D2F71E501E2F06532AB /* ScheduledItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07017B36556829104C6CC52B3E0DFDA4 /* ScheduledItemType.swift */; }; + C3739BDF471B57AECC84085608EC9CE6 /* InfiniteSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34DB4ED4653A16819871618F69B3182D /* InfiniteSequence.swift */; }; + C5099A3F4D955165F503506F2D10065D /* SynchronizedDisposeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C239D292236A2F59F0F6F5F1DB31795E /* SynchronizedDisposeType.swift */; }; + C546890220177F840E8AFC829D0E3FEB /* Pods-SwaggerClientTests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 687B19CB3E722272B41D60B485C29EE7 /* Pods-SwaggerClientTests-dummy.m */; }; + C6EFFFF6D9947B99945FE08559733EF6 /* Timer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A03FE8BD209B0504BE052CBD44BD277A /* Timer.swift */; }; + C75519F0450166A6F28126ECC7664E9C /* Validation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F31DEFD11FF950B319F5E3A97C41178F /* Validation.swift */; }; + CA4A98FD2226B57E5F59E0BA2E1A97EC /* OperationQueueScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38E6FD240ADA8F1BCE82B9426E6EF8F /* OperationQueueScheduler.swift */; }; + CD00FDDA48E9BC390530672F9F09D8CF /* Amb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EF617EC4E8045D4B384E618B83B2F6F /* Amb.swift */; }; + CDF08B0C84BE839E79DF99C271453406 /* SubscriptionDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F52905F2DED9823E28E154C2CD365A0 /* SubscriptionDisposable.swift */; }; + CF13D1D873436D3890EC7392DEDE0B3E /* ObserveOnSerialDispatchQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 922907F82CF71DEBAE0585263AEF4518 /* ObserveOnSerialDispatchQueue.swift */; }; + D0F5068C6F5C0489E8A41A9912A09016 /* Range.swift in Sources */ = {isa = PBXBuildFile; fileRef = 509773F27764F1FF30E06C5F91E1FF0D /* Range.swift */; }; + D180CF545583D5DCDF770FBAA36F5DB0 /* Filter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B5BDA8EA0E40E1A09E34DD0FF21BAD9 /* Filter.swift */; }; + D190592C39D806474770AF30FCC4EF4E /* Bag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2529676E540C411C575AB0CD27CCEF57 /* Bag.swift */; }; + D21B7325B3642887BFBE977E021F2D26 /* ResponseSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = A56FED751BA06FF779D945B5D478065C /* ResponseSerialization.swift */; }; + D4789D8318C97E380412D03C1C321A88 /* Platform.Linux.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0668CCF084235C10B605A3F640FB98D8 /* Platform.Linux.swift */; }; + D5ECB1C860D3F53280EE2C5E54D470BD /* Using.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93ECB6F232D07DFDE4F782C41FFD85FE /* Using.swift */; }; + D75CA395D510E08C404E55F5BDAE55CE /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 526E73E2F71E0EC1442DFF1E6C3D7626 /* Error.swift */; }; + D932A3F3727B26175B547BA865A76B81 /* TakeUntil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC78F9679615E991FC6F18D85FCF21C /* TakeUntil.swift */; }; + D99C59116FC2BC799C9C9DE4D0282EB9 /* Observable+Binding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D9E0FD7CAAFFDA1BCA65C0DE4AB27B4 /* Observable+Binding.swift */; }; + DA18B15A9632B7282CF91FE4771C0B60 /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A272A3BAB4634A80251132C7FB980D8A /* Observable.swift */; }; + DA202CAFA730E897B4D302C8C603A7E1 /* Pet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 284B3DE9B793FCC633E971DB1798AFAF /* Pet.swift */; }; + DB5B0A5C01527330DCD4CEF9740C7140 /* PublishSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84665902C00313BF6D709D279E597AF9 /* PublishSubject.swift */; }; + DC9EF51CEA903F88D43F7B3A96923DFD /* SubscribeOn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46BB6E8D195D7B7711B8B0B50213D36B /* SubscribeOn.swift */; }; + DFF7D509E6FC70067A71C1CF0441AD48 /* PetstoreClient-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F681D2C508D1BA8F62893120D9343A4 /* PetstoreClient-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E16A421C7269D0E81CB5E59344E63391 /* NAryDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C6944EFCED2081E91C44EEF357D1EA3 /* NAryDisposable.swift */; }; + E315A5FF56451DF73C7FE3140D5E2C6C /* ObservableConvertibleType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D072A90162699810B672895226A27C43 /* ObservableConvertibleType.swift */; }; + E51F4BE281ADBC629708A4D131E9190C /* Disposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD65E96303458AB841FAD17494E26AAD /* Disposable.swift */; }; + E61B26D220A1A27E3BE7AD3F9BE35C76 /* Observable+StandardSequenceOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372C2E8DD6FEE19981359253F88A881F /* Observable+StandardSequenceOperators.swift */; }; + E8CAB3FA190277C8E609F992A51EA9D2 /* StartWith.swift in Sources */ = {isa = PBXBuildFile; fileRef = F17B79123C6F61E5E5DBBF14710E6012 /* StartWith.swift */; }; + ECFCC7B806126EF7788D0DE094711905 /* CurrentThreadScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51171A514198E93AF767FD06958653FA /* CurrentThreadScheduler.swift */; }; + EE42701AD3887754AF7695978852957E /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB5D61F564F3FF7A53825B0EF70E98B4 /* Observable+Extensions.swift */; }; + F206C370F63155D3468E0C188498C5DC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9610BA4403551C05999CF892D495F516 /* Foundation.framework */; }; + F2246690EA6DEBF52D4CACA089B7FFC0 /* LockOwnerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED580EA15AD5B2541B7EBE483BEE21EE /* LockOwnerType.swift */; }; + F460F46DBA5EE0D4FABB3CD0BEFE6CE3 /* Debug.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E21F1428A7A2D51A86015D1E4531D87 /* Debug.swift */; }; + FC14480CECE872865A9C6E584F886DA3 /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86C5082D39612A1F1FD675C33932AEC9 /* Request.swift */; }; + FEDA6187E5CC1CFB1781F8F4947E160C /* ConcurrentMainScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBCE4DC8C3C8888BE09F0BC0EFCB3EA /* ConcurrentMainScheduler.swift */; }; + FEF0D7653948988B804226129471C1EC /* Stream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EF1F005F839FD46AD74F13986274F1B /* Stream.swift */; }; + FFDD18622776D270EAFE1CF94726C96D /* VirtualTimeScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25C6BCDF18A3A22B7FEDE36B0A580C0E /* VirtualTimeScheduler.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 1B1D2D2B5F790067C63584DC46E8DEED /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 432ECC54282C84882B482CCB4CF227FC; + remoteInfo = Alamofire; + }; + 1E7EDC9660FD64A123EAC6BDA4C055AC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = F316854D76F084E9539BFEF85DCBCF9D; + remoteInfo = RxSwift; + }; + 80996B8BB3446668F158E7817336A6E4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 432ECC54282C84882B482CCB4CF227FC; + remoteInfo = Alamofire; + }; + C11AB97FC44865EAFD37FD7629B96B72 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = F316854D76F084E9539BFEF85DCBCF9D; + remoteInfo = RxSwift; + }; + D6508A8A1DB5D04976ECA9641101DB50 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = B3F4219972B712BDBD25392781A43848; + remoteInfo = PetstoreClient; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 00ACB4396DD1B4E4539E4E81C1D7A14E /* Pods-SwaggerClientTests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-SwaggerClientTests.modulemap"; sourceTree = ""; }; + 02F28E719AA874BE9213D6CF8CE7E36B /* Pods-SwaggerClientTests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-SwaggerClientTests-acknowledgements.plist"; sourceTree = ""; }; + 051BE7827FDD01F32E6822EC2DE1CE1C /* Observable+Debug.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Debug.swift"; path = "RxSwift/Observables/Observable+Debug.swift"; sourceTree = ""; }; + 0567A0BF989778CA9FF9575D62613B8E /* DistinctUntilChanged.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DistinctUntilChanged.swift; path = RxSwift/Observables/Implementations/DistinctUntilChanged.swift; sourceTree = ""; }; + 057FC3E5DE19EA8F4DD600557D771032 /* Pods_SwaggerClient.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwaggerClient.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 0668CCF084235C10B605A3F640FB98D8 /* Platform.Linux.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Platform.Linux.swift; path = RxSwift/Platform/Platform.Linux.swift; sourceTree = ""; }; + 06C46F9E4863BA39300A28EEBB2FED44 /* InvocableScheduledItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = InvocableScheduledItem.swift; path = RxSwift/Schedulers/Internal/InvocableScheduledItem.swift; sourceTree = ""; }; + 07017B36556829104C6CC52B3E0DFDA4 /* ScheduledItemType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ScheduledItemType.swift; path = RxSwift/Schedulers/Internal/ScheduledItemType.swift; sourceTree = ""; }; + 075BA1FDBF8D0B4B1D383DF8FD3BE509 /* Sequence.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sequence.swift; path = RxSwift/Observables/Implementations/Sequence.swift; sourceTree = ""; }; + 09414F47E12D9B51147335D651E0D536 /* Cancelable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Cancelable.swift; path = RxSwift/Cancelable.swift; sourceTree = ""; }; + 09BD8ACFD826D9E6CCCAAB5DDB0132BF /* ImmediateSchedulerType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImmediateSchedulerType.swift; path = RxSwift/ImmediateSchedulerType.swift; sourceTree = ""; }; + 0A545673F09F49CDD60A13B4B0AF1020 /* Order.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Order.swift; sourceTree = ""; }; + 0B72DF27B30B51C1091F485174052F1D /* DisposeBag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DisposeBag.swift; path = RxSwift/Disposables/DisposeBag.swift; sourceTree = ""; }; + 0B9FE8B611FD713A03D461C686322726 /* ObserverType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ObserverType.swift; path = RxSwift/ObserverType.swift; sourceTree = ""; }; + 0CAB8BECDF386291E0D615DE5171B181 /* Event.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Event.swift; path = RxSwift/Event.swift; sourceTree = ""; }; + 0DE7F5B430FDC646F58271F85B672788 /* AnonymousDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnonymousDisposable.swift; path = RxSwift/Disposables/AnonymousDisposable.swift; sourceTree = ""; }; + 0E21F1428A7A2D51A86015D1E4531D87 /* Debug.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Debug.swift; path = RxSwift/Observables/Implementations/Debug.swift; sourceTree = ""; }; + 101E84FB1E5F4A753DAF7518FB9BF0A7 /* Variable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Variable.swift; path = RxSwift/Subjects/Variable.swift; sourceTree = ""; }; + 10D1C22E4BBFB16E5C966FF77E92F296 /* SchedulerServices+Emulation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "SchedulerServices+Emulation.swift"; path = "RxSwift/Schedulers/SchedulerServices+Emulation.swift"; sourceTree = ""; }; + 14BA42A836361E4416D38DECBEFE25C0 /* Alamofire-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Alamofire-dummy.m"; sourceTree = ""; }; + 14EB178F75EE27270C8F21ADA50D9C41 /* Error.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Error.swift; path = RxSwift/Observables/Implementations/Error.swift; sourceTree = ""; }; + 14F8F74E862AC5CA39F8E5132F1C00B9 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 17534D83D8298C9D739F4506816D218F /* ToArray.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ToArray.swift; path = RxSwift/Observables/Implementations/ToArray.swift; sourceTree = ""; }; + 17881314399342A30A86EF8655AFD35C /* ScheduledDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ScheduledDisposable.swift; path = RxSwift/Disposables/ScheduledDisposable.swift; sourceTree = ""; }; + 19296A8C5E948345E5744A748B1CC720 /* RxSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 1974F6C69B156C91AE3DD56FAC5A3808 /* Lock.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Lock.swift; path = RxSwift/Concurrency/Lock.swift; sourceTree = ""; }; + 19C0FF31F56DFA84FE0CDF777CF56845 /* ReplaySubject.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ReplaySubject.swift; path = RxSwift/Subjects/ReplaySubject.swift; sourceTree = ""; }; + 1A3E5E3CD673B025FD8AC260E67AB47E /* StoreAPI.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = StoreAPI.swift; sourceTree = ""; }; + 1BE009E15582DF43271F4102E7EC30F5 /* SerialDispatchQueueScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SerialDispatchQueueScheduler.swift; path = RxSwift/Schedulers/SerialDispatchQueueScheduler.swift; sourceTree = ""; }; + 1C7A9744D1553CE8C58822392FE251D8 /* Alamofire-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Alamofire-prefix.pch"; sourceTree = ""; }; + 1EF617EC4E8045D4B384E618B83B2F6F /* Amb.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Amb.swift; path = RxSwift/Observables/Implementations/Amb.swift; sourceTree = ""; }; + 1F0C939A9E2A83A661C6EA3D4EE8DC54 /* RxMutableBox.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RxMutableBox.swift; path = RxSwift/RxMutableBox.swift; sourceTree = ""; }; + 1F9095E4F9CC417FB1536F011BCAFACA /* PriorityQueue.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PriorityQueue.swift; path = RxSwift/DataStructures/PriorityQueue.swift; sourceTree = ""; }; + 211F73A46D90346F7FC6D0D29640EE4F /* Tag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = ""; }; + 24D7DE1FFF6AE5D438E4DAC777A8B8F2 /* RxSwift-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "RxSwift-dummy.m"; sourceTree = ""; }; + 2529676E540C411C575AB0CD27CCEF57 /* Bag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Bag.swift; path = RxSwift/DataStructures/Bag.swift; sourceTree = ""; }; + 257C3EC4A4AA8458E5B4BE717014B450 /* AnonymousInvocable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnonymousInvocable.swift; path = RxSwift/Schedulers/Internal/AnonymousInvocable.swift; sourceTree = ""; }; + 25A12681F026446EDBE1C55D22872F9D /* Manager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Manager.swift; path = Source/Manager.swift; sourceTree = ""; }; + 25C6BCDF18A3A22B7FEDE36B0A580C0E /* VirtualTimeScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = VirtualTimeScheduler.swift; path = RxSwift/Schedulers/VirtualTimeScheduler.swift; sourceTree = ""; }; + 25D1E84FDF56D9C05CACE85F684D9965 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 261F03A3C73374FD19333EEA59CCD59F /* PetAPI.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PetAPI.swift; sourceTree = ""; }; + 284B3DE9B793FCC633E971DB1798AFAF /* Pet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Pet.swift; sourceTree = ""; }; + 291054DAA3207AFC1F6B3D7AD6C25E5C /* Pods-SwaggerClient-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-SwaggerClient-dummy.m"; sourceTree = ""; }; + 292B4E8722DE17F6767ABED8D62A4C9E /* SynchronizedUnsubscribeType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SynchronizedUnsubscribeType.swift; path = RxSwift/Concurrency/SynchronizedUnsubscribeType.swift; sourceTree = ""; }; + 2AC78F9679615E991FC6F18D85FCF21C /* TakeUntil.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TakeUntil.swift; path = RxSwift/Observables/Implementations/TakeUntil.swift; sourceTree = ""; }; + 2B77AAD2C4150B81817D5833C2B78B7C /* MainScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MainScheduler.swift; path = RxSwift/Schedulers/MainScheduler.swift; sourceTree = ""; }; + 2FE2208C0198E8412BDD034563E2B1A7 /* Catch.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Catch.swift; path = RxSwift/Observables/Implementations/Catch.swift; sourceTree = ""; }; + 2FF17440CCD2E1A69791A4AA23325AD5 /* Pods-SwaggerClient-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-SwaggerClient-acknowledgements.markdown"; sourceTree = ""; }; + 3107BC52C0E01198FAE330F1ADC0BF3C /* ParameterEncoding.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ParameterEncoding.swift; path = Source/ParameterEncoding.swift; sourceTree = ""; }; + 315D8F39A79B562AA2268250BED93150 /* ObserveOn.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ObserveOn.swift; path = RxSwift/Observables/Implementations/ObserveOn.swift; sourceTree = ""; }; + 31889B2EAD6E61A01714C04A70E0DF6F /* Buffer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Buffer.swift; path = RxSwift/Observables/Implementations/Buffer.swift; sourceTree = ""; }; + 31D3B68FA022AAECF54F3CBFB928B666 /* Throttle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Throttle.swift; path = RxSwift/Observables/Implementations/Throttle.swift; sourceTree = ""; }; + 321E8BEC99166D3ED7E88CDBACBE407A /* Zip.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Zip.swift; path = RxSwift/Observables/Implementations/Zip.swift; sourceTree = ""; }; + 3341D7B714515136B34354D7D32202DB /* Alamofire-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Alamofire-umbrella.h"; sourceTree = ""; }; + 34DB4ED4653A16819871618F69B3182D /* InfiniteSequence.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = InfiniteSequence.swift; path = RxSwift/DataStructures/InfiniteSequence.swift; sourceTree = ""; }; + 35A3C82BD63330195DE669D3836B7E41 /* ShareReplay1WhileConnected.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ShareReplay1WhileConnected.swift; path = RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift; sourceTree = ""; }; + 372C2E8DD6FEE19981359253F88A881F /* Observable+StandardSequenceOperators.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+StandardSequenceOperators.swift"; path = "RxSwift/Observables/Observable+StandardSequenceOperators.swift"; sourceTree = ""; }; + 37E5E51602A7EC243D3CC5A8B0FBC7E3 /* Sink.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sink.swift; path = RxSwift/Observables/Implementations/Sink.swift; sourceTree = ""; }; + 39E5209D93CDC3C851C2F4454601FF04 /* ConnectableObservableType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConnectableObservableType.swift; path = RxSwift/ConnectableObservableType.swift; sourceTree = ""; }; + 3B5E5E7372652C9D351B65002A966365 /* VirtualTimeConverterType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = VirtualTimeConverterType.swift; path = RxSwift/Schedulers/VirtualTimeConverterType.swift; sourceTree = ""; }; + 3C0CED57E33C91E281A79EE0195FCAC2 /* DelaySubscription.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DelaySubscription.swift; path = RxSwift/Observables/Implementations/DelaySubscription.swift; sourceTree = ""; }; + 3C2489BF8D3C006E1A6E9FA8E1275FC1 /* Observable+Aggregate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Aggregate.swift"; path = "RxSwift/Observables/Observable+Aggregate.swift"; sourceTree = ""; }; + 3EB61DA897ED3DE273EC2B5824A42DF0 /* Response.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Response.swift; path = Source/Response.swift; sourceTree = ""; }; + 3EEBA91980AEC8774CF7EC08035B089A /* Pods-SwaggerClient-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-SwaggerClient-umbrella.h"; sourceTree = ""; }; + 3F16B43ABD2C8CD4A311AA1AB3B6C02F /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3F52905F2DED9823E28E154C2CD365A0 /* SubscriptionDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SubscriptionDisposable.swift; path = RxSwift/Disposables/SubscriptionDisposable.swift; sourceTree = ""; }; + 43FC49AA70D3E2A84CAED9C37BE9C4B5 /* Pods-SwaggerClientTests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SwaggerClientTests-frameworks.sh"; sourceTree = ""; }; + 46A8E0328DC896E0893B565FE8742167 /* PetstoreClient-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "PetstoreClient-dummy.m"; sourceTree = ""; }; + 46BB6E8D195D7B7711B8B0B50213D36B /* SubscribeOn.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SubscribeOn.swift; path = RxSwift/Observables/Implementations/SubscribeOn.swift; sourceTree = ""; }; + 47C4BE1760C078A0188C4A66807F2C29 /* AddRef.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AddRef.swift; path = RxSwift/Observables/Implementations/AddRef.swift; sourceTree = ""; }; + 48F68420AE4974226AE95592AB01F5C3 /* Generate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Generate.swift; path = RxSwift/Observables/Implementations/Generate.swift; sourceTree = ""; }; + 4A3658B178A16F05FFD28C46A18EF8E8 /* Map.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Map.swift; path = RxSwift/Observables/Implementations/Map.swift; sourceTree = ""; }; + 4CAF565A8B834CB6FD86DDFF010D4E4B /* Take.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Take.swift; path = RxSwift/Observables/Implementations/Take.swift; sourceTree = ""; }; + 509773F27764F1FF30E06C5F91E1FF0D /* Range.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Range.swift; path = RxSwift/Observables/Implementations/Range.swift; sourceTree = ""; }; + 51171A514198E93AF767FD06958653FA /* CurrentThreadScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CurrentThreadScheduler.swift; path = RxSwift/Schedulers/CurrentThreadScheduler.swift; sourceTree = ""; }; + 5124609C66364357A0450CE5890AB140 /* BinaryDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BinaryDisposable.swift; path = RxSwift/Disposables/BinaryDisposable.swift; sourceTree = ""; }; + 516C671101243A9465AF2A689641D598 /* CombineLatest.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CombineLatest.swift; path = RxSwift/Observables/Implementations/CombineLatest.swift; sourceTree = ""; }; + 52611EC9CCB565A24C2C007F5A2CB6C3 /* HistoricalScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = HistoricalScheduler.swift; path = RxSwift/Schedulers/HistoricalScheduler.swift; sourceTree = ""; }; + 526E73E2F71E0EC1442DFF1E6C3D7626 /* Error.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Error.swift; path = Source/Error.swift; sourceTree = ""; }; + 5412898DEB10F1983487A10453C6B9CB /* Extensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; + 549C6527D10094289B101749047807C5 /* Pods-SwaggerClient.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SwaggerClient.debug.xcconfig"; sourceTree = ""; }; + 552D15E0340BF58CC1922B82E864AEC9 /* UserAPI.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = UserAPI.swift; sourceTree = ""; }; + 5ADB3F22CC2D987B4C7E76A7B502DE81 /* RefCount.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RefCount.swift; path = RxSwift/Observables/Implementations/RefCount.swift; sourceTree = ""; }; + 5B248364ABF60ACD7DB31A17DCFDFD0C /* User.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; + 5B598E168B47485DC60F9DBBCBEEF5BB /* Alamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Alamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 5C6944EFCED2081E91C44EEF357D1EA3 /* NAryDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NAryDisposable.swift; path = RxSwift/Disposables/NAryDisposable.swift; sourceTree = ""; }; + 5CF9673331C58F7D9396CDEC9CE940A9 /* CombineLatest+CollectionType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "CombineLatest+CollectionType.swift"; path = "RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift"; sourceTree = ""; }; + 5DEE36ACBCF70F5F1553D055175D1622 /* RecursiveScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RecursiveScheduler.swift; path = RxSwift/Schedulers/RecursiveScheduler.swift; sourceTree = ""; }; + 609B0D6771C363A74DDB9B2FFF4A9BAC /* DispatchQueueSchedulerQOS.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DispatchQueueSchedulerQOS.swift; path = RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift; sourceTree = ""; }; + 6156CD5049D33CC68DF29760B398B408 /* NopDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NopDisposable.swift; path = RxSwift/Disposables/NopDisposable.swift; sourceTree = ""; }; + 6204091F721976FA7C97D74AC93B9637 /* Zip+CollectionType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Zip+CollectionType.swift"; path = "RxSwift/Observables/Implementations/Zip+CollectionType.swift"; sourceTree = ""; }; + 621056D7E34F3276D7ECDB147918DBEC /* Alamofire.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Alamofire.swift; path = Source/Alamofire.swift; sourceTree = ""; }; + 62EC50E209B29C93EAECE01AD46DBAE7 /* RefCountDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RefCountDisposable.swift; path = RxSwift/Disposables/RefCountDisposable.swift; sourceTree = ""; }; + 636788473300310D67C31CCE1A571AC4 /* Switch.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Switch.swift; path = RxSwift/Observables/Implementations/Switch.swift; sourceTree = ""; }; + 64491633490DB74E1E8D2CED2021C746 /* Download.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Download.swift; path = Source/Download.swift; sourceTree = ""; }; + 64FED6C504DC2686A1BF8615B1D0213F /* String+Rx.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "String+Rx.swift"; path = "RxSwift/Extensions/String+Rx.swift"; sourceTree = ""; }; + 66429A42B7499250307412ECB7AF627E /* Alamofire.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Alamofire.xcconfig; sourceTree = ""; }; + 687B19CB3E722272B41D60B485C29EE7 /* Pods-SwaggerClientTests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-SwaggerClientTests-dummy.m"; sourceTree = ""; }; + 6C4F5E9ABF91F6B2FF369456D3804258 /* ServerTrustPolicy.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ServerTrustPolicy.swift; path = Source/ServerTrustPolicy.swift; sourceTree = ""; }; + 6DBCE4DC8C3C8888BE09F0BC0EFCB3EA /* ConcurrentMainScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConcurrentMainScheduler.swift; path = RxSwift/Schedulers/ConcurrentMainScheduler.swift; sourceTree = ""; }; + 6EBAF7A3F8D6D888BC91244485ECD2AA /* Alamofire.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Alamofire.modulemap; sourceTree = ""; }; + 6EF1F005F839FD46AD74F13986274F1B /* Stream.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Stream.swift; path = Source/Stream.swift; sourceTree = ""; }; + 6F1954F056E7EC88AD642B7E7D937664 /* ObserverBase.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ObserverBase.swift; path = RxSwift/Observers/ObserverBase.swift; sourceTree = ""; }; + 72AAAA3FE5DDA94BC0636A15F9F4F7EF /* Just.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Just.swift; path = RxSwift/Observables/Implementations/Just.swift; sourceTree = ""; }; + 72DC2CBE50494D6723773E2C3E89C3C1 /* ScheduledItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ScheduledItem.swift; path = RxSwift/Schedulers/Internal/ScheduledItem.swift; sourceTree = ""; }; + 72F5796E9AA6A65EA2149A206ADE4289 /* TakeWhile.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TakeWhile.swift; path = RxSwift/Observables/Implementations/TakeWhile.swift; sourceTree = ""; }; + 75D5E40EFDE70F2D69310639B473B817 /* TakeLast.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TakeLast.swift; path = RxSwift/Observables/Implementations/TakeLast.swift; sourceTree = ""; }; + 76485D1ACD1F13E0E68638CA3D9E175C /* ConnectableObservable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConnectableObservable.swift; path = RxSwift/Observables/Implementations/ConnectableObservable.swift; sourceTree = ""; }; + 7678CC14BE55592C2250C4C122EADEF3 /* RetryWhen.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RetryWhen.swift; path = RxSwift/Observables/Implementations/RetryWhen.swift; sourceTree = ""; }; + 7AD0626709B8BF22F5F6B42379D4C1EB /* Producer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Producer.swift; path = RxSwift/Observables/Implementations/Producer.swift; sourceTree = ""; }; + 7C8E63660D346FD8ED2A97242E74EA09 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7D488959FBBFCF0351F42E7D150C1942 /* Multicast.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Multicast.swift; path = RxSwift/Observables/Implementations/Multicast.swift; sourceTree = ""; }; + 7D9E0FD7CAAFFDA1BCA65C0DE4AB27B4 /* Observable+Binding.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Binding.swift"; path = "RxSwift/Observables/Observable+Binding.swift"; sourceTree = ""; }; + 7E056012594D80C40AF86E23AAD413A0 /* ImmediateScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ImmediateScheduler.swift; path = RxSwift/Schedulers/ImmediateScheduler.swift; sourceTree = ""; }; + 7E2F61612759130FD3873E3FBE0E2CC0 /* WithLatestFrom.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = WithLatestFrom.swift; path = RxSwift/Observables/Implementations/WithLatestFrom.swift; sourceTree = ""; }; + 8033FB9B41A3E314A0CC6C50015B835D /* Observable+Single.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Single.swift"; path = "RxSwift/Observables/Observable+Single.swift"; sourceTree = ""; }; + 81BA6471D19E57603D3AF0A0A49939B9 /* Window.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Window.swift; path = RxSwift/Observables/Implementations/Window.swift; sourceTree = ""; }; + 84665902C00313BF6D709D279E597AF9 /* PublishSubject.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PublishSubject.swift; path = RxSwift/Subjects/PublishSubject.swift; sourceTree = ""; }; + 849FECBC6CC67F2B6800F982927E3A9E /* Pods-SwaggerClientTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SwaggerClientTests.release.xcconfig"; sourceTree = ""; }; + 84A09D760BA2EA13D5BE269086BAD34C /* RxSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8611EB072B953093474C20B1B11F76CC /* RxSwift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = RxSwift.modulemap; sourceTree = ""; }; + 86B1DDCB9E27DF43C2C35D9E7B2E84DA /* Pods-SwaggerClient.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SwaggerClient.release.xcconfig"; sourceTree = ""; }; + 86C5082D39612A1F1FD675C33932AEC9 /* Request.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Request.swift; path = Source/Request.swift; sourceTree = ""; }; + 88A83A4C472835F0F6BDC178F2EF51A6 /* BehaviorSubject.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BehaviorSubject.swift; path = RxSwift/Subjects/BehaviorSubject.swift; sourceTree = ""; }; + 8A95956A18890D406F52B50CE636C417 /* ConcurrentDispatchQueueScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConcurrentDispatchQueueScheduler.swift; path = RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift; sourceTree = ""; }; + 8CA8E405CD1F1D51078388FDE3498848 /* Observable+Concurrency.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Concurrency.swift"; path = "RxSwift/Observables/Observable+Concurrency.swift"; sourceTree = ""; }; + 8E78A6B0E3334E11FE5615FE4CC506E8 /* Upload.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Upload.swift; path = Source/Upload.swift; sourceTree = ""; }; + 8EFB1B59D84F8B11F82B8DF1A2150846 /* Observable+Time.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Time.swift"; path = "RxSwift/Observables/Observable+Time.swift"; sourceTree = ""; }; + 8F0266C5AE0B23A436291F6647902086 /* Models.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; + 8F329D6196F35CB573BEBA0D2379035F /* SkipWhile.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SkipWhile.swift; path = RxSwift/Observables/Implementations/SkipWhile.swift; sourceTree = ""; }; + 9144FDC8DC22962DE80692307106EF74 /* Merge.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Merge.swift; path = RxSwift/Observables/Implementations/Merge.swift; sourceTree = ""; }; + 914B1C0C6B1C0BB87F3EB1E7F1060425 /* AnonymousObserver.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnonymousObserver.swift; path = RxSwift/Observers/AnonymousObserver.swift; sourceTree = ""; }; + 922907F82CF71DEBAE0585263AEF4518 /* ObserveOnSerialDispatchQueue.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ObserveOnSerialDispatchQueue.swift; path = RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift; sourceTree = ""; }; + 92734297B64DFE0EB0EDE1EA821163DB /* AlamofireImplementations.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AlamofireImplementations.swift; sourceTree = ""; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 93ECB6F232D07DFDE4F782C41FFD85FE /* Using.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Using.swift; path = RxSwift/Observables/Implementations/Using.swift; sourceTree = ""; }; + 9610BA4403551C05999CF892D495F516 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + 969C2AF48F4307163B301A92E78AFCF2 /* Pods-SwaggerClientTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SwaggerClientTests.debug.xcconfig"; sourceTree = ""; }; + 97C78DB1DE41EDF5A70DBAB37DA9904B /* Queue.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Queue.swift; path = RxSwift/DataStructures/Queue.swift; sourceTree = ""; }; + 983586C602A5C7D5B4FD91982F3711D0 /* DisposeBase.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DisposeBase.swift; path = RxSwift/Disposables/DisposeBase.swift; sourceTree = ""; }; + 99A31BA1E446FA35628A7DED964EF04F /* Skip.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Skip.swift; path = RxSwift/Observables/Implementations/Skip.swift; sourceTree = ""; }; + 9B0F57917A904327F2D141C7E2E8623F /* Observable+Multiple.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Multiple.swift"; path = "RxSwift/Observables/Observable+Multiple.swift"; sourceTree = ""; }; + 9B3FF9A09AF9E0D7751789D55FDDDCA2 /* CompositeDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CompositeDisposable.swift; path = RxSwift/Disposables/CompositeDisposable.swift; sourceTree = ""; }; + 9B5BDA8EA0E40E1A09E34DD0FF21BAD9 /* Filter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Filter.swift; path = RxSwift/Observables/Implementations/Filter.swift; sourceTree = ""; }; + 9D510BAAE86BD9AA107EBEE6C81330BB /* RxSwift-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "RxSwift-prefix.pch"; sourceTree = ""; }; + 9E9064EE8CEF10A602EFC90A26D1DC39 /* HistoricalSchedulerTimeConverter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = HistoricalSchedulerTimeConverter.swift; path = RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift; sourceTree = ""; }; + 9F681D2C508D1BA8F62893120D9343A4 /* PetstoreClient-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "PetstoreClient-umbrella.h"; sourceTree = ""; }; + A03FE8BD209B0504BE052CBD44BD277A /* Timer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Timer.swift; path = RxSwift/Observables/Implementations/Timer.swift; sourceTree = ""; }; + A272A3BAB4634A80251132C7FB980D8A /* Observable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Observable.swift; path = RxSwift/Observable.swift; sourceTree = ""; }; + A2CEC38D6994E89F7BD53BCE73AB7F89 /* AnonymousObservable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnonymousObservable.swift; path = RxSwift/Observables/Implementations/AnonymousObservable.swift; sourceTree = ""; }; + A371B67E1A1BC9D198E470D4B54FEE87 /* ObservableType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ObservableType.swift; path = RxSwift/ObservableType.swift; sourceTree = ""; }; + A38E6FD240ADA8F1BCE82B9426E6EF8F /* OperationQueueScheduler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = OperationQueueScheduler.swift; path = RxSwift/Schedulers/OperationQueueScheduler.swift; sourceTree = ""; }; + A4D4B50A66CA7EB372C9BCE21D117CEC /* SynchronizedSubscribeType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SynchronizedSubscribeType.swift; path = RxSwift/Concurrency/SynchronizedSubscribeType.swift; sourceTree = ""; }; + A56FED751BA06FF779D945B5D478065C /* ResponseSerialization.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ResponseSerialization.swift; path = Source/ResponseSerialization.swift; sourceTree = ""; }; + A5D1009B6CD1857E5025278FDFACF63C /* Do.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Do.swift; path = RxSwift/Observables/Implementations/Do.swift; sourceTree = ""; }; + A6E7F9EA5FCA01B648E37743D97B9D57 /* Deferred.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Deferred.swift; path = RxSwift/Observables/Implementations/Deferred.swift; sourceTree = ""; }; + A7D21C15998D42252EF80A55181C7D18 /* MultipartFormData.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MultipartFormData.swift; path = Source/MultipartFormData.swift; sourceTree = ""; }; + A98250195E2C07F9A7DB5E4BB333ACE9 /* Rx.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Rx.swift; path = RxSwift/Rx.swift; sourceTree = ""; }; + AA9C5856BEAE5090A7D1EB450A10C04F /* Alamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Alamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + ACF6B90536554BCC5A32E2DC7731D9FD /* Zip+arity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Zip+arity.swift"; path = "RxSwift/Observables/Implementations/Zip+arity.swift"; sourceTree = ""; }; + AD65E96303458AB841FAD17494E26AAD /* Disposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Disposable.swift; path = RxSwift/Disposable.swift; sourceTree = ""; }; + AEC4CF736B6956856103762EC255EEA2 /* AsyncLock.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AsyncLock.swift; path = RxSwift/Concurrency/AsyncLock.swift; sourceTree = ""; }; + B2B14E7D38A4727796ABDFA4079BD210 /* Repeat.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Repeat.swift; path = RxSwift/Observables/Implementations/Repeat.swift; sourceTree = ""; }; + B3A144887C8B13FD888B76AB096B0CA1 /* PetstoreClient-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "PetstoreClient-prefix.pch"; sourceTree = ""; }; + B4D9A8D2D89ACE5DBF27150F182DE34E /* CombineLatest+arity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "CombineLatest+arity.swift"; path = "RxSwift/Observables/Implementations/CombineLatest+arity.swift"; sourceTree = ""; }; + B7B5D80C0F71324ED10DBE73D28402DB /* SynchronizedOnType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SynchronizedOnType.swift; path = RxSwift/Concurrency/SynchronizedOnType.swift; sourceTree = ""; }; + B7FA9B23245D415690FB894178BBF20F /* SerialDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SerialDisposable.swift; path = RxSwift/Disposables/SerialDisposable.swift; sourceTree = ""; }; + BA1AAD8792DE618CDBBF78CA8E642111 /* SingleAsync.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SingleAsync.swift; path = RxSwift/Observables/Implementations/SingleAsync.swift; sourceTree = ""; }; + BABA671A27CF29C8AA31D5C66D34CBA3 /* Result.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Result.swift; path = Source/Result.swift; sourceTree = ""; }; + BC813A2800E1E5B7D9C9A9A095B0D51E /* StableCompositeDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = StableCompositeDisposable.swift; path = RxSwift/Disposables/StableCompositeDisposable.swift; sourceTree = ""; }; + BCF2D4DFF08D2A18E8C8FE4C4B4633FB /* Pods-SwaggerClient-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SwaggerClient-frameworks.sh"; sourceTree = ""; }; + BDA5F3724FE84CF94299E36A8DF89017 /* RxSwift-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "RxSwift-umbrella.h"; sourceTree = ""; }; + BE69C5E6F8BF09D066522463F69EB8A6 /* Empty.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Empty.swift; path = RxSwift/Observables/Implementations/Empty.swift; sourceTree = ""; }; + C239D292236A2F59F0F6F5F1DB31795E /* SynchronizedDisposeType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SynchronizedDisposeType.swift; path = RxSwift/Concurrency/SynchronizedDisposeType.swift; sourceTree = ""; }; + C4B474BD9070828C0F786071EEF46CD0 /* Pods_SwaggerClientTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwaggerClientTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D02FE9C7BBEB944DACB0B057F631B40C /* TailRecursiveSink.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TailRecursiveSink.swift; path = RxSwift/Observers/TailRecursiveSink.swift; sourceTree = ""; }; + D072A90162699810B672895226A27C43 /* ObservableConvertibleType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ObservableConvertibleType.swift; path = RxSwift/ObservableConvertibleType.swift; sourceTree = ""; }; + D0A71420D33D17B1C771C1CC7ADD8258 /* RxSwift.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = RxSwift.xcconfig; sourceTree = ""; }; + D2841E5E2183846280B97F6E660DA26C /* Pods-SwaggerClient-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SwaggerClient-resources.sh"; sourceTree = ""; }; + D2BAD338E56EF3CAA6E54490FE0C5DF9 /* APIHelper.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = APIHelper.swift; sourceTree = ""; }; + D4DF0604EDC1460935E6E445A47023A4 /* Category.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = ""; }; + D5438FA602118A769102A572D66E5EDD /* Reduce.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Reduce.swift; path = RxSwift/Observables/Implementations/Reduce.swift; sourceTree = ""; }; + D69A080DF8671D7B4CEB7E706EF4667F /* SkipUntil.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SkipUntil.swift; path = RxSwift/Observables/Implementations/SkipUntil.swift; sourceTree = ""; }; + D8072E1108951F272C003553FC8926C7 /* APIs.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = APIs.swift; sourceTree = ""; }; + DABFA04B3B312B12F4703582A14EEE51 /* ElementAt.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ElementAt.swift; path = RxSwift/Observables/Implementations/ElementAt.swift; sourceTree = ""; }; + DADAB10704E49D6B9E18F59F995BB88F /* PetstoreClient.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = PetstoreClient.xcconfig; sourceTree = ""; }; + DB5D61F564F3FF7A53825B0EF70E98B4 /* Observable+Extensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Extensions.swift"; path = "RxSwift/Observable+Extensions.swift"; sourceTree = ""; }; + DBC29FB0F89F4B2B863A122A41D07007 /* Sample.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sample.swift; path = RxSwift/Observables/Implementations/Sample.swift; sourceTree = ""; }; + DE164497A94DD3215ED4D1AE0D4703B1 /* Pods-SwaggerClient.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-SwaggerClient.modulemap"; sourceTree = ""; }; + DE3076AFBC266A6E88C8171467D6C5A5 /* SingleAssignmentDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SingleAssignmentDisposable.swift; path = RxSwift/Disposables/SingleAssignmentDisposable.swift; sourceTree = ""; }; + DFB51688711C8369A2961F69330DCC99 /* ShareReplay1.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ShareReplay1.swift; path = RxSwift/Observables/Implementations/ShareReplay1.swift; sourceTree = ""; }; + E1E4BCB344D3C100253B24B79421F00A /* Pods-SwaggerClient-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-SwaggerClient-acknowledgements.plist"; sourceTree = ""; }; + E3D1141B63DF38660CD6F3AC588A782B /* PetstoreClient.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = PetstoreClient.modulemap; sourceTree = ""; }; + E4E6F4A58FE7868CA2177D3AC79AD2FA /* Pods-SwaggerClientTests-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SwaggerClientTests-resources.sh"; sourceTree = ""; }; + E64D15D1795EA999578C393A507A882F /* SubjectType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SubjectType.swift; path = RxSwift/Subjects/SubjectType.swift; sourceTree = ""; }; + E8B5CE5592D5B0BD393B7D599B053BFA /* Concat.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Concat.swift; path = RxSwift/Observables/Implementations/Concat.swift; sourceTree = ""; }; + E97A3908B642D476F00987B50894F4C9 /* InvocableType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = InvocableType.swift; path = RxSwift/Schedulers/Internal/InvocableType.swift; sourceTree = ""; }; + E9CBBB398E7A62950FA8BC091CBE0359 /* PetstoreClient.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PetstoreClient.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + EBED49C45F40708D9355E7D2CFFE4602 /* Observable+Creation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Observable+Creation.swift"; path = "RxSwift/Observables/Observable+Creation.swift"; sourceTree = ""; }; + EC88FCE0410EAE3C16E64A8A8108D142 /* SchedulerType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SchedulerType.swift; path = RxSwift/SchedulerType.swift; sourceTree = ""; }; + ED580EA15AD5B2541B7EBE483BEE21EE /* LockOwnerType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LockOwnerType.swift; path = RxSwift/Concurrency/LockOwnerType.swift; sourceTree = ""; }; + EDC79FC8F9A849970B716868E7F51D2C /* Timeout.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Timeout.swift; path = RxSwift/Observables/Implementations/Timeout.swift; sourceTree = ""; }; + F0B81B0D0B0B21977235410AAD4CFECB /* BooleanDisposable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BooleanDisposable.swift; path = RxSwift/Disposables/BooleanDisposable.swift; sourceTree = ""; }; + F0D4E00A8974E74325E9E53D456F9AD4 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F17B79123C6F61E5E5DBBF14710E6012 /* StartWith.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = StartWith.swift; path = RxSwift/Observables/Implementations/StartWith.swift; sourceTree = ""; }; + F22FE315AC1C04A8749BD18281EE9028 /* Pods-SwaggerClientTests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-SwaggerClientTests-umbrella.h"; sourceTree = ""; }; + F250B545A022C0627A401DF08D2B7339 /* Errors.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Errors.swift; path = RxSwift/Errors.swift; sourceTree = ""; }; + F31DEFD11FF950B319F5E3A97C41178F /* Validation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Validation.swift; path = Source/Validation.swift; sourceTree = ""; }; + FB170EFD14935F121CDE3211DB4C5CA3 /* Pods-SwaggerClientTests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-SwaggerClientTests-acknowledgements.markdown"; sourceTree = ""; }; + FC3B7613AC16E246F73123670BAED3F5 /* Platform.Darwin.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Platform.Darwin.swift; path = RxSwift/Platform/Platform.Darwin.swift; sourceTree = ""; }; + FCF668BEB868B23FA177F79EA8B5D5CF /* Never.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Never.swift; path = RxSwift/Observables/Implementations/Never.swift; sourceTree = ""; }; + FD709EBAF5345AC238B7849DE5BCB273 /* Scan.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Scan.swift; path = RxSwift/Observables/Implementations/Scan.swift; sourceTree = ""; }; + FF0E5B19D36827BBE8598B8ACC2EC189 /* AnyObserver.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnyObserver.swift; path = RxSwift/AnyObserver.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 05BA91ABD8AC918A49A9D7E0E3722C70 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 14DD51004DF8C27A7D0491AEFEC5F464 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 76130794E62D45206C62CE83429B6CF2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9FDB94097AD437CDE44A507037AE4010 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A5AE1D340C4A0691EC28EEA8241C9FCD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0BD8B4E55E72312366130E97A1204CD8 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CB2482011FA929C2BCC3E41A1B6E02E1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 110E6B43666A729745E9980F080944C4 /* Alamofire.framework in Frameworks */, + 393372CC0F931D0D192179C4B16DF65E /* Foundation.framework in Frameworks */, + 58344FE826FA6ED012A3450ACB0BF93D /* RxSwift.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FE8FC779CF4B0CFCC594E81C0FF86C7E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F206C370F63155D3468E0C188498C5DC /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1322FED69118C64DAD026CAF7F4C38C6 /* Models */ = { + isa = PBXGroup; + children = ( + D4DF0604EDC1460935E6E445A47023A4 /* Category.swift */, + 0A545673F09F49CDD60A13B4B0AF1020 /* Order.swift */, + 284B3DE9B793FCC633E971DB1798AFAF /* Pet.swift */, + 211F73A46D90346F7FC6D0D29640EE4F /* Tag.swift */, + 5B248364ABF60ACD7DB31A17DCFDFD0C /* User.swift */, + ); + path = Models; + sourceTree = ""; + }; + 22F52349E1BE90FC6E064DAAC9EA9612 /* Development Pods */ = { + isa = PBXGroup; + children = ( + E9F8459055B900A58FB97600A53E5D1C /* PetstoreClient */, + ); + name = "Development Pods"; + sourceTree = ""; + }; + 530337216701C70B5DE636BF1B3DB0C5 /* RxSwift */ = { + isa = PBXGroup; + children = ( + 47C4BE1760C078A0188C4A66807F2C29 /* AddRef.swift */, + 1EF617EC4E8045D4B384E618B83B2F6F /* Amb.swift */, + 0DE7F5B430FDC646F58271F85B672788 /* AnonymousDisposable.swift */, + 257C3EC4A4AA8458E5B4BE717014B450 /* AnonymousInvocable.swift */, + A2CEC38D6994E89F7BD53BCE73AB7F89 /* AnonymousObservable.swift */, + 914B1C0C6B1C0BB87F3EB1E7F1060425 /* AnonymousObserver.swift */, + FF0E5B19D36827BBE8598B8ACC2EC189 /* AnyObserver.swift */, + AEC4CF736B6956856103762EC255EEA2 /* AsyncLock.swift */, + 2529676E540C411C575AB0CD27CCEF57 /* Bag.swift */, + 88A83A4C472835F0F6BDC178F2EF51A6 /* BehaviorSubject.swift */, + 5124609C66364357A0450CE5890AB140 /* BinaryDisposable.swift */, + F0B81B0D0B0B21977235410AAD4CFECB /* BooleanDisposable.swift */, + 31889B2EAD6E61A01714C04A70E0DF6F /* Buffer.swift */, + 09414F47E12D9B51147335D651E0D536 /* Cancelable.swift */, + 2FE2208C0198E8412BDD034563E2B1A7 /* Catch.swift */, + 516C671101243A9465AF2A689641D598 /* CombineLatest.swift */, + B4D9A8D2D89ACE5DBF27150F182DE34E /* CombineLatest+arity.swift */, + 5CF9673331C58F7D9396CDEC9CE940A9 /* CombineLatest+CollectionType.swift */, + 9B3FF9A09AF9E0D7751789D55FDDDCA2 /* CompositeDisposable.swift */, + E8B5CE5592D5B0BD393B7D599B053BFA /* Concat.swift */, + 8A95956A18890D406F52B50CE636C417 /* ConcurrentDispatchQueueScheduler.swift */, + 6DBCE4DC8C3C8888BE09F0BC0EFCB3EA /* ConcurrentMainScheduler.swift */, + 76485D1ACD1F13E0E68638CA3D9E175C /* ConnectableObservable.swift */, + 39E5209D93CDC3C851C2F4454601FF04 /* ConnectableObservableType.swift */, + 51171A514198E93AF767FD06958653FA /* CurrentThreadScheduler.swift */, + 0E21F1428A7A2D51A86015D1E4531D87 /* Debug.swift */, + A6E7F9EA5FCA01B648E37743D97B9D57 /* Deferred.swift */, + 3C0CED57E33C91E281A79EE0195FCAC2 /* DelaySubscription.swift */, + 609B0D6771C363A74DDB9B2FFF4A9BAC /* DispatchQueueSchedulerQOS.swift */, + AD65E96303458AB841FAD17494E26AAD /* Disposable.swift */, + 0B72DF27B30B51C1091F485174052F1D /* DisposeBag.swift */, + 983586C602A5C7D5B4FD91982F3711D0 /* DisposeBase.swift */, + 0567A0BF989778CA9FF9575D62613B8E /* DistinctUntilChanged.swift */, + A5D1009B6CD1857E5025278FDFACF63C /* Do.swift */, + DABFA04B3B312B12F4703582A14EEE51 /* ElementAt.swift */, + BE69C5E6F8BF09D066522463F69EB8A6 /* Empty.swift */, + 14EB178F75EE27270C8F21ADA50D9C41 /* Error.swift */, + F250B545A022C0627A401DF08D2B7339 /* Errors.swift */, + 0CAB8BECDF386291E0D615DE5171B181 /* Event.swift */, + 9B5BDA8EA0E40E1A09E34DD0FF21BAD9 /* Filter.swift */, + 48F68420AE4974226AE95592AB01F5C3 /* Generate.swift */, + 52611EC9CCB565A24C2C007F5A2CB6C3 /* HistoricalScheduler.swift */, + 9E9064EE8CEF10A602EFC90A26D1DC39 /* HistoricalSchedulerTimeConverter.swift */, + 7E056012594D80C40AF86E23AAD413A0 /* ImmediateScheduler.swift */, + 09BD8ACFD826D9E6CCCAAB5DDB0132BF /* ImmediateSchedulerType.swift */, + 34DB4ED4653A16819871618F69B3182D /* InfiniteSequence.swift */, + 06C46F9E4863BA39300A28EEBB2FED44 /* InvocableScheduledItem.swift */, + E97A3908B642D476F00987B50894F4C9 /* InvocableType.swift */, + 72AAAA3FE5DDA94BC0636A15F9F4F7EF /* Just.swift */, + 1974F6C69B156C91AE3DD56FAC5A3808 /* Lock.swift */, + ED580EA15AD5B2541B7EBE483BEE21EE /* LockOwnerType.swift */, + 2B77AAD2C4150B81817D5833C2B78B7C /* MainScheduler.swift */, + 4A3658B178A16F05FFD28C46A18EF8E8 /* Map.swift */, + 9144FDC8DC22962DE80692307106EF74 /* Merge.swift */, + 7D488959FBBFCF0351F42E7D150C1942 /* Multicast.swift */, + 5C6944EFCED2081E91C44EEF357D1EA3 /* NAryDisposable.swift */, + FCF668BEB868B23FA177F79EA8B5D5CF /* Never.swift */, + 6156CD5049D33CC68DF29760B398B408 /* NopDisposable.swift */, + A272A3BAB4634A80251132C7FB980D8A /* Observable.swift */, + 3C2489BF8D3C006E1A6E9FA8E1275FC1 /* Observable+Aggregate.swift */, + 7D9E0FD7CAAFFDA1BCA65C0DE4AB27B4 /* Observable+Binding.swift */, + 8CA8E405CD1F1D51078388FDE3498848 /* Observable+Concurrency.swift */, + EBED49C45F40708D9355E7D2CFFE4602 /* Observable+Creation.swift */, + 051BE7827FDD01F32E6822EC2DE1CE1C /* Observable+Debug.swift */, + DB5D61F564F3FF7A53825B0EF70E98B4 /* Observable+Extensions.swift */, + 9B0F57917A904327F2D141C7E2E8623F /* Observable+Multiple.swift */, + 8033FB9B41A3E314A0CC6C50015B835D /* Observable+Single.swift */, + 372C2E8DD6FEE19981359253F88A881F /* Observable+StandardSequenceOperators.swift */, + 8EFB1B59D84F8B11F82B8DF1A2150846 /* Observable+Time.swift */, + D072A90162699810B672895226A27C43 /* ObservableConvertibleType.swift */, + A371B67E1A1BC9D198E470D4B54FEE87 /* ObservableType.swift */, + 315D8F39A79B562AA2268250BED93150 /* ObserveOn.swift */, + 922907F82CF71DEBAE0585263AEF4518 /* ObserveOnSerialDispatchQueue.swift */, + 6F1954F056E7EC88AD642B7E7D937664 /* ObserverBase.swift */, + 0B9FE8B611FD713A03D461C686322726 /* ObserverType.swift */, + A38E6FD240ADA8F1BCE82B9426E6EF8F /* OperationQueueScheduler.swift */, + FC3B7613AC16E246F73123670BAED3F5 /* Platform.Darwin.swift */, + 0668CCF084235C10B605A3F640FB98D8 /* Platform.Linux.swift */, + 1F9095E4F9CC417FB1536F011BCAFACA /* PriorityQueue.swift */, + 7AD0626709B8BF22F5F6B42379D4C1EB /* Producer.swift */, + 84665902C00313BF6D709D279E597AF9 /* PublishSubject.swift */, + 97C78DB1DE41EDF5A70DBAB37DA9904B /* Queue.swift */, + 509773F27764F1FF30E06C5F91E1FF0D /* Range.swift */, + 5DEE36ACBCF70F5F1553D055175D1622 /* RecursiveScheduler.swift */, + D5438FA602118A769102A572D66E5EDD /* Reduce.swift */, + 5ADB3F22CC2D987B4C7E76A7B502DE81 /* RefCount.swift */, + 62EC50E209B29C93EAECE01AD46DBAE7 /* RefCountDisposable.swift */, + B2B14E7D38A4727796ABDFA4079BD210 /* Repeat.swift */, + 19C0FF31F56DFA84FE0CDF777CF56845 /* ReplaySubject.swift */, + 7678CC14BE55592C2250C4C122EADEF3 /* RetryWhen.swift */, + A98250195E2C07F9A7DB5E4BB333ACE9 /* Rx.swift */, + 1F0C939A9E2A83A661C6EA3D4EE8DC54 /* RxMutableBox.swift */, + DBC29FB0F89F4B2B863A122A41D07007 /* Sample.swift */, + FD709EBAF5345AC238B7849DE5BCB273 /* Scan.swift */, + 17881314399342A30A86EF8655AFD35C /* ScheduledDisposable.swift */, + 72DC2CBE50494D6723773E2C3E89C3C1 /* ScheduledItem.swift */, + 07017B36556829104C6CC52B3E0DFDA4 /* ScheduledItemType.swift */, + 10D1C22E4BBFB16E5C966FF77E92F296 /* SchedulerServices+Emulation.swift */, + EC88FCE0410EAE3C16E64A8A8108D142 /* SchedulerType.swift */, + 075BA1FDBF8D0B4B1D383DF8FD3BE509 /* Sequence.swift */, + 1BE009E15582DF43271F4102E7EC30F5 /* SerialDispatchQueueScheduler.swift */, + B7FA9B23245D415690FB894178BBF20F /* SerialDisposable.swift */, + DFB51688711C8369A2961F69330DCC99 /* ShareReplay1.swift */, + 35A3C82BD63330195DE669D3836B7E41 /* ShareReplay1WhileConnected.swift */, + DE3076AFBC266A6E88C8171467D6C5A5 /* SingleAssignmentDisposable.swift */, + BA1AAD8792DE618CDBBF78CA8E642111 /* SingleAsync.swift */, + 37E5E51602A7EC243D3CC5A8B0FBC7E3 /* Sink.swift */, + 99A31BA1E446FA35628A7DED964EF04F /* Skip.swift */, + D69A080DF8671D7B4CEB7E706EF4667F /* SkipUntil.swift */, + 8F329D6196F35CB573BEBA0D2379035F /* SkipWhile.swift */, + BC813A2800E1E5B7D9C9A9A095B0D51E /* StableCompositeDisposable.swift */, + F17B79123C6F61E5E5DBBF14710E6012 /* StartWith.swift */, + 64FED6C504DC2686A1BF8615B1D0213F /* String+Rx.swift */, + E64D15D1795EA999578C393A507A882F /* SubjectType.swift */, + 46BB6E8D195D7B7711B8B0B50213D36B /* SubscribeOn.swift */, + 3F52905F2DED9823E28E154C2CD365A0 /* SubscriptionDisposable.swift */, + 636788473300310D67C31CCE1A571AC4 /* Switch.swift */, + C239D292236A2F59F0F6F5F1DB31795E /* SynchronizedDisposeType.swift */, + B7B5D80C0F71324ED10DBE73D28402DB /* SynchronizedOnType.swift */, + A4D4B50A66CA7EB372C9BCE21D117CEC /* SynchronizedSubscribeType.swift */, + 292B4E8722DE17F6767ABED8D62A4C9E /* SynchronizedUnsubscribeType.swift */, + D02FE9C7BBEB944DACB0B057F631B40C /* TailRecursiveSink.swift */, + 4CAF565A8B834CB6FD86DDFF010D4E4B /* Take.swift */, + 75D5E40EFDE70F2D69310639B473B817 /* TakeLast.swift */, + 2AC78F9679615E991FC6F18D85FCF21C /* TakeUntil.swift */, + 72F5796E9AA6A65EA2149A206ADE4289 /* TakeWhile.swift */, + 31D3B68FA022AAECF54F3CBFB928B666 /* Throttle.swift */, + EDC79FC8F9A849970B716868E7F51D2C /* Timeout.swift */, + A03FE8BD209B0504BE052CBD44BD277A /* Timer.swift */, + 17534D83D8298C9D739F4506816D218F /* ToArray.swift */, + 93ECB6F232D07DFDE4F782C41FFD85FE /* Using.swift */, + 101E84FB1E5F4A753DAF7518FB9BF0A7 /* Variable.swift */, + 3B5E5E7372652C9D351B65002A966365 /* VirtualTimeConverterType.swift */, + 25C6BCDF18A3A22B7FEDE36B0A580C0E /* VirtualTimeScheduler.swift */, + 81BA6471D19E57603D3AF0A0A49939B9 /* Window.swift */, + 7E2F61612759130FD3873E3FBE0E2CC0 /* WithLatestFrom.swift */, + 321E8BEC99166D3ED7E88CDBACBE407A /* Zip.swift */, + ACF6B90536554BCC5A32E2DC7731D9FD /* Zip+arity.swift */, + 6204091F721976FA7C97D74AC93B9637 /* Zip+CollectionType.swift */, + A45143F0CEA87E55D6F93C6DF7BD1446 /* Support Files */, + ); + path = RxSwift; + sourceTree = ""; + }; + 5E2543AE40E062857224EB1DCE80B9E3 /* iOS */ = { + isa = PBXGroup; + children = ( + 9610BA4403551C05999CF892D495F516 /* Foundation.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 69750F9014CEFA9B29584C65B2491D2E /* Frameworks */ = { + isa = PBXGroup; + children = ( + AA9C5856BEAE5090A7D1EB450A10C04F /* Alamofire.framework */, + 19296A8C5E948345E5744A748B1CC720 /* RxSwift.framework */, + 5E2543AE40E062857224EB1DCE80B9E3 /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 771D190F914310F450FF47756BC0DD0F /* Support Files */ = { + isa = PBXGroup; + children = ( + 6EBAF7A3F8D6D888BC91244485ECD2AA /* Alamofire.modulemap */, + 66429A42B7499250307412ECB7AF627E /* Alamofire.xcconfig */, + 14BA42A836361E4416D38DECBEFE25C0 /* Alamofire-dummy.m */, + 1C7A9744D1553CE8C58822392FE251D8 /* Alamofire-prefix.pch */, + 3341D7B714515136B34354D7D32202DB /* Alamofire-umbrella.h */, + 14F8F74E862AC5CA39F8E5132F1C00B9 /* Info.plist */, + ); + name = "Support Files"; + path = "../Target Support Files/Alamofire"; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, + 22F52349E1BE90FC6E064DAAC9EA9612 /* Development Pods */, + 69750F9014CEFA9B29584C65B2491D2E /* Frameworks */, + 920125D5A6247D4AF2FAB58D0148CAD8 /* Pods */, + C1398CE2D296EEBAA178C160CA6E6AD6 /* Products */, + C1A60D10CED0E61146591438999C7502 /* Targets Support Files */, + ); + sourceTree = ""; + }; + 88CE2B3F08C34DDB098AD8A5DCC1DF1E /* Pods-SwaggerClient */ = { + isa = PBXGroup; + children = ( + 7C8E63660D346FD8ED2A97242E74EA09 /* Info.plist */, + DE164497A94DD3215ED4D1AE0D4703B1 /* Pods-SwaggerClient.modulemap */, + 2FF17440CCD2E1A69791A4AA23325AD5 /* Pods-SwaggerClient-acknowledgements.markdown */, + E1E4BCB344D3C100253B24B79421F00A /* Pods-SwaggerClient-acknowledgements.plist */, + 291054DAA3207AFC1F6B3D7AD6C25E5C /* Pods-SwaggerClient-dummy.m */, + BCF2D4DFF08D2A18E8C8FE4C4B4633FB /* Pods-SwaggerClient-frameworks.sh */, + D2841E5E2183846280B97F6E660DA26C /* Pods-SwaggerClient-resources.sh */, + 3EEBA91980AEC8774CF7EC08035B089A /* Pods-SwaggerClient-umbrella.h */, + 549C6527D10094289B101749047807C5 /* Pods-SwaggerClient.debug.xcconfig */, + 86B1DDCB9E27DF43C2C35D9E7B2E84DA /* Pods-SwaggerClient.release.xcconfig */, + ); + name = "Pods-SwaggerClient"; + path = "Target Support Files/Pods-SwaggerClient"; + sourceTree = ""; + }; + 8F6D133867EE63820DFB7E83F4C51252 /* Support Files */ = { + isa = PBXGroup; + children = ( + F0D4E00A8974E74325E9E53D456F9AD4 /* Info.plist */, + E3D1141B63DF38660CD6F3AC588A782B /* PetstoreClient.modulemap */, + DADAB10704E49D6B9E18F59F995BB88F /* PetstoreClient.xcconfig */, + 46A8E0328DC896E0893B565FE8742167 /* PetstoreClient-dummy.m */, + B3A144887C8B13FD888B76AB096B0CA1 /* PetstoreClient-prefix.pch */, + 9F681D2C508D1BA8F62893120D9343A4 /* PetstoreClient-umbrella.h */, + ); + name = "Support Files"; + path = "SwaggerClientTests/Pods/Target Support Files/PetstoreClient"; + sourceTree = ""; + }; + 920125D5A6247D4AF2FAB58D0148CAD8 /* Pods */ = { + isa = PBXGroup; + children = ( + E4310C54179D230C8E716E0BF52E4F90 /* Alamofire */, + 530337216701C70B5DE636BF1B3DB0C5 /* RxSwift */, + ); + name = Pods; + sourceTree = ""; + }; + A45143F0CEA87E55D6F93C6DF7BD1446 /* Support Files */ = { + isa = PBXGroup; + children = ( + 25D1E84FDF56D9C05CACE85F684D9965 /* Info.plist */, + 8611EB072B953093474C20B1B11F76CC /* RxSwift.modulemap */, + D0A71420D33D17B1C771C1CC7ADD8258 /* RxSwift.xcconfig */, + 24D7DE1FFF6AE5D438E4DAC777A8B8F2 /* RxSwift-dummy.m */, + 9D510BAAE86BD9AA107EBEE6C81330BB /* RxSwift-prefix.pch */, + BDA5F3724FE84CF94299E36A8DF89017 /* RxSwift-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/RxSwift"; + sourceTree = ""; + }; + AD94092456F8ABCB18F74CAC75AD85DE /* Classes */ = { + isa = PBXGroup; + children = ( + F64549CFCC17C7AC6479508BE180B18D /* Swaggers */, + ); + path = Classes; + sourceTree = ""; + }; + C1398CE2D296EEBAA178C160CA6E6AD6 /* Products */ = { + isa = PBXGroup; + children = ( + 5B598E168B47485DC60F9DBBCBEEF5BB /* Alamofire.framework */, + E9CBBB398E7A62950FA8BC091CBE0359 /* PetstoreClient.framework */, + 057FC3E5DE19EA8F4DD600557D771032 /* Pods_SwaggerClient.framework */, + C4B474BD9070828C0F786071EEF46CD0 /* Pods_SwaggerClientTests.framework */, + 84A09D760BA2EA13D5BE269086BAD34C /* RxSwift.framework */, + ); + name = Products; + sourceTree = ""; + }; + C1A60D10CED0E61146591438999C7502 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + 88CE2B3F08C34DDB098AD8A5DCC1DF1E /* Pods-SwaggerClient */, + D6D0CD30E3EAF2ED10AE0CBC07506C5A /* Pods-SwaggerClientTests */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + D6D0CD30E3EAF2ED10AE0CBC07506C5A /* Pods-SwaggerClientTests */ = { + isa = PBXGroup; + children = ( + 3F16B43ABD2C8CD4A311AA1AB3B6C02F /* Info.plist */, + 00ACB4396DD1B4E4539E4E81C1D7A14E /* Pods-SwaggerClientTests.modulemap */, + FB170EFD14935F121CDE3211DB4C5CA3 /* Pods-SwaggerClientTests-acknowledgements.markdown */, + 02F28E719AA874BE9213D6CF8CE7E36B /* Pods-SwaggerClientTests-acknowledgements.plist */, + 687B19CB3E722272B41D60B485C29EE7 /* Pods-SwaggerClientTests-dummy.m */, + 43FC49AA70D3E2A84CAED9C37BE9C4B5 /* Pods-SwaggerClientTests-frameworks.sh */, + E4E6F4A58FE7868CA2177D3AC79AD2FA /* Pods-SwaggerClientTests-resources.sh */, + F22FE315AC1C04A8749BD18281EE9028 /* Pods-SwaggerClientTests-umbrella.h */, + 969C2AF48F4307163B301A92E78AFCF2 /* Pods-SwaggerClientTests.debug.xcconfig */, + 849FECBC6CC67F2B6800F982927E3A9E /* Pods-SwaggerClientTests.release.xcconfig */, + ); + name = "Pods-SwaggerClientTests"; + path = "Target Support Files/Pods-SwaggerClientTests"; + sourceTree = ""; + }; + E4310C54179D230C8E716E0BF52E4F90 /* Alamofire */ = { + isa = PBXGroup; + children = ( + 621056D7E34F3276D7ECDB147918DBEC /* Alamofire.swift */, + 64491633490DB74E1E8D2CED2021C746 /* Download.swift */, + 526E73E2F71E0EC1442DFF1E6C3D7626 /* Error.swift */, + 25A12681F026446EDBE1C55D22872F9D /* Manager.swift */, + A7D21C15998D42252EF80A55181C7D18 /* MultipartFormData.swift */, + 3107BC52C0E01198FAE330F1ADC0BF3C /* ParameterEncoding.swift */, + 86C5082D39612A1F1FD675C33932AEC9 /* Request.swift */, + 3EB61DA897ED3DE273EC2B5824A42DF0 /* Response.swift */, + A56FED751BA06FF779D945B5D478065C /* ResponseSerialization.swift */, + BABA671A27CF29C8AA31D5C66D34CBA3 /* Result.swift */, + 6C4F5E9ABF91F6B2FF369456D3804258 /* ServerTrustPolicy.swift */, + 6EF1F005F839FD46AD74F13986274F1B /* Stream.swift */, + 8E78A6B0E3334E11FE5615FE4CC506E8 /* Upload.swift */, + F31DEFD11FF950B319F5E3A97C41178F /* Validation.swift */, + 771D190F914310F450FF47756BC0DD0F /* Support Files */, + ); + path = Alamofire; + sourceTree = ""; + }; + E73D9BF152C59F341559DE62A3143721 /* PetstoreClient */ = { + isa = PBXGroup; + children = ( + AD94092456F8ABCB18F74CAC75AD85DE /* Classes */, + ); + path = PetstoreClient; + sourceTree = ""; + }; + E9F8459055B900A58FB97600A53E5D1C /* PetstoreClient */ = { + isa = PBXGroup; + children = ( + E73D9BF152C59F341559DE62A3143721 /* PetstoreClient */, + 8F6D133867EE63820DFB7E83F4C51252 /* Support Files */, + ); + name = PetstoreClient; + path = ../..; + sourceTree = ""; + }; + F64549CFCC17C7AC6479508BE180B18D /* Swaggers */ = { + isa = PBXGroup; + children = ( + 92734297B64DFE0EB0EDE1EA821163DB /* AlamofireImplementations.swift */, + D2BAD338E56EF3CAA6E54490FE0C5DF9 /* APIHelper.swift */, + D8072E1108951F272C003553FC8926C7 /* APIs.swift */, + 5412898DEB10F1983487A10453C6B9CB /* Extensions.swift */, + 8F0266C5AE0B23A436291F6647902086 /* Models.swift */, + F92EFB558CBA923AB1CFA22F708E315A /* APIs */, + 1322FED69118C64DAD026CAF7F4C38C6 /* Models */, + ); + path = Swaggers; + sourceTree = ""; + }; + F92EFB558CBA923AB1CFA22F708E315A /* APIs */ = { + isa = PBXGroup; + children = ( + 261F03A3C73374FD19333EEA59CCD59F /* PetAPI.swift */, + 1A3E5E3CD673B025FD8AC260E67AB47E /* StoreAPI.swift */, + 552D15E0340BF58CC1922B82E864AEC9 /* UserAPI.swift */, + ); + path = APIs; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 0B076F0166D87A519E5251C471131E44 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 69AC467220269CE474E1C1156912C9DD /* RxSwift-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5F7B61281F714E2A64A51E80A2C9C062 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C5450AC69398958CF6F7539EF7D99E5 /* Alamofire-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 99AE2032DA4A773DFF2E835A8D453117 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + DFF7D509E6FC70067A71C1CF0441AD48 /* PetstoreClient-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9C8BBB69FE8BD651A7BBC07E32AED31A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 725EED04ED27CA8159CB2683F1EFD45A /* Pods-SwaggerClient-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FF84DA06E91FBBAA756A7832375803CE /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 897283A0B7F5299913327CC8FD6CC997 /* Pods-SwaggerClientTests-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 432ECC54282C84882B482CCB4CF227FC /* Alamofire */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8B2B2DA2F7F80D41B1FDB5FACFA4B3DE /* Build configuration list for PBXNativeTarget "Alamofire" */; + buildPhases = ( + EF659EFF40D426A3A32A82CDB98CC6EE /* Sources */, + A5AE1D340C4A0691EC28EEA8241C9FCD /* Frameworks */, + 5F7B61281F714E2A64A51E80A2C9C062 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Alamofire; + productName = Alamofire; + productReference = 5B598E168B47485DC60F9DBBCBEEF5BB /* Alamofire.framework */; + productType = "com.apple.product-type.framework"; + }; + 462B200BD111D7F438E47B7C42B6772F /* Pods-SwaggerClientTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 245A935A321D16F418F4D34C5D17D2B6 /* Build configuration list for PBXNativeTarget "Pods-SwaggerClientTests" */; + buildPhases = ( + 0529825EC79AED06C77091DC0F061854 /* Sources */, + FE8FC779CF4B0CFCC594E81C0FF86C7E /* Frameworks */, + FF84DA06E91FBBAA756A7832375803CE /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Pods-SwaggerClientTests"; + productName = "Pods-SwaggerClientTests"; + productReference = C4B474BD9070828C0F786071EEF46CD0 /* Pods_SwaggerClientTests.framework */; + productType = "com.apple.product-type.framework"; + }; + 7E04F4E0C9D1C499E7C5C2E0653893A5 /* Pods-SwaggerClient */ = { + isa = PBXNativeTarget; + buildConfigurationList = C17E886D20DFCEDEFC84423D6652F7EE /* Build configuration list for PBXNativeTarget "Pods-SwaggerClient" */; + buildPhases = ( + EDDE9277BF55CC0EE317B81A0DB026A1 /* Sources */, + 05BA91ABD8AC918A49A9D7E0E3722C70 /* Frameworks */, + 9C8BBB69FE8BD651A7BBC07E32AED31A /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + C9B7EA4A29DBD0225CC347E19EBAC59F /* PBXTargetDependency */, + 31D9C92344926342E3D2800111C05269 /* PBXTargetDependency */, + 57DC5B1E798B66E24E2BEC74CDB6BDF2 /* PBXTargetDependency */, + ); + name = "Pods-SwaggerClient"; + productName = "Pods-SwaggerClient"; + productReference = 057FC3E5DE19EA8F4DD600557D771032 /* Pods_SwaggerClient.framework */; + productType = "com.apple.product-type.framework"; + }; + B3F4219972B712BDBD25392781A43848 /* PetstoreClient */ = { + isa = PBXNativeTarget; + buildConfigurationList = F609276975EA85CEC0F2AA47BE77CDBD /* Build configuration list for PBXNativeTarget "PetstoreClient" */; + buildPhases = ( + CABD7A5E996838E97D6AE9D1E4A47DE6 /* Sources */, + CB2482011FA929C2BCC3E41A1B6E02E1 /* Frameworks */, + 99AE2032DA4A773DFF2E835A8D453117 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 9351A33C64C743193D9663213D4582BD /* PBXTargetDependency */, + F461599241C7FC6B0184BF7BAAEF658C /* PBXTargetDependency */, + ); + name = PetstoreClient; + productName = PetstoreClient; + productReference = E9CBBB398E7A62950FA8BC091CBE0359 /* PetstoreClient.framework */; + productType = "com.apple.product-type.framework"; + }; + F316854D76F084E9539BFEF85DCBCF9D /* RxSwift */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7335F4AA774EFBDED5B7673EF35FCF11 /* Build configuration list for PBXNativeTarget "RxSwift" */; + buildPhases = ( + 26ED5385D63D1F6761BEF3EA5FAE7165 /* Sources */, + 76130794E62D45206C62CE83429B6CF2 /* Frameworks */, + 0B076F0166D87A519E5251C471131E44 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RxSwift; + productName = RxSwift; + productReference = 84A09D760BA2EA13D5BE269086BAD34C /* RxSwift.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = C1398CE2D296EEBAA178C160CA6E6AD6 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 432ECC54282C84882B482CCB4CF227FC /* Alamofire */, + B3F4219972B712BDBD25392781A43848 /* PetstoreClient */, + 7E04F4E0C9D1C499E7C5C2E0653893A5 /* Pods-SwaggerClient */, + 462B200BD111D7F438E47B7C42B6772F /* Pods-SwaggerClientTests */, + F316854D76F084E9539BFEF85DCBCF9D /* RxSwift */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 0529825EC79AED06C77091DC0F061854 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C546890220177F840E8AFC829D0E3FEB /* Pods-SwaggerClientTests-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26ED5385D63D1F6761BEF3EA5FAE7165 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 22C91CF507223CEE1A7E1302E912DC8B /* AddRef.swift in Sources */, + CD00FDDA48E9BC390530672F9F09D8CF /* Amb.swift in Sources */, + B22405A127912A4943AEFBDD57E7A267 /* AnonymousDisposable.swift in Sources */, + 84B93CFEFA6412E49988C92153998357 /* AnonymousInvocable.swift in Sources */, + 4F8D754FA3405C5B692B644166A0F02A /* AnonymousObservable.swift in Sources */, + 77D1DB57FAA744C6ECBA7242836D6479 /* AnonymousObserver.swift in Sources */, + 751E794A58F9FCB7738D4ED30D10DD19 /* AnyObserver.swift in Sources */, + ADC582F488BC636CC4292513053F6992 /* AsyncLock.swift in Sources */, + D190592C39D806474770AF30FCC4EF4E /* Bag.swift in Sources */, + 9543E1505CCD2189D86456DAA0D55A22 /* BehaviorSubject.swift in Sources */, + 4DB1B23F5FAF7C5E02520AFE08646AF2 /* BinaryDisposable.swift in Sources */, + 96A03A2C4325A59DE2B02913FE351815 /* BooleanDisposable.swift in Sources */, + A606E44DA4B92B1FFBA177125D55F6AA /* Buffer.swift in Sources */, + 8BDC4F0F424CA9A8190F28E7A02417A8 /* Cancelable.swift in Sources */, + 39F4B474510DFC1711DD2EF809EA101B /* Catch.swift in Sources */, + B0F20FEA2B9A800D016EF5B46EFDECE9 /* CombineLatest+arity.swift in Sources */, + 04509FBE687E186C45C9E2F78E6F6946 /* CombineLatest+CollectionType.swift in Sources */, + 99F6DFF51E7C238DF99CA788144C732A /* CombineLatest.swift in Sources */, + 00A528BBED5B1D5DF26B8ADE64C5B3F2 /* CompositeDisposable.swift in Sources */, + 3DAFF4DA4C977B85B5C5B35728001AF2 /* Concat.swift in Sources */, + 028C4C90CAA75222DAA6CA7B37F16A84 /* ConcurrentDispatchQueueScheduler.swift in Sources */, + FEDA6187E5CC1CFB1781F8F4947E160C /* ConcurrentMainScheduler.swift in Sources */, + 030667BEF4154402A2317126A893E459 /* ConnectableObservable.swift in Sources */, + 1CBCB4FF2C9CDB144871C2A0856EB44D /* ConnectableObservableType.swift in Sources */, + ECFCC7B806126EF7788D0DE094711905 /* CurrentThreadScheduler.swift in Sources */, + F460F46DBA5EE0D4FABB3CD0BEFE6CE3 /* Debug.swift in Sources */, + 434C2C5108A8B9EEA916566F7DB0EDF6 /* Deferred.swift in Sources */, + 5997C0F97BD6687648224D5C6442B862 /* DelaySubscription.swift in Sources */, + 956216483BCB853794F52B0292831E9C /* DispatchQueueSchedulerQOS.swift in Sources */, + E51F4BE281ADBC629708A4D131E9190C /* Disposable.swift in Sources */, + 98FA1CFF63A5E74A7DB3255DA60C1843 /* DisposeBag.swift in Sources */, + 58023FA401993154E36E604471265263 /* DisposeBase.swift in Sources */, + 3AAB4B14DB0A02456F909B482400C142 /* DistinctUntilChanged.swift in Sources */, + AF3E5D2CE5E3448DB881E0F40F2F334F /* Do.swift in Sources */, + 4A216C127342712EDE589085CBB58962 /* ElementAt.swift in Sources */, + 5BD263D28F10A84969A6521CA166957C /* Empty.swift in Sources */, + 92450B928E8001F2B28A80072611F4C1 /* Error.swift in Sources */, + 498A556404BCE59DD962113CD29165A0 /* Errors.swift in Sources */, + BB3A568E8ED6C1792B43708A36A66F3D /* Event.swift in Sources */, + D180CF545583D5DCDF770FBAA36F5DB0 /* Filter.swift in Sources */, + A67CCBFC004EF58E785FA7ED4A1B69B6 /* Generate.swift in Sources */, + 22C9E40BB4DFB30DAAFD8555EF69BC08 /* HistoricalScheduler.swift in Sources */, + 5C8C1A80AB947F293430868D52A910C2 /* HistoricalSchedulerTimeConverter.swift in Sources */, + A4FBC2BD1A93FA52B5C97E79CDB9302F /* ImmediateScheduler.swift in Sources */, + 55D355CC26824B52E1A7420802FB5DC5 /* ImmediateSchedulerType.swift in Sources */, + C3739BDF471B57AECC84085608EC9CE6 /* InfiniteSequence.swift in Sources */, + 207AB9AAE48F202AF774554ED7545D98 /* InvocableScheduledItem.swift in Sources */, + 26E95A382D3F6848E571EF506D91B1C1 /* InvocableType.swift in Sources */, + 0487B12B08D927162A20CB2A56A2D077 /* Just.swift in Sources */, + 72CF8071AF37B85C1DE763805C39A3AB /* Lock.swift in Sources */, + F2246690EA6DEBF52D4CACA089B7FFC0 /* LockOwnerType.swift in Sources */, + B590B3C59D3A327452D2532766F2F630 /* MainScheduler.swift in Sources */, + 0D6AD3708152BB59E38D5839A0B0377F /* Map.swift in Sources */, + 4266AE0D8F9A4FA69F408AAC9118320A /* Merge.swift in Sources */, + 5BDF0811AEFBD49A7DE4AF35DA3BD34F /* Multicast.swift in Sources */, + E16A421C7269D0E81CB5E59344E63391 /* NAryDisposable.swift in Sources */, + 2023E24B94C04CC05DDFB499ECA760FB /* Never.swift in Sources */, + 00D1D0E4C3E6F9EA952C2EDEF2C13DE9 /* NopDisposable.swift in Sources */, + 7A6597623E723E6F8350D2CA30A2CD9C /* Observable+Aggregate.swift in Sources */, + D99C59116FC2BC799C9C9DE4D0282EB9 /* Observable+Binding.swift in Sources */, + A0A18CB5F889D7C2F80D6024EA568BEA /* Observable+Concurrency.swift in Sources */, + 618251D2C3027F214154D2CDFE1900AB /* Observable+Creation.swift in Sources */, + 501A111A5AE07BC13E3265DB49EE0A1B /* Observable+Debug.swift in Sources */, + EE42701AD3887754AF7695978852957E /* Observable+Extensions.swift in Sources */, + 68614EDB167FFFA6FBEC851368044FB3 /* Observable+Multiple.swift in Sources */, + 731E6ACE4939DCE8F6AF47FA1A00D595 /* Observable+Single.swift in Sources */, + E61B26D220A1A27E3BE7AD3F9BE35C76 /* Observable+StandardSequenceOperators.swift in Sources */, + 165531B0C3FF4D343825C3DB0B79FD68 /* Observable+Time.swift in Sources */, + DA18B15A9632B7282CF91FE4771C0B60 /* Observable.swift in Sources */, + E315A5FF56451DF73C7FE3140D5E2C6C /* ObservableConvertibleType.swift in Sources */, + 2BEA24EE395DA16EFEBC08B8D450F00A /* ObservableType.swift in Sources */, + 6414AAC9ED1AD7417B005D50D04341F5 /* ObserveOn.swift in Sources */, + CF13D1D873436D3890EC7392DEDE0B3E /* ObserveOnSerialDispatchQueue.swift in Sources */, + 88CCC2ADA43F75CB4708A701F5031643 /* ObserverBase.swift in Sources */, + 8D3CD54E3BACC9DB116DDA2DC30420CF /* ObserverType.swift in Sources */, + CA4A98FD2226B57E5F59E0BA2E1A97EC /* OperationQueueScheduler.swift in Sources */, + 6007585CC5912D979404BDB047CD36C4 /* Platform.Darwin.swift in Sources */, + D4789D8318C97E380412D03C1C321A88 /* Platform.Linux.swift in Sources */, + AC265ECE8E2AF91D58A755022E7DF802 /* PriorityQueue.swift in Sources */, + 4CA85A5CF8897D7D46BC6D0D76C8189A /* Producer.swift in Sources */, + DB5B0A5C01527330DCD4CEF9740C7140 /* PublishSubject.swift in Sources */, + B754E33E17893DF35DECA754DE819A66 /* Queue.swift in Sources */, + D0F5068C6F5C0489E8A41A9912A09016 /* Range.swift in Sources */, + AD9D268210ED449C3BE591513FD0CFB8 /* RecursiveScheduler.swift in Sources */, + 07E83400AACF1430C5B3DF482167A0F1 /* Reduce.swift in Sources */, + 3ADB6687421BF63BCC8A8C8D62E0C4F2 /* RefCount.swift in Sources */, + 66D9046FEDE40E6732F8B3E090007268 /* RefCountDisposable.swift in Sources */, + 5B721FAF55FEDB8046F23843565833A2 /* Repeat.swift in Sources */, + B28CA824CA5CD903042D8A07E9C5950E /* ReplaySubject.swift in Sources */, + 0A5F6F590DCE147853B2E21487ABA4AA /* RetryWhen.swift in Sources */, + 437C3354F611D5412125ADF24F4FDEE1 /* Rx.swift in Sources */, + 1A11209BABC1DE84187BFAEA3E91602D /* RxMutableBox.swift in Sources */, + B33369A55E29C11FA5F5977B5A47F1D4 /* RxSwift-dummy.m in Sources */, + 0607BCCDD781FF7FFD3629BF4A8BAD23 /* Sample.swift in Sources */, + 107E73472222CFD28A8C640F332DA52A /* Scan.swift in Sources */, + 0268E70939A7BFBC91C0557D16DDD027 /* ScheduledDisposable.swift in Sources */, + 4EF8849290BCC9D36D8D75969F6753E7 /* ScheduledItem.swift in Sources */, + BC10CEE813861D2F71E501E2F06532AB /* ScheduledItemType.swift in Sources */, + 0AEB6185484DD9137068A40CE70D4B85 /* SchedulerServices+Emulation.swift in Sources */, + 23CA1BD96C4742DE71082211C8DBFF5F /* SchedulerType.swift in Sources */, + 7E6DD4CEE210B03B7E3A0F01A36A7624 /* Sequence.swift in Sources */, + A23E9C4262ED3ED9FF20A9E6E1FA2121 /* SerialDispatchQueueScheduler.swift in Sources */, + 4AE52A909A95E3E4A6DC2F48BD8FC758 /* SerialDisposable.swift in Sources */, + 85E0465919F9DC7C97DD593CB49BB5E0 /* ShareReplay1.swift in Sources */, + 7F8297BE677C9A67B915F044DB16C0BE /* ShareReplay1WhileConnected.swift in Sources */, + 12999CCB3E22F57CB230F85534EF6930 /* SingleAssignmentDisposable.swift in Sources */, + 3EE9F1D7EB9C05CB5821E18136EF812E /* SingleAsync.swift in Sources */, + 4C5244B7F2D69F1DFC083E31070E3B0F /* Sink.swift in Sources */, + 33393FE8FB3933A22617E02FA3FFA780 /* Skip.swift in Sources */, + 79F6454BBF28D094A211494E22A07327 /* SkipUntil.swift in Sources */, + B7DCF4199B0EEF4CB2FE0DFF23F99049 /* SkipWhile.swift in Sources */, + B45CADB404E006E0EA39D7239C81C64F /* StableCompositeDisposable.swift in Sources */, + E8CAB3FA190277C8E609F992A51EA9D2 /* StartWith.swift in Sources */, + 9C824A364077ED1458CEF9776F2FB44A /* String+Rx.swift in Sources */, + 04923B3851BD1F857A9B207EE9EC8CDB /* SubjectType.swift in Sources */, + DC9EF51CEA903F88D43F7B3A96923DFD /* SubscribeOn.swift in Sources */, + CDF08B0C84BE839E79DF99C271453406 /* SubscriptionDisposable.swift in Sources */, + 3200EF8FA76EE92E0108DF928FB39CCB /* Switch.swift in Sources */, + C5099A3F4D955165F503506F2D10065D /* SynchronizedDisposeType.swift in Sources */, + 717576C9ABD8ABE8163D441ABE1C4A8D /* SynchronizedOnType.swift in Sources */, + 159C262BD23A08981D11D3B94340848B /* SynchronizedSubscribeType.swift in Sources */, + 313FCC5057970674AB6016DEF7A05902 /* SynchronizedUnsubscribeType.swift in Sources */, + 527C7425A5831BFC30CC9EC216506393 /* TailRecursiveSink.swift in Sources */, + 7F82F4EE1BA91C32CE75312176ACD4F0 /* Take.swift in Sources */, + 480B2F9937EF953E12DE12FCB177C32A /* TakeLast.swift in Sources */, + D932A3F3727B26175B547BA865A76B81 /* TakeUntil.swift in Sources */, + 5CF87E88489D3832C46FAFCE191F78F9 /* TakeWhile.swift in Sources */, + 9C3C83B09DE882AA526C40FDA31B69C8 /* Throttle.swift in Sources */, + 7574EBA19BA114D77C76D2CC1B58E73C /* Timeout.swift in Sources */, + C6EFFFF6D9947B99945FE08559733EF6 /* Timer.swift in Sources */, + 82DB09296E2BC713C6D363528657A3FD /* ToArray.swift in Sources */, + D5ECB1C860D3F53280EE2C5E54D470BD /* Using.swift in Sources */, + 2DF21CC164C25ED6947C67198879DE12 /* Variable.swift in Sources */, + 7E11CAC09AC72BD412078441E2F7BC21 /* VirtualTimeConverterType.swift in Sources */, + FFDD18622776D270EAFE1CF94726C96D /* VirtualTimeScheduler.swift in Sources */, + 84B43422CBE09278E477D1BFF27B07A1 /* Window.swift in Sources */, + 252E1D07E589566E0B8F49C2B9131976 /* WithLatestFrom.swift in Sources */, + BB5C8DC43B5072BBC05F56BF4DFD8CC5 /* Zip+arity.swift in Sources */, + 402BB7DBAC4D93AD381A0075D7BDDDBA /* Zip+CollectionType.swift in Sources */, + B0EAF63B91ABFD39C96353392D157D19 /* Zip.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CABD7A5E996838E97D6AE9D1E4A47DE6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 983C8A7CA7087B8FD905B6392B05B790 /* AlamofireImplementations.swift in Sources */, + 54325B7F87498350C604C429751BEC97 /* APIHelper.swift in Sources */, + 08D2C4B252A264F837733A22CBFB2481 /* APIs.swift in Sources */, + 569684CF06CEDCEA569BEC7910FC6E5B /* Category.swift in Sources */, + 75D86B4420906282E6B3393E98837360 /* Extensions.swift in Sources */, + BB03FC085AE6A19821878DE92116DDD5 /* Models.swift in Sources */, + A1B963DD34D20B255430C99DD78A1D43 /* Order.swift in Sources */, + DA202CAFA730E897B4D302C8C603A7E1 /* Pet.swift in Sources */, + AFF9AA31B242BF7F011D018D1B2A12FC /* PetAPI.swift in Sources */, + 4E1394BCD39E2E3470805196E884B68B /* PetstoreClient-dummy.m in Sources */, + 8634F37209E5506667C604C1973F630D /* StoreAPI.swift in Sources */, + 4B059D5D108F9D2A4E51A6D1B477A2F5 /* Tag.swift in Sources */, + 0A9698AC9DD60FC3721809C6AB9BCE81 /* User.swift in Sources */, + 97AB8959ABA0C9B8D4F400FD814BBB65 /* UserAPI.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EDDE9277BF55CC0EE317B81A0DB026A1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8B68A752ED9CC80E5478E4FEC5A5F721 /* Pods-SwaggerClient-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EF659EFF40D426A3A32A82CDB98CC6EE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B6D2DC3E3DA44CD382B9B425F40E11C1 /* Alamofire-dummy.m in Sources */, + B0FB4B01682814B9E3D32F9DC4A5E762 /* Alamofire.swift in Sources */, + A3505FA2FB3067D53847AD288AC04F03 /* Download.swift in Sources */, + D75CA395D510E08C404E55F5BDAE55CE /* Error.swift in Sources */, + A2C172FE407C0BC3478ADCA91A6C9CEC /* Manager.swift in Sources */, + 8399DBEE3E2D98EB1F466132E476F4D9 /* MultipartFormData.swift in Sources */, + 4DE5FCC41D100B113B6645EA64410F16 /* ParameterEncoding.swift in Sources */, + FC14480CECE872865A9C6E584F886DA3 /* Request.swift in Sources */, + 03F494989CC1A8857B68A317D5D6860F /* Response.swift in Sources */, + D21B7325B3642887BFBE977E021F2D26 /* ResponseSerialization.swift in Sources */, + 82971968CBDAB224212EEB4607C9FB8D /* Result.swift in Sources */, + 80F496237530D382A045A29654D8C11C /* ServerTrustPolicy.swift in Sources */, + FEF0D7653948988B804226129471C1EC /* Stream.swift in Sources */, + 0681ADC8BAE2C3185F13487BAAB4D9DD /* Upload.swift in Sources */, + C75519F0450166A6F28126ECC7664E9C /* Validation.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 31D9C92344926342E3D2800111C05269 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = PetstoreClient; + target = B3F4219972B712BDBD25392781A43848 /* PetstoreClient */; + targetProxy = D6508A8A1DB5D04976ECA9641101DB50 /* PBXContainerItemProxy */; + }; + 57DC5B1E798B66E24E2BEC74CDB6BDF2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = RxSwift; + target = F316854D76F084E9539BFEF85DCBCF9D /* RxSwift */; + targetProxy = 1E7EDC9660FD64A123EAC6BDA4C055AC /* PBXContainerItemProxy */; + }; + 9351A33C64C743193D9663213D4582BD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Alamofire; + target = 432ECC54282C84882B482CCB4CF227FC /* Alamofire */; + targetProxy = 1B1D2D2B5F790067C63584DC46E8DEED /* PBXContainerItemProxy */; + }; + C9B7EA4A29DBD0225CC347E19EBAC59F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Alamofire; + target = 432ECC54282C84882B482CCB4CF227FC /* Alamofire */; + targetProxy = 80996B8BB3446668F158E7817336A6E4 /* PBXContainerItemProxy */; + }; + F461599241C7FC6B0184BF7BAAEF658C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = RxSwift; + target = F316854D76F084E9539BFEF85DCBCF9D /* RxSwift */; + targetProxy = C11AB97FC44865EAFD37FD7629B96B72 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 00BCE7A03AB3EB1357203501EA6FCC84 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D0A71420D33D17B1C771C1CC7ADD8258 /* RxSwift.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/RxSwift/RxSwift-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/RxSwift/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/RxSwift/RxSwift.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = RxSwift; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 2B14898A0D927578A91AF17061B0704F /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 86B1DDCB9E27DF43C2C35D9E7B2E84DA /* Pods-SwaggerClient.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-SwaggerClient/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_SwaggerClient; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 3FA451D268613890FA8A5A03801E11D5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 5E62115DE8C09934BF8D2FE5D15FED1E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + ONLY_ACTIVE_ARCH = YES; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 8710426EC015A0183026219312A2B17E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DADAB10704E49D6B9E18F59F995BB88F /* PetstoreClient.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/PetstoreClient/PetstoreClient-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/PetstoreClient/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/PetstoreClient/PetstoreClient.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = PetstoreClient; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 99EA0FE8990CDA4F2B5110D22698851E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 849FECBC6CC67F2B6800F982927E3A9E /* Pods-SwaggerClientTests.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-SwaggerClientTests/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_SwaggerClientTests; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 9B259A01C5DDE12EA25530F7D005A3D2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 969C2AF48F4307163B301A92E78AFCF2 /* Pods-SwaggerClientTests.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-SwaggerClientTests/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-SwaggerClientTests/Pods-SwaggerClientTests.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_SwaggerClientTests; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 9B26D3A39011247999C097562A550399 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 66429A42B7499250307412ECB7AF627E /* Alamofire.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Alamofire/Alamofire-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Alamofire/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Alamofire/Alamofire.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = Alamofire; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + AD723F120D0CDC6265BA516FE35A9BEB /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 549C6527D10094289B101749047807C5 /* Pods-SwaggerClient.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-SwaggerClient/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_SwaggerClient; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + B0B4110B60B5F7F6D72CFA5E690CEF32 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D0A71420D33D17B1C771C1CC7ADD8258 /* RxSwift.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/RxSwift/RxSwift-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/RxSwift/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/RxSwift/RxSwift.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = RxSwift; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + BE1BF3E5FC53BAFA505AB342C35E1F50 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 66429A42B7499250307412ECB7AF627E /* Alamofire.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Alamofire/Alamofire-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Alamofire/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Alamofire/Alamofire.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = Alamofire; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + F0817112233556AF9CA538F326C20567 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DADAB10704E49D6B9E18F59F995BB88F /* PetstoreClient.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/PetstoreClient/PetstoreClient-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/PetstoreClient/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/PetstoreClient/PetstoreClient.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = PetstoreClient; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 245A935A321D16F418F4D34C5D17D2B6 /* Build configuration list for PBXNativeTarget "Pods-SwaggerClientTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B259A01C5DDE12EA25530F7D005A3D2 /* Debug */, + 99EA0FE8990CDA4F2B5110D22698851E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E62115DE8C09934BF8D2FE5D15FED1E /* Debug */, + 3FA451D268613890FA8A5A03801E11D5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7335F4AA774EFBDED5B7673EF35FCF11 /* Build configuration list for PBXNativeTarget "RxSwift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 00BCE7A03AB3EB1357203501EA6FCC84 /* Debug */, + B0B4110B60B5F7F6D72CFA5E690CEF32 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8B2B2DA2F7F80D41B1FDB5FACFA4B3DE /* Build configuration list for PBXNativeTarget "Alamofire" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BE1BF3E5FC53BAFA505AB342C35E1F50 /* Debug */, + 9B26D3A39011247999C097562A550399 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C17E886D20DFCEDEFC84423D6652F7EE /* Build configuration list for PBXNativeTarget "Pods-SwaggerClient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + AD723F120D0CDC6265BA516FE35A9BEB /* Debug */, + 2B14898A0D927578A91AF17061B0704F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F609276975EA85CEC0F2AA47BE77CDBD /* Build configuration list for PBXNativeTarget "PetstoreClient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F0817112233556AF9CA538F326C20567 /* Debug */, + 8710426EC015A0183026219312A2B17E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/LICENSE.md b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/LICENSE.md new file mode 100644 index 00000000000..d6765d9c9b9 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/LICENSE.md @@ -0,0 +1,9 @@ +**The MIT License** +**Copyright © 2015 Krunoslav Zaher** +**All rights reserved.** + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/README.md b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/README.md new file mode 100644 index 00000000000..c024273281e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/README.md @@ -0,0 +1,180 @@ +Miss Electric Eel 2016 RxSwift: ReactiveX for Swift +====================================== + +[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + +Xcode 7.3 Swift 2.2 required + +## About Rx + +Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. + +This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). + +It tries to port as many concepts from the original version as possible, but some concepts were adapted for more pleasant and performant integration with iOS/OSX environment. + +Cross platform documentation can be found on [ReactiveX.io](http://reactivex.io/). + +Like the original Rx, its intention is to enable easy composition of asynchronous operations and event/data streams. + +KVO observing, async operations and streams are all unified under [abstraction of sequence](Documentation/GettingStarted.md#observables-aka-sequences). This is the reason why Rx is so simple, elegant and powerful. + +## I came here because I want to ... + +###### ... understand + +* [why use rx?](Documentation/Why.md) +* [the basics, getting started with RxSwift](Documentation/GettingStarted.md) +* [units](Documentation/Units.md) - what is `Driver`, `ControlProperty`, and `Variable` ... and why do they exist? +* [testing](Documentation/UnitTests.md) +* [tips and common errors](Documentation/Tips.md) +* [debugging](Documentation/GettingStarted.md#debugging) +* [the math behind Rx](Documentation/MathBehindRx.md) +* [what are hot and cold observable sequences?](Documentation/HotAndColdObservables.md) +* [what does the the public API look like?](Documentation/API.md) + +###### ... install + +* Integrate RxSwift/RxCocoa with my app. [Installation Guide](Documentation/Installation.md) + +###### ... hack around + +* with the example app. [Running Example App](Documentation/ExampleApp.md) +* with operators in playgrounds. [Playgrounds](Documentation/Playgrounds.md) + +###### ... interact + +* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences.
[![Slack channel](http://slack.rxswift.org/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://slack.rxswift.org/) +* Report a problem using the library. [Open an Issue With Bug Template](ISSUE_TEMPLATE.md) +* Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md) + + +###### ... compare + +* [with other libraries](Documentation/ComparisonWithOtherLibraries.md). + + +###### ... find compatible + +* libraries from [RxSwiftCommunity](https://github.com/RxSwiftCommunity). +* [Pods using RxSwift](https://cocoapods.org/?q=uses%3Arxswift). + +###### ... see the broader vision + +* Does this exist for Android? [RxJava](https://github.com/ReactiveX/RxJava) +* Where is all of this going, what is the future, what about reactive architectures, how do you design entire apps this way? [Cycle.js](https://github.com/cyclejs/cycle-core) - this is javascript, but [RxJS](https://github.com/Reactive-Extensions/RxJS) is javascript version of Rx. + +## Usage + + + + + + + + + + + + + + + + + + + +
Here's an exampleIn Action
Define search for GitHub repositories ...
+let searchResults = searchBar.rx_text
+    .throttle(0.3, scheduler: MainScheduler.instance)
+    .distinctUntilChanged()
+    .flatMapLatest { query -> Observable<[Repository]> in
+        if query.isEmpty {
+            return Observable.just([])
+        }
+
+        return searchGitHub(query)
+            .catchErrorJustReturn([])
+    }
+    .observeOn(MainScheduler.instance)
... then bind the results to your tableview
+searchResults
+    .bindTo(tableView.rx_itemsWithCellIdentifier("Cell")) {
+        (index, repository: Repository, cell) in
+        cell.textLabel?.text = repository.name
+        cell.detailTextLabel?.text = repository.url
+    }
+    .addDisposableTo(disposeBag)
+ + +## Installation + +Rx doesn't contain any external dependencies. + +These are currently the supported options: + +### Manual + +Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build everything and run the sample app + +### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html) + +**:warning: IMPORTANT! For tvOS support, CocoaPods `0.39` is required. :warning:** + +``` +# Podfile +use_frameworks! + +target 'YOUR_TARGET_NAME' do + pod 'RxSwift', '~> 2.0' + pod 'RxCocoa', '~> 2.0' +end + +# RxTests and RxBlocking make the most sense in the context of unit/integration tests +target 'YOUR_TESTING_TARGET' do + pod 'RxBlocking', '~> 2.0' + pod 'RxTests', '~> 2.0' +end +``` + +Replace `YOUR_TARGET_NAME` and then, in the `Podfile` directory, type: + +``` +$ pod install +``` + +### [Carthage](https://github.com/Carthage/Carthage) + +**Xcode 7.1 required** + +Add this to `Cartfile` + +``` +github "ReactiveX/RxSwift" ~> 2.0 +``` + +``` +$ carthage update +``` + +### Manually using git submodules + +* Add RxSwift as a submodule + +``` +$ git submodule add git@github.com:ReactiveX/RxSwift.git +``` + +* Drag `Rx.xcodeproj` into Project Navigator +* Go to `Project > Targets > Build Phases > Link Binary With Libraries`, click `+` and select `RxSwift-[Platform]` and `RxCocoa-[Platform]` targets + + +## References + +* [http://reactivex.io/](http://reactivex.io/) +* [Reactive Extensions GitHub (GitHub)](https://github.com/Reactive-Extensions) +* [Erik Meijer (Wikipedia)](http://en.wikipedia.org/wiki/Erik_Meijer_%28computer_scientist%29) +* [Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx) (video)](https://youtu.be/looJcaeboBY) +* [Reactive Programming Overview (Jafar Husain from Netflix)](https://www.youtube.com/watch?v=dwP1TNXE6fc) +* [Subject/Observer is Dual to Iterator (paper)](http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf) +* [Rx standard sequence operators visualized (visualization tool)](http://rxmarbles.com/) +* [Haskell](https://www.haskell.org/) diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/AnyObserver.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/AnyObserver.swift new file mode 100644 index 00000000000..530142e4e68 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/AnyObserver.swift @@ -0,0 +1,75 @@ +// +// AnyObserver.swift +// Rx +// +// Created by Krunoslav Zaher on 2/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +A type-erased `ObserverType`. + +Forwards operations to an arbitrary underlying observer with the same `Element` type, hiding the specifics of the underlying observer type. +*/ +public struct AnyObserver : ObserverType { + /** + The type of elements in sequence that observer can observe. + */ + public typealias E = Element + + /** + Anonymous event handler type. + */ + public typealias EventHandler = (Event) -> Void + + public let observer: EventHandler + + /** + Construct an instance whose `on(event)` calls `eventHandler(event)` + + - parameter eventHandler: Event handler that observes sequences events. + */ + public init(eventHandler: EventHandler) { + self.observer = eventHandler + } + + /** + Construct an instance whose `on(event)` calls `observer.on(event)` + + - parameter observer: Observer that receives sequence events. + */ + public init(_ observer: O) { + self.observer = observer.on + } + + /** + Send `event` to this observer. + + - parameter event: Event instance. + */ + public func on(event: Event) { + return self.observer(event) + } + + /** + Erases type of observer and returns canonical observer. + + - returns: type erased observer. + */ + public func asObserver() -> AnyObserver { + return self + } +} + +extension ObserverType { + /** + Erases type of observer and returns canonical observer. + + - returns: type erased observer. + */ + public func asObserver() -> AnyObserver { + return AnyObserver(self) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Cancelable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Cancelable.swift new file mode 100644 index 00000000000..1a6c5911d0b --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Cancelable.swift @@ -0,0 +1,19 @@ +// +// Cancelable.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents disposable resource with state tracking. +*/ +public protocol Cancelable : Disposable { + /** + - returns: Was resource disposed. + */ + var disposed: Bool { get } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift new file mode 100644 index 00000000000..0d1ab168c24 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift @@ -0,0 +1,104 @@ +// +// AsyncLock.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +In case nobody holds this lock, the work will be queued and executed immediately +on thread that is requesting lock. + +In case there is somebody currently holding that lock, action will be enqueued. +When owned of the lock finishes with it's processing, it will also execute +and pending work. + +That means that enqueued work could possibly be executed later on a different thread. +*/ +class AsyncLock + : Disposable + , Lock + , SynchronizedDisposeType { + typealias Action = () -> Void + + var _lock = SpinLock() + + private var _queue: Queue = Queue(capacity: 0) + + private var _isExecuting: Bool = false + private var _hasFaulted: Bool = false + + // lock { + func lock() { + _lock.lock() + } + + func unlock() { + _lock.unlock() + } + // } + + private func enqueue(action: I) -> I? { + _lock.lock(); defer { _lock.unlock() } // { + if _hasFaulted { + return nil + } + + if _isExecuting { + _queue.enqueue(action) + return nil + } + + _isExecuting = true + + return action + // } + } + + private func dequeue() -> I? { + _lock.lock(); defer { _lock.unlock() } // { + if _queue.count > 0 { + return _queue.dequeue() + } + else { + _isExecuting = false + return nil + } + // } + } + + func invoke(action: I) { + let firstEnqueuedAction = enqueue(action) + + if let firstEnqueuedAction = firstEnqueuedAction { + firstEnqueuedAction.invoke() + } + else { + // action is enqueued, it's somebody else's concern now + return + } + + while true { + let nextAction = dequeue() + + if let nextAction = nextAction { + nextAction.invoke() + } + else { + return + } + } + } + + func dispose() { + synchronizedDispose() + } + + func _synchronized_dispose() { + _queue = Queue(capacity: 0) + _hasFaulted = true + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/Lock.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/Lock.swift new file mode 100644 index 00000000000..d1632f1cebf --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/Lock.swift @@ -0,0 +1,107 @@ +// +// Lock.swift +// Rx +// +// Created by Krunoslav Zaher on 3/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol Lock { + func lock() + func unlock() +} + +#if os(Linux) + import Glibc + + /** + Simple wrapper for spin lock. + */ + class SpinLock { + private var _lock: pthread_spinlock_t = 0 + + init() { + if (pthread_spin_init(&_lock, 0) != 0) { + fatalError("Spin lock initialization failed") + } + } + + func lock() { + pthread_spin_lock(&_lock) + } + + func unlock() { + pthread_spin_unlock(&_lock) + } + + func performLocked(@noescape action: () -> Void) { + lock(); defer { unlock() } + action() + } + + func calculateLocked(@noescape action: () -> T) -> T { + lock(); defer { unlock() } + return action() + } + + func calculateLockedOrFail(@noescape action: () throws -> T) throws -> T { + lock(); defer { unlock() } + let result = try action() + return result + } + + deinit { + pthread_spin_destroy(&_lock) + } + } +#else + + // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html + typealias SpinLock = NSRecursiveLock +#endif + +extension NSRecursiveLock : Lock { + func performLocked(@noescape action: () -> Void) { + lock(); defer { unlock() } + action() + } + + func calculateLocked(@noescape action: () -> T) -> T { + lock(); defer { unlock() } + return action() + } + + func calculateLockedOrFail(@noescape action: () throws -> T) throws -> T { + lock(); defer { unlock() } + let result = try action() + return result + } +} + +/* +let RECURSIVE_MUTEX = _initializeRecursiveMutex() + +func _initializeRecursiveMutex() -> pthread_mutex_t { + var mutex: pthread_mutex_t = pthread_mutex_t() + var mta: pthread_mutexattr_t = pthread_mutexattr_t() + + pthread_mutex_init(&mutex, nil) + pthread_mutexattr_init(&mta) + pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE) + pthread_mutex_init(&mutex, &mta) + + return mutex +} + +extension pthread_mutex_t { + mutating func lock() { + pthread_mutex_lock(&self) + } + + mutating func unlock() { + pthread_mutex_unlock(&self) + } +} +*/ diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift new file mode 100644 index 00000000000..b11fcaa87df --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift @@ -0,0 +1,23 @@ +// +// LockOwnerType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol LockOwnerType : class, Lock { + var _lock: NSRecursiveLock { get } +} + +extension LockOwnerType { + func lock() { + _lock.lock() + } + + func unlock() { + _lock.unlock() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift new file mode 100644 index 00000000000..5764575e899 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift @@ -0,0 +1,20 @@ +// +// SynchronizedDisposeType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedDisposeType : class, Disposable, Lock { + func _synchronized_dispose() +} + +extension SynchronizedDisposeType { + func synchronizedDispose() { + lock(); defer { unlock() } + _synchronized_dispose() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift new file mode 100644 index 00000000000..84a3df5d104 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift @@ -0,0 +1,20 @@ +// +// SynchronizedOnType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedOnType : class, ObserverType, Lock { + func _synchronized_on(event: Event) +} + +extension SynchronizedOnType { + func synchronizedOn(event: Event) { + lock(); defer { unlock() } + _synchronized_on(event) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift new file mode 100644 index 00000000000..a4903157511 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift @@ -0,0 +1,20 @@ +// +// SynchronizedSubscribeType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedSubscribeType : class, ObservableType, Lock { + func _synchronized_subscribe(observer: O) -> Disposable +} + +extension SynchronizedSubscribeType { + func synchronizedSubscribe(observer: O) -> Disposable { + lock(); defer { unlock() } + return _synchronized_subscribe(observer) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift new file mode 100644 index 00000000000..4f41cb89a66 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift @@ -0,0 +1,15 @@ +// +// SynchronizedUnsubscribeType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedUnsubscribeType : class { + associatedtype DisposeKey + + func synchronizedUnsubscribe(disposeKey: DisposeKey) +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ConnectableObservableType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ConnectableObservableType.swift new file mode 100644 index 00000000000..2ba55dc60f7 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ConnectableObservableType.swift @@ -0,0 +1,21 @@ +// +// ConnectableObservableType.swift +// Rx +// +// Created by Krunoslav Zaher on 3/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an observable sequence wrapper that can be connected and disconnected from its underlying observable sequence. +*/ +public protocol ConnectableObservableType : ObservableType { + /** + Connects the observable wrapper to its source. All subscribed observers will receive values from the underlying observable sequence as long as the connection is established. + + - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. + */ + func connect() -> Disposable +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Bag.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Bag.swift new file mode 100644 index 00000000000..f886f249f36 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Bag.swift @@ -0,0 +1,328 @@ +// +// Bag.swift +// Rx +// +// Created by Krunoslav Zaher on 2/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +import Swift + +let arrayDictionaryMaxSize = 30 + +/** +Class that enables using memory allocations as a means to uniquely identify objects. +*/ +class Identity { + // weird things have known to happen with Swift + var _forceAllocation: Int32 = 0 +} + +func hash(_x: Int) -> Int { + var x = _x + x = ((x >> 16) ^ x) &* 0x45d9f3b + x = ((x >> 16) ^ x) &* 0x45d9f3b + x = ((x >> 16) ^ x) + return x; +} + +/** +Unique identifier for object added to `Bag`. +*/ +public struct BagKey : Hashable { + let uniqueIdentity: Identity? + let key: Int + + public var hashValue: Int { + if let uniqueIdentity = uniqueIdentity { + return hash(key) ^ (unsafeAddressOf(uniqueIdentity).hashValue) + } + else { + return hash(key) + } + } +} + +/** +Compares two `BagKey`s. +*/ +public func == (lhs: BagKey, rhs: BagKey) -> Bool { + return lhs.key == rhs.key && lhs.uniqueIdentity === rhs.uniqueIdentity +} + +/** +Data structure that represents a bag of elements typed `T`. + +Single element can be stored multiple times. + +Time and space complexity of insertion an deletion is O(n). + +It is suitable for storing small number of elements. +*/ +public struct Bag : CustomDebugStringConvertible { + /** + Type of identifier for inserted elements. + */ + public typealias KeyType = BagKey + + private typealias ScopeUniqueTokenType = Int + + typealias Entry = (key: BagKey, value: T) + + private var _uniqueIdentity: Identity? + private var _nextKey: ScopeUniqueTokenType = 0 + + // data + + // first fill inline variables + private var _key0: BagKey? = nil + private var _value0: T? = nil + + private var _key1: BagKey? = nil + private var _value1: T? = nil + + // then fill "array dictionary" + private var _pairs = ContiguousArray() + + // last is sparse dictionary + private var _dictionary: [BagKey : T]? = nil + + private var _onlyFastPath = true + + /** + Creates new empty `Bag`. + */ + public init() { + } + + /** + Inserts `value` into bag. + + - parameter element: Element to insert. + - returns: Key that can be used to remove element from bag. + */ + public mutating func insert(element: T) -> BagKey { + _nextKey = _nextKey &+ 1 + +#if DEBUG + _nextKey = _nextKey % 20 +#endif + + if _nextKey == 0 { + _uniqueIdentity = Identity() + } + + let key = BagKey(uniqueIdentity: _uniqueIdentity, key: _nextKey) + + if _key0 == nil { + _key0 = key + _value0 = element + return key + } + + _onlyFastPath = false + + if _key1 == nil { + _key1 = key + _value1 = element + return key + } + + if _dictionary != nil { + _dictionary![key] = element + return key + } + + if _pairs.count < arrayDictionaryMaxSize { + _pairs.append(key: key, value: element) + return key + } + + if _dictionary == nil { + _dictionary = [:] + } + + _dictionary![key] = element + + return key + } + + /** + - returns: Number of elements in bag. + */ + public var count: Int { + let dictionaryCount: Int = _dictionary?.count ?? 0 + return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + dictionaryCount + } + + /** + Removes all elements from bag and clears capacity. + */ + public mutating func removeAll() { + _key0 = nil + _value0 = nil + _key1 = nil + _value1 = nil + + _pairs.removeAll(keepCapacity: false) + _dictionary?.removeAll(keepCapacity: false) + } + + /** + Removes element with a specific `key` from bag. + + - parameter key: Key that identifies element to remove from bag. + - returns: Element that bag contained, or nil in case element was already removed. + */ + public mutating func removeKey(key: BagKey) -> T? { + if _key0 == key { + _key0 = nil + let value = _value0! + _value0 = nil + return value + } + + if _key1 == key { + _key1 = nil + let value = _value1! + _value1 = nil + return value + } + + if let existingObject = _dictionary?.removeValueForKey(key) { + return existingObject + } + + for i in 0 ..< _pairs.count { + if _pairs[i].key == key { + let value = _pairs[i].value + _pairs.removeAtIndex(i) + return value + } + } + + return nil + } +} + +extension Bag { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription : String { + return "\(self.count) elements in Bag" + } +} + + +// MARK: forEach + +extension Bag { + /** + Enumerates elements inside the bag. + + - parameter action: Enumeration closure. + */ + public func forEach(@noescape action: (T) -> Void) { + if _onlyFastPath { + if let value0 = _value0 { + action(value0) + } + return + } + + let pairs = _pairs + let value0 = _value0 + let value1 = _value1 + let dictionary = _dictionary + + if let value0 = value0 { + action(value0) + } + + if let value1 = value1 { + action(value1) + } + + for i in 0 ..< pairs.count { + action(pairs[i].value) + } + + if dictionary?.count ?? 0 > 0 { + for element in dictionary!.values { + action(element) + } + } + } +} + +extension Bag where T: ObserverType { + /** + Dispatches `event` to app observers contained inside bag. + + - parameter action: Enumeration closure. + */ + public func on(event: Event) { + if _onlyFastPath { + _value0?.on(event) + return + } + + let pairs = _pairs + let value0 = _value0 + let value1 = _value1 + let dictionary = _dictionary + + if let value0 = value0 { + value0.on(event) + } + + if let value1 = value1 { + value1.on(event) + } + + for i in 0 ..< pairs.count { + pairs[i].value.on(event) + } + + if dictionary?.count ?? 0 > 0 { + for element in dictionary!.values { + element.on(event) + } + } + } +} + +/** +Dispatches `dispose` to all disposables contained inside bag. +*/ +public func disposeAllIn(bag: Bag) { + if bag._onlyFastPath { + bag._value0?.dispose() + return + } + + let pairs = bag._pairs + let value0 = bag._value0 + let value1 = bag._value1 + let dictionary = bag._dictionary + + if let value0 = value0 { + value0.dispose() + } + + if let value1 = value1 { + value1.dispose() + } + + for i in 0 ..< pairs.count { + pairs[i].value.dispose() + } + + if dictionary?.count ?? 0 > 0 { + for element in dictionary!.values { + element.dispose() + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift new file mode 100644 index 00000000000..33ead5ec09f --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift @@ -0,0 +1,30 @@ +// +// InfiniteSequence.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Sequence that repeats `repeatedValue` infinite number of times. +*/ +struct InfiniteSequence : SequenceType { + typealias Element = E + typealias Generator = AnyGenerator + + private let _repeatedValue: E + + init(repeatedValue: E) { + _repeatedValue = repeatedValue + } + + func generate() -> Generator { + let repeatedValue = _repeatedValue + return AnyGenerator { + return repeatedValue + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift new file mode 100644 index 00000000000..efbd546a453 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift @@ -0,0 +1,120 @@ +// +// PriorityQueue.swift +// Rx +// +// Created by Krunoslav Zaher on 12/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct PriorityQueue { + private let _hasHigherPriority: (Element, Element) -> Bool + private var _elements = [Element]() + + init(hasHigherPriority: (Element, Element) -> Bool) { + _hasHigherPriority = hasHigherPriority + } + + mutating func enqueue(element: Element) { + _elements.append(element) + bubbleToHigherPriority(_elements.count - 1) + } + + func peek() -> Element? { + return _elements.first + } + + var isEmpty: Bool { + return _elements.count == 0 + } + + mutating func dequeue() -> Element? { + guard let front = peek() else { + return nil + } + + removeAt(0) + + return front + } + + mutating func remove(element: Element) { + for i in 0 ..< _elements.count { + if _elements[i] === element { + removeAt(i) + return + } + } + } + + private mutating func removeAt(index: Int) { + let removingLast = index == _elements.count - 1 + if !removingLast { + swap(&_elements[index], &_elements[_elements.count - 1]) + } + + _elements.popLast() + + if !removingLast { + bubbleToHigherPriority(index) + bubbleToLowerPriority(index) + } + } + + private mutating func bubbleToHigherPriority(initialUnbalancedIndex: Int) { + precondition(initialUnbalancedIndex >= 0) + precondition(initialUnbalancedIndex < _elements.count) + + var unbalancedIndex = initialUnbalancedIndex + + while unbalancedIndex > 0 { + let parentIndex = (unbalancedIndex - 1) / 2 + + if _hasHigherPriority(_elements[unbalancedIndex], _elements[parentIndex]) { + swap(&_elements[unbalancedIndex], &_elements[parentIndex]) + + unbalancedIndex = parentIndex + } + else { + break + } + } + } + + private mutating func bubbleToLowerPriority(initialUnbalancedIndex: Int) { + precondition(initialUnbalancedIndex >= 0) + precondition(initialUnbalancedIndex < _elements.count) + + var unbalancedIndex = initialUnbalancedIndex + repeat { + let leftChildIndex = unbalancedIndex * 2 + 1 + let rightChildIndex = unbalancedIndex * 2 + 2 + + var highestPriorityIndex = unbalancedIndex + + if leftChildIndex < _elements.count && _hasHigherPriority(_elements[leftChildIndex], _elements[highestPriorityIndex]) { + highestPriorityIndex = leftChildIndex + } + + if rightChildIndex < _elements.count && _hasHigherPriority(_elements[rightChildIndex], _elements[highestPriorityIndex]) { + highestPriorityIndex = rightChildIndex + } + + if highestPriorityIndex != unbalancedIndex { + swap(&_elements[highestPriorityIndex], &_elements[unbalancedIndex]) + + unbalancedIndex = highestPriorityIndex + } + else { + break + } + } while true + } +} + +extension PriorityQueue : CustomDebugStringConvertible { + var debugDescription: String { + return _elements.debugDescription + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Queue.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Queue.swift new file mode 100644 index 00000000000..4bf95889861 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/DataStructures/Queue.swift @@ -0,0 +1,168 @@ +// +// Queue.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Data structure that represents queue. + +Complexity of `enqueue`, `dequeue` is O(1) when number of operations is +averaged over N operations. + +Complexity of `peek` is O(1). +*/ +public struct Queue: SequenceType { + /** + Type of generator. + */ + public typealias Generator = AnyGenerator + + private let _resizeFactor = 2 + + private var _storage: ContiguousArray + private var _count = 0 + private var _pushNextIndex = 0 + private var _initialCapacity: Int + + /** + Creates new queue. + + - parameter capacity: Capacity of newly created queue. + */ + public init(capacity: Int) { + _initialCapacity = capacity + + _storage = ContiguousArray(count: capacity, repeatedValue: nil) + } + + private var dequeueIndex: Int { + let index = _pushNextIndex - count + return index < 0 ? index + _storage.count : index + } + + /** + - returns: Is queue empty. + */ + public var isEmpty: Bool { + return count == 0 + } + + /** + - returns: Number of elements inside queue. + */ + public var count: Int { + return _count + } + + /** + - returns: Element in front of a list of elements to `dequeue`. + */ + public func peek() -> T { + precondition(count > 0) + + return _storage[dequeueIndex]! + } + + mutating private func resizeTo(size: Int) { + var newStorage = ContiguousArray(count: size, repeatedValue: nil) + + let count = _count + + let dequeueIndex = self.dequeueIndex + let spaceToEndOfQueue = _storage.count - dequeueIndex + + // first batch is from dequeue index to end of array + let countElementsInFirstBatch = min(count, spaceToEndOfQueue) + // second batch is wrapped from start of array to end of queue + let numberOfElementsInSecondBatch = count - countElementsInFirstBatch + + newStorage[0 ..< countElementsInFirstBatch] = _storage[dequeueIndex ..< (dequeueIndex + countElementsInFirstBatch)] + newStorage[countElementsInFirstBatch ..< (countElementsInFirstBatch + numberOfElementsInSecondBatch)] = _storage[0 ..< numberOfElementsInSecondBatch] + + _count = count + _pushNextIndex = count + _storage = newStorage + } + + /** + Enqueues `element`. + + - parameter element: Element to enqueue. + */ + public mutating func enqueue(element: T) { + if count == _storage.count { + resizeTo(max(_storage.count, 1) * _resizeFactor) + } + + _storage[_pushNextIndex] = element + _pushNextIndex += 1 + _count += 1 + + if _pushNextIndex >= _storage.count { + _pushNextIndex -= _storage.count + } + } + + private mutating func dequeueElementOnly() -> T { + precondition(count > 0) + + let index = dequeueIndex + + defer { + _storage[index] = nil + _count -= 1 + } + + return _storage[index]! + } + + /** + Dequeues element or throws an exception in case queue is empty. + + - returns: Dequeued element. + */ + public mutating func dequeue() -> T? { + if self.count == 0 { + return nil + } + + defer { + let downsizeLimit = _storage.count / (_resizeFactor * _resizeFactor) + if _count < downsizeLimit && downsizeLimit >= _initialCapacity { + resizeTo(_storage.count / _resizeFactor) + } + } + + return dequeueElementOnly() + } + + /** + - returns: Generator of contained elements. + */ + public func generate() -> Generator { + var i = dequeueIndex + var count = _count + + return AnyGenerator { + if count == 0 { + return nil + } + + defer { + count -= 1 + i += 1 + } + + if i >= self._storage.count { + i -= self._storage.count + } + + return self._storage[i] + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposable.swift new file mode 100644 index 00000000000..da760fff763 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposable.swift @@ -0,0 +1,15 @@ +// +// Disposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/// Respresents a disposable resource. +public protocol Disposable { + /// Dispose resource. + func dispose() +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift new file mode 100644 index 00000000000..17a40910be0 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift @@ -0,0 +1,54 @@ +// +// AnonymousDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an Action-based disposable. + +When dispose method is called, disposal action will be dereferenced. +*/ +public final class AnonymousDisposable : DisposeBase, Cancelable { + public typealias DisposeAction = () -> Void + + private var _disposed: AtomicInt = 0 + private var _disposeAction: DisposeAction? + + /** + - returns: Was resource disposed. + */ + public var disposed: Bool { + return _disposed == 1 + } + + /** + Constructs a new disposable with the given action used for disposal. + + - parameter disposeAction: Disposal action which will be run upon calling `dispose`. + */ + public init(_ disposeAction: DisposeAction) { + _disposeAction = disposeAction + super.init() + } + + /** + Calls the disposal action if and only if the current instance hasn't been disposed yet. + + After invoking disposal action, disposal action will be dereferenced. + */ + public func dispose() { + if AtomicCompareAndSwap(0, 1, &_disposed) { + assert(_disposed == 1) + + if let action = _disposeAction { + _disposeAction = nil + action() + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift new file mode 100644 index 00000000000..b6176592fdc --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift @@ -0,0 +1,54 @@ +// +// BinaryDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents two disposable resources that are disposed together. +*/ +public final class BinaryDisposable : DisposeBase, Cancelable { + + private var _disposed: AtomicInt = 0 + + // state + private var _disposable1: Disposable? + private var _disposable2: Disposable? + + /** + - returns: Was resource disposed. + */ + public var disposed: Bool { + return _disposed > 0 + } + + /** + Constructs new binary disposable from two disposables. + + - parameter disposable1: First disposable + - parameter disposable2: Second disposable + */ + init(_ disposable1: Disposable, _ disposable2: Disposable) { + _disposable1 = disposable1 + _disposable2 = disposable2 + super.init() + } + + /** + Calls the disposal action if and only if the current instance hasn't been disposed yet. + + After invoking disposal action, disposal action will be dereferenced. + */ + public func dispose() { + if AtomicCompareAndSwap(0, 1, &_disposed) { + _disposable1?.dispose() + _disposable2?.dispose() + _disposable1 = nil + _disposable2 = nil + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift new file mode 100644 index 00000000000..28db627b14a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift @@ -0,0 +1,45 @@ +// +// BooleanDisposable.swift +// Rx +// +// Created by Junior B. on 10/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable resource that can be checked for disposal status. +*/ +public class BooleanDisposable : Disposable, Cancelable { + + internal static let BooleanDisposableTrue = BooleanDisposable(disposed: true) + private var _disposed = false + + /** + Initializes a new instance of the `BooleanDisposable` class + */ + public init() { + } + + /** + Initializes a new instance of the `BooleanDisposable` class with given value + */ + public init(disposed: Bool) { + self._disposed = disposed + } + + /** + - returns: Was resource disposed. + */ + public var disposed: Bool { + return _disposed + } + + /** + Sets the status to disposed, which can be observer through the `disposed` property. + */ + public func dispose() { + _disposed = true + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift new file mode 100644 index 00000000000..a787f3625fd --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift @@ -0,0 +1,135 @@ +// +// CompositeDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/20/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a group of disposable resources that are disposed together. +*/ +public class CompositeDisposable : DisposeBase, Disposable, Cancelable { + public typealias DisposeKey = Bag.KeyType + + private var _lock = SpinLock() + + // state + private var _disposables: Bag? = Bag() + + public var disposed: Bool { + _lock.lock(); defer { _lock.unlock() } + return _disposables == nil + } + + public override init() { + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(_ disposable1: Disposable, _ disposable2: Disposable) { + // This overload is here to make sure we are using optimized version up to 4 arguments. + _disposables!.insert(disposable1) + _disposables!.insert(disposable2) + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable) { + // This overload is here to make sure we are using optimized version up to 4 arguments. + _disposables!.insert(disposable1) + _disposables!.insert(disposable2) + _disposables!.insert(disposable3) + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable, _ disposable4: Disposable, _ disposables: Disposable...) { + // This overload is here to make sure we are using optimized version up to 4 arguments. + _disposables!.insert(disposable1) + _disposables!.insert(disposable2) + _disposables!.insert(disposable3) + _disposables!.insert(disposable4) + + for disposable in disposables { + _disposables!.insert(disposable) + } + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(disposables: [Disposable]) { + for disposable in disposables { + _disposables!.insert(disposable) + } + } + + /** + Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. + + - parameter disposable: Disposable to add. + - returns: Key that can be used to remove disposable from composite disposable. In case dispose bag was already + disposed `nil` will be returned. + */ + public func addDisposable(disposable: Disposable) -> DisposeKey? { + let key = _addDisposable(disposable) + + if key == nil { + disposable.dispose() + } + + return key + } + + private func _addDisposable(disposable: Disposable) -> DisposeKey? { + _lock.lock(); defer { _lock.unlock() } + + return _disposables?.insert(disposable) + } + + /** + - returns: Gets the number of disposables contained in the `CompositeDisposable`. + */ + public var count: Int { + _lock.lock(); defer { _lock.unlock() } + return _disposables?.count ?? 0 + } + + /** + Removes and disposes the disposable identified by `disposeKey` from the CompositeDisposable. + + - parameter disposeKey: Key used to identify disposable to be removed. + */ + public func removeDisposable(disposeKey: DisposeKey) { + _removeDisposable(disposeKey)?.dispose() + } + + private func _removeDisposable(disposeKey: DisposeKey) -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + return _disposables?.removeKey(disposeKey) + } + + /** + Disposes all disposables in the group and removes them from the group. + */ + public func dispose() { + if let disposables = _dispose() { + disposeAllIn(disposables) + } + } + + private func _dispose() -> Bag? { + _lock.lock(); defer { _lock.unlock() } + + let disposeBag = _disposables + _disposables = nil + + return disposeBag + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift new file mode 100644 index 00000000000..ce1f0b7fce7 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift @@ -0,0 +1,94 @@ +// +// DisposeBag.swift +// Rx +// +// Created by Krunoslav Zaher on 3/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension Disposable { + /** + Adds `self` to `bag`. + + - parameter bag: `DisposeBag` to add `self` to. + */ + public func addDisposableTo(bag: DisposeBag) { + bag.addDisposable(self) + } +} + +/** +Thread safe bag that disposes added disposables on `deinit`. + +This returns ARC (RAII) like resource management to `RxSwift`. + +In case contained disposables need to be disposed, just put a different dispose bag +or create a new one in its place. + + self.existingDisposeBag = DisposeBag() + +In case explicit disposal is necessary, there is also `CompositeDisposable`. +*/ +public class DisposeBag: DisposeBase { + + private var _lock = SpinLock() + + // state + private var _disposables = [Disposable]() + private var _disposed = false + + /** + Constructs new empty dispose bag. + */ + public override init() { + super.init() + } + + /** + Adds `disposable` to be disposed when dispose bag is being deinited. + + - parameter disposable: Disposable to add. + */ + public func addDisposable(disposable: Disposable) { + _addDisposable(disposable)?.dispose() + } + + private func _addDisposable(disposable: Disposable) -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + if _disposed { + return disposable + } + + _disposables.append(disposable) + + return nil + } + + /** + This is internal on purpose, take a look at `CompositeDisposable` instead. + */ + private func dispose() { + let oldDisposables = _dispose() + + for disposable in oldDisposables { + disposable.dispose() + } + } + + private func _dispose() -> [Disposable] { + _lock.lock(); defer { _lock.unlock() } + + let disposables = _disposables + + _disposables.removeAll(keepCapacity: false) + _disposed = true + + return disposables + } + + deinit { + dispose() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift new file mode 100644 index 00000000000..86ecf4198f9 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift @@ -0,0 +1,26 @@ +// +// DisposeBase.swift +// Rx +// +// Created by Krunoslav Zaher on 4/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Base class for all disposables. +*/ +public class DisposeBase { + init() { +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) +#endif + } + + deinit { +#if TRACE_RESOURCES + AtomicDecrement(&resourceCount) +#endif + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NAryDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NAryDisposable.swift new file mode 100644 index 00000000000..548a1c3a5c2 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NAryDisposable.swift @@ -0,0 +1,10 @@ +// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project +// +// NAryDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 8/20/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift new file mode 100644 index 00000000000..05048bcea92 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift @@ -0,0 +1,32 @@ +// +// NopDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable that does nothing on disposal. + +Nop = No Operation +*/ +public struct NopDisposable : Disposable { + + /** + Singleton instance of `NopDisposable`. + */ + public static let instance: Disposable = NopDisposable() + + init() { + + } + + /** + Does nothing. + */ + public func dispose() { + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift new file mode 100644 index 00000000000..2d29d74a33f --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift @@ -0,0 +1,127 @@ +// +// RefCountDisposable.swift +// Rx +// +// Created by Junior B. on 10/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. + */ +public class RefCountDisposable : DisposeBase, Cancelable { + private var _lock = SpinLock() + private var _disposable = nil as Disposable? + private var _primaryDisposed = false + private var _count = 0 + + /** + - returns: Was resource disposed. + */ + public var disposed: Bool { + _lock.lock(); defer { _lock.unlock() } + return _disposable == nil + } + + /** + Initializes a new instance of the `RefCountDisposable`. + */ + public init(disposable: Disposable) { + _disposable = disposable + super.init() + } + + /** + Holds a dependent disposable that when disposed decreases the refcount on the underlying disposable. + + When getter is called, a dependent disposable contributing to the reference count that manages the underlying disposable's lifetime is returned. + */ + public func retain() -> Disposable { + return _lock.calculateLocked { + if let _ = _disposable { + + do { + try incrementChecked(&_count) + } catch (_) { + rxFatalError("RefCountDisposable increment failed") + } + + return RefCountInnerDisposable(self) + } else { + return NopDisposable.instance + } + } + } + + /** + Disposes the underlying disposable only when all dependent disposables have been disposed. + */ + public func dispose() { + let oldDisposable: Disposable? = _lock.calculateLocked { + if let oldDisposable = _disposable where !_primaryDisposed + { + _primaryDisposed = true + + if (_count == 0) + { + _disposable = nil + return oldDisposable + } + } + + return nil + } + + if let disposable = oldDisposable { + disposable.dispose() + } + } + + private func release() { + let oldDisposable: Disposable? = _lock.calculateLocked { + if let oldDisposable = _disposable { + do { + try decrementChecked(&_count) + } catch (_) { + rxFatalError("RefCountDisposable decrement on release failed") + } + + guard _count >= 0 else { + rxFatalError("RefCountDisposable counter is lower than 0") + } + + if _primaryDisposed && _count == 0 { + _disposable = nil + return oldDisposable + } + } + + return nil + } + + if let disposable = oldDisposable { + disposable.dispose() + } + } +} + +internal final class RefCountInnerDisposable: DisposeBase, Disposable +{ + private let _parent: RefCountDisposable + private var _disposed: AtomicInt = 0 + + init(_ parent: RefCountDisposable) + { + _parent = parent + super.init() + } + + internal func dispose() + { + if AtomicCompareAndSwap(0, 1, &_disposed) { + _parent.release() + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift new file mode 100644 index 00000000000..ac734996c46 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift @@ -0,0 +1,58 @@ +// +// ScheduledDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +private let disposeScheduledDisposable: ScheduledDisposable -> Disposable = { sd in + sd.disposeInner() + return NopDisposable.instance +} + +/** +Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler. +*/ +public class ScheduledDisposable : Cancelable { + public let scheduler: ImmediateSchedulerType + + private var _disposed: AtomicInt = 0 + + // state + private var _disposable: Disposable? + + /** + - returns: Was resource disposed. + */ + public var disposed: Bool { + return _disposed == 1 + } + + /** + Initializes a new instance of the `ScheduledDisposable` that uses a `scheduler` on which to dispose the `disposable`. + + - parameter scheduler: Scheduler where the disposable resource will be disposed on. + - parameter disposable: Disposable resource to dispose on the given scheduler. + */ + public init(scheduler: ImmediateSchedulerType, disposable: Disposable) { + self.scheduler = scheduler + _disposable = disposable + } + + /** + Disposes the wrapped disposable on the provided scheduler. + */ + public func dispose() { + scheduler.schedule(self, action: disposeScheduledDisposable) + } + + func disposeInner() { + if AtomicCompareAndSwap(0, 1, &_disposed) { + _disposable!.dispose() + _disposable = nil + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift new file mode 100644 index 00000000000..07eebcc1cb5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift @@ -0,0 +1,85 @@ +// +// SerialDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource. +*/ +public class SerialDisposable : DisposeBase, Cancelable { + private var _lock = SpinLock() + + // state + private var _current = nil as Disposable? + private var _disposed = false + + /** + - returns: Was resource disposed. + */ + public var disposed: Bool { + return _disposed + } + + /** + Initializes a new instance of the `SerialDisposable`. + */ + override public init() { + super.init() + } + + /** + Gets or sets the underlying disposable. + + Assigning this property disposes the previous disposable object. + + If the `SerialDisposable` has already been disposed, assignment to this property causes immediate disposal of the given disposable object. + */ + public var disposable: Disposable { + get { + return _lock.calculateLocked { + return self.disposable + } + } + set (newDisposable) { + let disposable: Disposable? = _lock.calculateLocked { + if _disposed { + return newDisposable + } + else { + let toDispose = _current + _current = newDisposable + return toDispose + } + } + + if let disposable = disposable { + disposable.dispose() + } + } + } + + /** + Disposes the underlying disposable as well as all future replacements. + */ + public func dispose() { + _dispose()?.dispose() + } + + private func _dispose() -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + if _disposed { + return nil + } + else { + _disposed = true + let current = _current + _current = nil + return current + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift new file mode 100644 index 00000000000..2b192bac869 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift @@ -0,0 +1,89 @@ +// +// SingleAssignmentDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable resource which only allows a single assignment of its underlying disposable resource. + +If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception. +*/ +public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable { + private var _lock = SpinLock() + + // state + private var _disposed = false + private var _disposableSet = false + private var _disposable = nil as Disposable? + + /** + - returns: A value that indicates whether the object is disposed. + */ + public var disposed: Bool { + return _disposed + } + + /** + Initializes a new instance of the `SingleAssignmentDisposable`. + */ + public override init() { + super.init() + } + + /** + Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined. + + **Throws exception if the `SingleAssignmentDisposable` has already been assigned to.** + */ + public var disposable: Disposable { + get { + _lock.lock(); defer { _lock.unlock() } + return _disposable ?? NopDisposable.instance + } + set { + _setDisposable(newValue)?.dispose() + } + } + + private func _setDisposable(newValue: Disposable) -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + if _disposableSet { + rxFatalError("oldState.disposable != nil") + } + + _disposableSet = true + + if _disposed { + return newValue + } + + _disposable = newValue + + return nil + } + + /** + Disposes the underlying disposable. + */ + public func dispose() { + if _disposed { + return + } + _dispose()?.dispose() + } + + private func _dispose() -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + + _disposed = true + let disposable = _disposable + _disposable = nil + + return disposable + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift new file mode 100644 index 00000000000..54162d2ee63 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift @@ -0,0 +1,15 @@ +// +// StableCompositeDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +public final class StableCompositeDisposable { + public static func create(disposable1: Disposable, _ disposable2: Disposable) -> Disposable { + return BinaryDisposable(disposable1, disposable2) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift new file mode 100644 index 00000000000..7a3e1e97053 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift @@ -0,0 +1,23 @@ +// +// SubscriptionDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct SubscriptionDisposable : Disposable { + private let _key: T.DisposeKey + private weak var _owner: T? + + init(owner: T, key: T.DisposeKey) { + _owner = owner + _key = key + } + + func dispose() { + _owner?.synchronizedUnsubscribe(_key) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Errors.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Errors.swift new file mode 100644 index 00000000000..ccb71c198a8 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Errors.swift @@ -0,0 +1,72 @@ +// +// Errors.swift +// Rx +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +let RxErrorDomain = "RxErrorDomain" +let RxCompositeFailures = "RxCompositeFailures" + +/** +Generic Rx error codes. +*/ +public enum RxError + : ErrorType + , CustomDebugStringConvertible { + /** + Unknown error occured. + */ + case Unknown + /** + Performing an action on disposed object. + */ + case Disposed(object: AnyObject) + /** + Aritmetic overflow error. + */ + case Overflow + /** + Argument out of range error. + */ + case ArgumentOutOfRange + /** + Sequence doesn't contain any elements. + */ + case NoElements + /** + Sequence contains more than one element. + */ + case MoreThanOneElement + /** + Timeout error. + */ + case Timeout +} + +public extension RxError { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + switch self { + case .Unknown: + return "Unknown error occured." + case .Disposed(let object): + return "Object `\(object)` was already disposed." + case .Overflow: + return "Arithmetic overflow occured." + case .ArgumentOutOfRange: + return "Argument out of range." + case .NoElements: + return "Sequence doesn't contain any elements." + case .MoreThanOneElement: + return "Sequence contains more than one element." + case .Timeout: + return "Sequence timeout." + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Event.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Event.swift new file mode 100644 index 00000000000..46e5f1b13d8 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Event.swift @@ -0,0 +1,66 @@ +// +// Event.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a sequence event. + +Sequence grammar: +Next\* (Error | Completed) +*/ +public enum Event { + /// Next element is produced. + case Next(Element) + + /// Sequence terminated with an error. + case Error(ErrorType) + + /// Sequence completed successfully. + case Completed +} + +extension Event : CustomDebugStringConvertible { + /// - returns: Description of event. + public var debugDescription: String { + switch self { + case .Next(let value): + return "Next(\(value))" + case .Error(let error): + return "Error(\(error))" + case .Completed: + return "Completed" + } + } +} + +extension Event { + /// - returns: Is `Completed` or `Error` event. + public var isStopEvent: Bool { + switch self { + case .Next: return false + case .Error, .Completed: return true + } + } + + /// - returns: If `Next` event, returns element value. + public var element: Element? { + if case .Next(let value) = self { + return value + } + return nil + } + + /// - returns: If `Error` event, returns error. + public var error: ErrorType? { + if case .Error(let error) = self { + return error + } + return nil + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift new file mode 100644 index 00000000000..430fc3a3fec --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift @@ -0,0 +1,26 @@ +// +// String+Rx.swift +// Rx +// +// Created by Krunoslav Zaher on 12/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension String { + /** + This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)` + */ + func lastIndexOf(character: Character) -> Index? { + var index = endIndex + while index > startIndex { + index = index.predecessor() + if self[index] == character { + return index + } + } + + return nil + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift new file mode 100644 index 00000000000..b14b9abdaee --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift @@ -0,0 +1,40 @@ +// +// ImmediateSchedulerType.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an object that immediately schedules units of work. +*/ +public protocol ImmediateSchedulerType { + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable +} + +extension ImmediateSchedulerType { + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleRecursive(state: State, action: (state: State, recurse: (State) -> ()) -> ()) -> Disposable { + let recursiveScheduler = RecursiveImmediateScheduler(action: action, scheduler: self) + + recursiveScheduler.schedule(state) + + return AnonymousDisposable(recursiveScheduler.dispose) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable+Extensions.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable+Extensions.swift new file mode 100644 index 00000000000..c44b9b05125 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable+Extensions.swift @@ -0,0 +1,128 @@ +// +// Observable+Extensions.swift +// Rx +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension ObservableType { + /** + Subscribes an event handler to an observable sequence. + + - parameter on: Action to invoke for each event in the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + public func subscribe(on: (event: Event) -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + on(event: e) + } + return self.subscribeSafe(observer) + } + + /** + Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has + gracefully completed, errored, or if the generation is cancelled by disposing subscription). + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + public func subscribe(onNext onNext: (E -> Void)? = nil, onError: (ErrorType -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) + -> Disposable { + + let disposable: Disposable + + if let disposed = onDisposed { + disposable = AnonymousDisposable(disposed) + } + else { + disposable = NopDisposable.instance + } + + let observer = AnonymousObserver { e in + switch e { + case .Next(let value): + onNext?(value) + case .Error(let e): + onError?(e) + disposable.dispose() + case .Completed: + onCompleted?() + disposable.dispose() + } + } + return BinaryDisposable( + self.subscribeSafe(observer), + disposable + ) + } + + /** + Subscribes an element handler to an observable sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + public func subscribeNext(onNext: (E) -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + if case .Next(let value) = e { + onNext(value) + } + } + return self.subscribeSafe(observer) + } + + /** + Subscribes an error handler to an observable sequence. + + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + public func subscribeError(onError: (ErrorType) -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + if case .Error(let error) = e { + onError(error) + } + } + return self.subscribeSafe(observer) + } + + /** + Subscribes a completion handler to an observable sequence. + + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + public func subscribeCompleted(onCompleted: () -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + if case .Completed = e { + onCompleted() + } + } + return self.subscribeSafe(observer) + } +} + +public extension ObservableType { + /** + All internal subscribe calls go through this method. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + func subscribeSafe(observer: O) -> Disposable { + return self.asObservable().subscribe(observer) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable.swift new file mode 100644 index 00000000000..cc472a0c9b7 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observable.swift @@ -0,0 +1,51 @@ +// +// Observable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +A type-erased `ObservableType`. + +It represents a push style sequence. +*/ +public class Observable : ObservableType { + /** + Type of elements in sequence. + */ + public typealias E = Element + + init() { +#if TRACE_RESOURCES + OSAtomicIncrement32(&resourceCount) +#endif + } + + public func subscribe(observer: O) -> Disposable { + abstractMethod() + } + + public func asObservable() -> Observable { + return self + } + + deinit { +#if TRACE_RESOURCES + AtomicDecrement(&resourceCount) +#endif + } + + // this is kind of ugly I know :( + // Swift compiler reports "Not supported yet" when trying to override protocol extensions, so ¯\_(ツ)_/¯ + + /** + Optimizations for map operator + */ + internal func composeMap(selector: Element throws -> R) -> Observable { + return Map(source: self, selector: selector) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift new file mode 100644 index 00000000000..802cc472fd4 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift @@ -0,0 +1,26 @@ +// +// ObservableConvertibleType.swift +// Rx +// +// Created by Krunoslav Zaher on 9/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type that can be converted to observable sequence (`Observer`). +*/ +public protocol ObservableConvertibleType { + /** + Type of elements in sequence. + */ + associatedtype E + + /** + Converts `self` to `Observable` sequence. + + - returns: Observable sequence that represents `self`. + */ + func asObservable() -> Observable +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableType.swift new file mode 100644 index 00000000000..5608ac03fd5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObservableType.swift @@ -0,0 +1,57 @@ +// +// ObservableType.swift +// RxSwift +// +// Created by Krunoslav Zaher on 8/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a push style sequence. +*/ +public protocol ObservableType : ObservableConvertibleType { + /** + Type of elements in sequence. + */ + associatedtype E + + /** + Subscribes `observer` to receive events for this sequence. + + ### Grammar + + **Next\* (Error | Completed)?** + + * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer` + * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other elements + + It is possible that events are sent from different threads, but no two events can be sent concurrently to + `observer`. + + ### Resource Management + + When sequence sends `Complete` or `Error` event all internal resources that compute sequence elements + will be freed. + + To cancel production of sequence elements and free resources immediatelly, call `dispose` on returned + subscription. + + - returns: Subscription for `observer` that can be used to cancel production of sequence elements and free resources. + */ + @warn_unused_result(message="http://git.io/rxs.ud") + func subscribe(observer: O) -> Disposable + +} + +extension ObservableType { + + /** + Default implementation of converting `ObservableType` to `Observable`. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func asObservable() -> Observable { + return Observable.create(self.subscribe) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift new file mode 100644 index 00000000000..211a9d41f34 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift @@ -0,0 +1,47 @@ +// +// AddRef.swift +// Rx +// +// Created by Junior B. on 30/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class AddRefSink : Sink, ObserverType { + typealias Element = O.E + + override init(observer: O) { + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(_): + forwardOn(event) + case .Completed, .Error(_): + forwardOn(event) + dispose() + } + } +} + +class AddRef : Producer { + typealias EventHandler = Event throws -> Void + + private let _source: Observable + private let _refCount: RefCountDisposable + + init(source: Observable, refCount: RefCountDisposable) { + _source = source + _refCount = refCount + } + + override func run(observer: O) -> Disposable { + let releaseDisposable = _refCount.retain() + let sink = AddRefSink(observer: observer) + sink.disposable = StableCompositeDisposable.create(releaseDisposable, _source.subscribeSafe(sink)) + + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift new file mode 100644 index 00000000000..7e9b5452294 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift @@ -0,0 +1,122 @@ +// +// Amb.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +enum AmbState { + case Neither + case Left + case Right +} + +class AmbObserver : ObserverType { + typealias Element = ElementType + typealias Parent = AmbSink + typealias This = AmbObserver + typealias Sink = (This, Event) -> Void + + private let _parent: Parent + private var _sink: Sink + private var _cancel: Disposable + + init(parent: Parent, cancel: Disposable, sink: Sink) { +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) +#endif + + _parent = parent + _sink = sink + _cancel = cancel + } + + func on(event: Event) { + _sink(self, event) + if event.isStopEvent { + _cancel.dispose() + } + } + + deinit { +#if TRACE_RESOURCES + AtomicDecrement(&resourceCount) +#endif + } +} + +class AmbSink : Sink { + typealias Parent = Amb + typealias AmbObserverType = AmbObserver + + private let _parent: Parent + + private let _lock = NSRecursiveLock() + // state + private var _choice = AmbState.Neither + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let disposeAll = StableCompositeDisposable.create(subscription1, subscription2) + + let forwardEvent = { (o: AmbObserverType, event: Event) -> Void in + self.forwardOn(event) + } + + let decide = { (o: AmbObserverType, event: Event, me: AmbState, otherSubscription: Disposable) in + self._lock.performLocked { + if self._choice == .Neither { + self._choice = me + o._sink = forwardEvent + o._cancel = disposeAll + otherSubscription.dispose() + } + + if self._choice == me { + self.forwardOn(event) + if event.isStopEvent { + self.dispose() + } + } + } + } + + let sink1 = AmbObserver(parent: self, cancel: subscription1) { o, e in + decide(o, e, .Left, subscription2) + } + + let sink2 = AmbObserver(parent: self, cancel: subscription1) { o, e in + decide(o, e, .Right, subscription1) + } + + subscription1.disposable = _parent._left.subscribe(sink1) + subscription2.disposable = _parent._right.subscribe(sink2) + + return disposeAll + } +} + +class Amb: Producer { + private let _left: Observable + private let _right: Observable + + init(left: Observable, right: Observable) { + _left = left + _right = right + } + + override func run(observer: O) -> Disposable { + let sink = AmbSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift new file mode 100644 index 00000000000..11346a9ff66 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift @@ -0,0 +1,56 @@ +// +// AnonymousObservable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class AnonymousObservableSink : Sink, ObserverType { + typealias E = O.E + typealias Parent = AnonymousObservable + + // state + private var _isStopped: AtomicInt = 0 + + override init(observer: O) { + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next: + if _isStopped == 1 { + return + } + forwardOn(event) + case .Error, .Completed: + if AtomicCompareAndSwap(0, 1, &_isStopped) { + forwardOn(event) + dispose() + } + } + } + + func run(parent: Parent) -> Disposable { + return parent._subscribeHandler(AnyObserver(self)) + } +} + +class AnonymousObservable : Producer { + typealias SubscribeHandler = (AnyObserver) -> Disposable + + let _subscribeHandler: SubscribeHandler + + init(_ subscribeHandler: SubscribeHandler) { + _subscribeHandler = subscribeHandler + } + + override func run(observer: O) -> Disposable { + let sink = AnonymousObservableSink(observer: observer) + sink.disposable = sink.run(self) + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift new file mode 100644 index 00000000000..0fa4714f2a3 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift @@ -0,0 +1,119 @@ +// +// Buffer.swift +// Rx +// +// Created by Krunoslav Zaher on 9/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class BufferTimeCount : Producer<[Element]> { + + private let _timeSpan: RxTimeInterval + private let _count: Int + private let _scheduler: SchedulerType + private let _source: Observable + + init(source: Observable, timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) { + _source = source + _timeSpan = timeSpan + _count = count + _scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = BufferTimeCountSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + +class BufferTimeCountSink + : Sink + , LockOwnerType + , ObserverType + , SynchronizedOnType { + typealias Parent = BufferTimeCount + typealias E = Element + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + private let _timerD = SerialDisposable() + private var _buffer = [Element]() + private var _windowID = 0 + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + createTimer(_windowID) + return StableCompositeDisposable.create(_timerD, _parent._source.subscribe(self)) + } + + func startNewWindowAndSendCurrentOne() { + _windowID = _windowID &+ 1 + let windowID = _windowID + + let buffer = _buffer + _buffer = [] + forwardOn(.Next(buffer)) + + createTimer(windowID) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let element): + _buffer.append(element) + + if _buffer.count == _parent._count { + startNewWindowAndSendCurrentOne() + } + + case .Error(let error): + _buffer = [] + forwardOn(.Error(error)) + dispose() + case .Completed: + forwardOn(.Next(_buffer)) + forwardOn(.Completed) + dispose() + } + } + + func createTimer(windowID: Int) { + if _timerD.disposed { + return + } + + if _windowID != windowID { + return + } + + let nextTimer = SingleAssignmentDisposable() + + _timerD.disposable = nextTimer + + nextTimer.disposable = _parent._scheduler.scheduleRelative(windowID, dueTime: _parent._timeSpan) { previousWindowID in + self._lock.performLocked { + if previousWindowID != self._windowID { + return + } + + self.startNewWindowAndSendCurrentOne() + } + + return NopDisposable.instance + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift new file mode 100644 index 00000000000..5f73d40538f --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift @@ -0,0 +1,162 @@ +// +// Catch.swift +// RxSwift +// +// Created by Krunoslav Zaher on 4/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// catch with callback + +class CatchSinkProxy : ObserverType { + typealias E = O.E + typealias Parent = CatchSink + + private let _parent: Parent + + init(parent: Parent) { + _parent = parent + } + + func on(event: Event) { + _parent.forwardOn(event) + + switch event { + case .Next: + break + case .Error, .Completed: + _parent.dispose() + } + } +} + +class CatchSink : Sink, ObserverType { + typealias E = O.E + typealias Parent = Catch + + private let _parent: Parent + private let _subscription = SerialDisposable() + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + let d1 = SingleAssignmentDisposable() + _subscription.disposable = d1 + d1.disposable = _parent._source.subscribe(self) + + return _subscription + } + + func on(event: Event) { + switch event { + case .Next: + forwardOn(event) + case .Completed: + forwardOn(event) + dispose() + case .Error(let error): + do { + let catchSequence = try _parent._handler(error) + + let observer = CatchSinkProxy(parent: self) + + _subscription.disposable = catchSequence.subscribe(observer) + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + } + } +} + +class Catch : Producer { + typealias Handler = (ErrorType) throws -> Observable + + private let _source: Observable + private let _handler: Handler + + init(source: Observable, handler: Handler) { + _source = source + _handler = handler + } + + override func run(observer: O) -> Disposable { + let sink = CatchSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + +// catch enumerable + +class CatchSequenceSink + : TailRecursiveSink + , ObserverType { + typealias Element = O.E + typealias Parent = CatchSequence + + private var _lastError: ErrorType? + + override init(observer: O) { + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next: + forwardOn(event) + case .Error(let error): + _lastError = error + schedule(.MoveNext) + case .Completed: + forwardOn(event) + dispose() + } + } + + override func subscribeToNext(source: Observable) -> Disposable { + return source.subscribe(self) + } + + override func done() { + if let lastError = _lastError { + forwardOn(.Error(lastError)) + } + else { + forwardOn(.Completed) + } + + self.dispose() + } + + override func extract(observable: Observable) -> SequenceGenerator? { + if let onError = observable as? CatchSequence { + return (onError.sources.generate(), nil) + } + else { + return nil + } + } +} + +class CatchSequence : Producer { + typealias Element = S.Generator.Element.E + + let sources: S + + init(sources: S) { + self.sources = sources + } + + override func run(observer: O) -> Disposable { + let sink = CatchSequenceSink(observer: observer) + sink.disposable = sink.run((self.sources.generate(), nil)) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift new file mode 100644 index 00000000000..7164815d7ab --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift @@ -0,0 +1,125 @@ +// +// CombineLatest+CollectionType.swift +// Rx +// +// Created by Krunoslav Zaher on 8/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class CombineLatestCollectionTypeSink + : Sink { + typealias Parent = CombineLatestCollectionType + typealias SourceElement = C.Generator.Element.E + + let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + var _numberOfValues = 0 + var _values: [SourceElement?] + var _isDone: [Bool] + var _numberOfDone = 0 + var _subscriptions: [SingleAssignmentDisposable] + + init(parent: Parent, observer: O) { + _parent = parent + _values = [SourceElement?](count: parent._count, repeatedValue: nil) + _isDone = [Bool](count: parent._count, repeatedValue: false) + _subscriptions = Array() + _subscriptions.reserveCapacity(parent._count) + + for _ in 0 ..< parent._count { + _subscriptions.append(SingleAssignmentDisposable()) + } + + super.init(observer: observer) + } + + func on(event: Event, atIndex: Int) { + _lock.lock(); defer { _lock.unlock() } // { + switch event { + case .Next(let element): + if _values[atIndex] == nil { + _numberOfValues += 1 + } + + _values[atIndex] = element + + if _numberOfValues < _parent._count { + let numberOfOthersThatAreDone = self._numberOfDone - (_isDone[atIndex] ? 1 : 0) + if numberOfOthersThatAreDone == self._parent._count - 1 { + forwardOn(.Completed) + dispose() + } + return + } + + do { + let result = try _parent._resultSelector(_values.map { $0! }) + forwardOn(.Next(result)) + } + catch let error { + forwardOn(.Error(error)) + dispose() + } + + case .Error(let error): + forwardOn(.Error(error)) + dispose() + case .Completed: + if _isDone[atIndex] { + return + } + + _isDone[atIndex] = true + _numberOfDone += 1 + + if _numberOfDone == self._parent._count { + forwardOn(.Completed) + dispose() + } + else { + _subscriptions[atIndex].dispose() + } + } + // } + } + + func run() -> Disposable { + var j = 0 + for i in _parent._sources.startIndex ..< _parent._sources.endIndex { + let index = j + let source = _parent._sources[i].asObservable() + _subscriptions[j].disposable = source.subscribe(AnyObserver { event in + self.on(event, atIndex: index) + }) + + j += 1 + } + + return CompositeDisposable(disposables: _subscriptions.map { $0 }) + } +} + +class CombineLatestCollectionType : Producer { + typealias ResultSelector = [C.Generator.Element.E] throws -> R + + let _sources: C + let _resultSelector: ResultSelector + let _count: Int + + init(sources: C, resultSelector: ResultSelector) { + _sources = sources + _resultSelector = resultSelector + _count = Int(self._sources.count.toIntMax()) + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestCollectionTypeSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift new file mode 100644 index 00000000000..5d5ea47aafc --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift @@ -0,0 +1,724 @@ +// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project +// +// CombineLatest+arity.swift +// RxSwift +// +// Created by Krunoslav Zaher on 4/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + + +// 2 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, resultSelector: (O1.E, O2.E) throws -> E) + -> Observable { + return CombineLatest2( + source1: source1.asObservable(), source2: source2.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink2_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest2 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 2, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2) + } +} + +class CombineLatest2 : Producer { + typealias ResultSelector = (E1, E2) throws -> R + + let _source1: Observable + let _source2: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink2_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 3 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, _ source3: O3, resultSelector: (O1.E, O2.E, O3.E) throws -> E) + -> Observable { + return CombineLatest3( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink3_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest3 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 3, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + subscription3.disposable = _parent._source3.subscribe(observer3) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3) + } +} + +class CombineLatest3 : Producer { + typealias ResultSelector = (E1, E2, E3) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink3_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 4 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: (O1.E, O2.E, O3.E, O4.E) throws -> E) + -> Observable { + return CombineLatest4( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink4_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest4 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 4, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + subscription3.disposable = _parent._source3.subscribe(observer3) + subscription4.disposable = _parent._source4.subscribe(observer4) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4) + } +} + +class CombineLatest4 : Producer { + typealias ResultSelector = (E1, E2, E3, E4) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink4_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 5 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) + -> Observable { + return CombineLatest5( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink5_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest5 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 5, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + subscription3.disposable = _parent._source3.subscribe(observer3) + subscription4.disposable = _parent._source4.subscribe(observer4) + subscription5.disposable = _parent._source5.subscribe(observer5) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5) + } +} + +class CombineLatest5 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink5_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 6 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) + -> Observable { + return CombineLatest6( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink6_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest6 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + var _latestElement6: E6! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 6, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + let observer6 = CombineLatestObserver(lock: _lock, parent: self, index: 5, setLatestValue: { (e: E6) -> Void in self._latestElement6 = e }, this: subscription6) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + subscription3.disposable = _parent._source3.subscribe(observer3) + subscription4.disposable = _parent._source4.subscribe(observer4) + subscription5.disposable = _parent._source5.subscribe(observer5) + subscription6.disposable = _parent._source6.subscribe(observer6) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5, _latestElement6) + } +} + +class CombineLatest6 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + let _source6: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + _source6 = source6 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink6_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 7 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) + -> Observable { + return CombineLatest7( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink7_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest7 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + var _latestElement6: E6! = nil + var _latestElement7: E7! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 7, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + let observer6 = CombineLatestObserver(lock: _lock, parent: self, index: 5, setLatestValue: { (e: E6) -> Void in self._latestElement6 = e }, this: subscription6) + let observer7 = CombineLatestObserver(lock: _lock, parent: self, index: 6, setLatestValue: { (e: E7) -> Void in self._latestElement7 = e }, this: subscription7) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + subscription3.disposable = _parent._source3.subscribe(observer3) + subscription4.disposable = _parent._source4.subscribe(observer4) + subscription5.disposable = _parent._source5.subscribe(observer5) + subscription6.disposable = _parent._source6.subscribe(observer6) + subscription7.disposable = _parent._source7.subscribe(observer7) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5, _latestElement6, _latestElement7) + } +} + +class CombineLatest7 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + let _source6: Observable + let _source7: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + _source6 = source6 + _source7 = source7 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink7_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 8 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func combineLatest + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) + -> Observable { + return CombineLatest8( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), source8: source8.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink8_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest8 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + var _latestElement6: E6! = nil + var _latestElement7: E7! = nil + var _latestElement8: E8! = nil + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 8, observer: observer) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + let subscription8 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + let observer6 = CombineLatestObserver(lock: _lock, parent: self, index: 5, setLatestValue: { (e: E6) -> Void in self._latestElement6 = e }, this: subscription6) + let observer7 = CombineLatestObserver(lock: _lock, parent: self, index: 6, setLatestValue: { (e: E7) -> Void in self._latestElement7 = e }, this: subscription7) + let observer8 = CombineLatestObserver(lock: _lock, parent: self, index: 7, setLatestValue: { (e: E8) -> Void in self._latestElement8 = e }, this: subscription8) + + subscription1.disposable = _parent._source1.subscribe(observer1) + subscription2.disposable = _parent._source2.subscribe(observer2) + subscription3.disposable = _parent._source3.subscribe(observer3) + subscription4.disposable = _parent._source4.subscribe(observer4) + subscription5.disposable = _parent._source5.subscribe(observer5) + subscription6.disposable = _parent._source6.subscribe(observer6) + subscription7.disposable = _parent._source7.subscribe(observer7) + subscription8.disposable = _parent._source8.subscribe(observer8) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7, + subscription8 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5, _latestElement6, _latestElement7, _latestElement8) + } +} + +class CombineLatest8 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7, E8) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + let _source6: Observable + let _source7: Observable + let _source8: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, source8: Observable, resultSelector: ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + _source6 = source6 + _source7 = source7 + _source8 = source8 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = CombineLatestSink8_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift new file mode 100644 index 00000000000..6662edb8dcc --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift @@ -0,0 +1,134 @@ +// +// CombineLatest.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol CombineLatestProtocol : class { + func next(index: Int) + func fail(error: ErrorType) + func done(index: Int) +} + +class CombineLatestSink + : Sink + , CombineLatestProtocol { + typealias Element = O.E + + let _lock = NSRecursiveLock() + + private let _arity: Int + private var _numberOfValues = 0 + private var _numberOfDone = 0 + private var _hasValue: [Bool] + private var _isDone: [Bool] + + init(arity: Int, observer: O) { + _arity = arity + _hasValue = [Bool](count: arity, repeatedValue: false) + _isDone = [Bool](count: arity, repeatedValue: false) + + super.init(observer: observer) + } + + func getResult() throws -> Element { + abstractMethod() + } + + func next(index: Int) { + if !_hasValue[index] { + _hasValue[index] = true + _numberOfValues += 1 + } + + if _numberOfValues == _arity { + do { + let result = try getResult() + forwardOn(.Next(result)) + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + } + else { + var allOthersDone = true + + for i in 0 ..< _arity { + if i != index && !_isDone[i] { + allOthersDone = false + break + } + } + + if allOthersDone { + forwardOn(.Completed) + dispose() + } + } + } + + func fail(error: ErrorType) { + forwardOn(.Error(error)) + dispose() + } + + func done(index: Int) { + if _isDone[index] { + return + } + + _isDone[index] = true + _numberOfDone += 1 + + if _numberOfDone == _arity { + forwardOn(.Completed) + dispose() + } + } +} + +class CombineLatestObserver + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = ElementType + typealias ValueSetter = (Element) -> Void + + private let _parent: CombineLatestProtocol + + let _lock: NSRecursiveLock + private let _index: Int + private let _this: Disposable + private let _setLatestValue: ValueSetter + + init(lock: NSRecursiveLock, parent: CombineLatestProtocol, index: Int, setLatestValue: ValueSetter, this: Disposable) { + _lock = lock + _parent = parent + _index = index + _this = this + _setLatestValue = setLatestValue + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let value): + _setLatestValue(value) + _parent.next(_index) + case .Error(let error): + _this.dispose() + _parent.fail(error) + case .Completed: + _this.dispose() + _parent.done(_index) + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift new file mode 100644 index 00000000000..85feff2e871 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift @@ -0,0 +1,63 @@ +// +// Concat.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + +class ConcatSink + : TailRecursiveSink + , ObserverType { + typealias Element = O.E + + override init(observer: O) { + super.init(observer: observer) + } + + func on(event: Event){ + switch event { + case .Next: + forwardOn(event) + case .Error: + forwardOn(event) + dispose() + case .Completed: + schedule(.MoveNext) + } + } + + override func subscribeToNext(source: Observable) -> Disposable { + return source.subscribe(self) + } + + override func extract(observable: Observable) -> SequenceGenerator? { + if let source = observable as? Concat { + return (source._sources.generate(), source._count) + } + else { + return nil + } + } +} + +class Concat : Producer { + typealias Element = S.Generator.Element.E + + private let _sources: S + private let _count: IntMax? + + init(sources: S, count: IntMax?) { + _sources = sources + _count = count + } + + override func run(observer: O) -> Disposable { + let sink = ConcatSink(observer: observer) + sink.disposable = sink.run((_sources.generate(), _count)) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift new file mode 100644 index 00000000000..72d4ed29cc4 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift @@ -0,0 +1,96 @@ +// +// ConnectableObservable.swift +// Rx +// +// Created by Krunoslav Zaher on 3/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Represents an observable wrapper that can be connected and disconnected from its underlying observable sequence. +*/ +public class ConnectableObservable + : Observable + , ConnectableObservableType { + + /** + Connects the observable wrapper to its source. All subscribed observers will receive values from the underlying observable sequence as long as the connection is established. + + - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. + */ + public func connect() -> Disposable { + abstractMethod() + } +} + +class Connection : Disposable { + + private var _lock: NSRecursiveLock + // state + private var _parent: ConnectableObservableAdapter? + private var _subscription : Disposable? + + init(parent: ConnectableObservableAdapter, lock: NSRecursiveLock, subscription: Disposable) { + _parent = parent + _subscription = subscription + _lock = lock + } + + func dispose() { + _lock.lock(); defer { _lock.unlock() } // { + guard let parent = _parent else { + return + } + + guard let oldSubscription = _subscription else { + return + } + + _subscription = nil + if parent._connection === self { + parent._connection = nil + } + _parent = nil + + oldSubscription.dispose() + // } + } +} + +class ConnectableObservableAdapter + : ConnectableObservable { + typealias ConnectionType = Connection + + private let _subject: S + private let _source: Observable + + private let _lock = NSRecursiveLock() + + // state + private var _connection: ConnectionType? + + init(source: Observable, subject: S) { + _source = source + _subject = subject + _connection = nil + } + + override func connect() -> Disposable { + return _lock.calculateLocked { + if let connection = _connection { + return connection + } + + let disposable = _source.subscribe(_subject.asObserver()) + let connection = Connection(parent: self, lock: _lock, subscription: disposable) + _connection = connection + return connection + } + } + + override func subscribe(observer: O) -> Disposable { + return _subject.subscribe(observer) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift new file mode 100644 index 00000000000..66b65f25b38 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift @@ -0,0 +1,77 @@ +// +// Debug.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +let dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" + +func logEvent(identifier: String, dateFormat: NSDateFormatter, content: String) { + print("\(dateFormat.stringFromDate(NSDate())): \(identifier) -> \(content)") +} + +class Debug_ : Sink, ObserverType { + typealias Element = O.E + typealias Parent = Debug + + private let _parent: Parent + private let _timestampFormatter = NSDateFormatter() + + init(parent: Parent, observer: O) { + _parent = parent + _timestampFormatter.dateFormat = dateFormat + + logEvent(_parent._identifier, dateFormat: _timestampFormatter, content: "subscribed") + + super.init(observer: observer) + } + + func on(event: Event) { + let maxEventTextLength = 40 + let eventText = "\(event)" + let eventNormalized = eventText.characters.count > maxEventTextLength + ? String(eventText.characters.prefix(maxEventTextLength / 2)) + "..." + String(eventText.characters.suffix(maxEventTextLength / 2)) + : eventText + + logEvent(_parent._identifier, dateFormat: _timestampFormatter, content: "Event \(eventNormalized)") + forwardOn(event) + } + + override func dispose() { + logEvent(_parent._identifier, dateFormat: _timestampFormatter, content: "disposed") + super.dispose() + } +} + +class Debug : Producer { + private let _identifier: String + + private let _source: Observable + + init(source: Observable, identifier: String?, file: String, line: UInt, function: String) { + if let identifier = identifier { + _identifier = identifier + } + else { + let trimmedFile: String + if let lastIndex = file.lastIndexOf("/") { + trimmedFile = file[lastIndex.successor() ..< file.endIndex] + } + else { + trimmedFile = file + } + _identifier = "\(trimmedFile):\(line) (\(function))" + } + _source = source + } + + override func run(observer: O) -> Disposable { + let sink = Debug_(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift new file mode 100644 index 00000000000..900082c4d93 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift @@ -0,0 +1,61 @@ +// +// Deferred.swift +// RxSwift +// +// Created by Krunoslav Zaher on 4/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DeferredSink : Sink, ObserverType { + typealias E = O.E + + private let _observableFactory: () throws -> S + + init(observableFactory: () throws -> S, observer: O) { + _observableFactory = observableFactory + super.init(observer: observer) + } + + func run() -> Disposable { + do { + let result = try _observableFactory() + return result.subscribe(self) + } + catch let e { + forwardOn(.Error(e)) + dispose() + return NopDisposable.instance + } + } + + func on(event: Event) { + forwardOn(event) + + switch event { + case .Next: + break + case .Error: + dispose() + case .Completed: + dispose() + } + } +} + +class Deferred : Producer { + typealias Factory = () throws -> S + + private let _observableFactory : Factory + + init(observableFactory: Factory) { + _observableFactory = observableFactory + } + + override func run(observer: O) -> Disposable { + let sink = DeferredSink(observableFactory: _observableFactory, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift new file mode 100644 index 00000000000..31d7c7c7a0a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift @@ -0,0 +1,52 @@ +// +// DelaySubscription.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DelaySubscriptionSink + : Sink + , ObserverType { + typealias Parent = DelaySubscription + typealias E = O.E + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + forwardOn(event) + if event.isStopEvent { + dispose() + } + } + +} + +class DelaySubscription: Producer { + private let _source: Observable + private let _dueTime: RxTimeInterval + private let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = DelaySubscriptionSink(parent: self, observer: observer) + sink.disposable = _scheduler.scheduleRelative((), dueTime: _dueTime) { _ in + return self._source.subscribe(sink) + } + + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift new file mode 100644 index 00000000000..cff09a898e8 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift @@ -0,0 +1,70 @@ +// +// DistinctUntilChanged.swift +// Rx +// +// Created by Krunoslav Zaher on 3/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DistinctUntilChangedSink: Sink, ObserverType { + typealias E = O.E + + private let _parent: DistinctUntilChanged + private var _currentKey: Key? = nil + + init(parent: DistinctUntilChanged, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + do { + let key = try _parent._selector(value) + var areEqual = false + if let currentKey = _currentKey { + areEqual = try _parent._comparer(currentKey, key) + } + + if areEqual { + return + } + + _currentKey = key + + forwardOn(event) + } + catch let error { + forwardOn(.Error(error)) + dispose() + } + case .Error, .Completed: + forwardOn(event) + dispose() + } + } +} + +class DistinctUntilChanged: Producer { + typealias KeySelector = (Element) throws -> Key + typealias EqualityComparer = (Key, Key) throws -> Bool + + private let _source: Observable + private let _selector: KeySelector + private let _comparer: EqualityComparer + + init(source: Observable, selector: KeySelector, comparer: EqualityComparer) { + _source = source + _selector = selector + _comparer = comparer + } + + override func run(observer: O) -> Disposable { + let sink = DistinctUntilChangedSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift new file mode 100644 index 00000000000..7fc07dcb706 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift @@ -0,0 +1,53 @@ +// +// Do.swift +// Rx +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DoSink : Sink, ObserverType { + typealias Element = O.E + typealias Parent = Do + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + do { + try _parent._eventHandler(event) + forwardOn(event) + if event.isStopEvent { + dispose() + } + } + catch let error { + forwardOn(.Error(error)) + dispose() + } + } +} + +class Do : Producer { + typealias EventHandler = Event throws -> Void + + private let _source: Observable + private let _eventHandler: EventHandler + + init(source: Observable, eventHandler: EventHandler) { + _source = source + _eventHandler = eventHandler + } + + override func run(observer: O) -> Disposable { + let sink = DoSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift new file mode 100644 index 00000000000..158e471572d --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift @@ -0,0 +1,79 @@ +// +// ElementAt.swift +// Rx +// +// Created by Junior B. on 21/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + +class ElementAtSink : Sink, ObserverType { + typealias Parent = ElementAt + + let _parent: Parent + var _i: Int + + init(parent: Parent, observer: O) { + _parent = parent + _i = parent._index + + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(_): + + if (_i == 0) { + forwardOn(event) + forwardOn(.Completed) + self.dispose() + } + + do { + try decrementChecked(&_i) + } catch(let e) { + forwardOn(.Error(e)) + dispose() + return + } + + case .Error(let e): + forwardOn(.Error(e)) + self.dispose() + case .Completed: + if (_parent._throwOnEmpty) { + forwardOn(.Error(RxError.ArgumentOutOfRange)) + } else { + forwardOn(.Completed) + } + + self.dispose() + } + } +} + +class ElementAt : Producer { + + let _source: Observable + let _throwOnEmpty: Bool + let _index: Int + + init(source: Observable, index: Int, throwOnEmpty: Bool) { + if index < 0 { + rxFatalError("index can't be negative") + } + + self._source = source + self._index = index + self._throwOnEmpty = throwOnEmpty + } + + override func run(observer: O) -> Disposable { + let sink = ElementAtSink(parent: self, observer: observer) + sink.disposable = _source.subscribeSafe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift new file mode 100644 index 00000000000..d2ebb1886a6 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift @@ -0,0 +1,16 @@ +// +// Empty.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Empty : Producer { + override func subscribe(observer: O) -> Disposable { + observer.on(.Completed) + return NopDisposable.instance + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift new file mode 100644 index 00000000000..ba0abf940a3 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift @@ -0,0 +1,22 @@ +// +// Error.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Error : Producer { + private let _error: ErrorType + + init(error: ErrorType) { + _error = error + } + + override func subscribe(observer: O) -> Disposable { + observer.on(.Error(_error)) + return NopDisposable.instance + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift new file mode 100644 index 00000000000..43d7a18f6c6 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift @@ -0,0 +1,60 @@ +// +// Filter.swift +// Rx +// +// Created by Krunoslav Zaher on 2/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class FilterSink: Sink, ObserverType { + typealias Predicate = (Element) throws -> Bool + typealias Element = O.E + + typealias Parent = Filter + + private let _predicate: Predicate + + init(predicate: Predicate, observer: O) { + _predicate = predicate + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + do { + let satisfies = try _predicate(value) + if satisfies { + forwardOn(.Next(value)) + } + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + case .Completed, .Error: + forwardOn(event) + dispose() + } + } +} + +class Filter : Producer { + typealias Predicate = (Element) throws -> Bool + + private let _source: Observable + private let _predicate: Predicate + + init(source: Observable, predicate: Predicate) { + _source = source + _predicate = predicate + } + + override func run(observer: O) -> Disposable { + let sink = FilterSink(predicate: _predicate, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift new file mode 100644 index 00000000000..d60a9b7431c --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift @@ -0,0 +1,71 @@ +// +// Generate.swift +// Rx +// +// Created by Krunoslav Zaher on 9/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class GenerateSink : Sink { + typealias Parent = Generate + + private let _parent: Parent + + private var _state: S + + init(parent: Parent, observer: O) { + _parent = parent + _state = parent._initialState + super.init(observer: observer) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive(true) { (isFirst, recurse) -> Void in + do { + if !isFirst { + self._state = try self._parent._iterate(self._state) + } + + if try self._parent._condition(self._state) { + let result = try self._parent._resultSelector(self._state) + self.forwardOn(.Next(result)) + + recurse(false) + } + else { + self.forwardOn(.Completed) + self.dispose() + } + } + catch let error { + self.forwardOn(.Error(error)) + self.dispose() + } + } + } +} + +class Generate : Producer { + private let _initialState: S + private let _condition: S throws -> Bool + private let _iterate: S throws -> S + private let _resultSelector: S throws -> E + private let _scheduler: ImmediateSchedulerType + + init(initialState: S, condition: S throws -> Bool, iterate: S throws -> S, resultSelector: S throws -> E, scheduler: ImmediateSchedulerType) { + _initialState = initialState + _condition = condition + _iterate = iterate + _resultSelector = resultSelector + _scheduler = scheduler + super.init() + } + + override func run(observer: O) -> Disposable { + let sink = GenerateSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift new file mode 100644 index 00000000000..d116d641582 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift @@ -0,0 +1,61 @@ +// +// Just.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class JustScheduledSink : Sink { + typealias Parent = JustScheduled + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + let scheduler = _parent._scheduler + return scheduler.schedule(_parent._element) { element in + self.forwardOn(.Next(element)) + return scheduler.schedule(()) { _ in + self.forwardOn(.Completed) + return NopDisposable.instance + } + } + } +} + +class JustScheduled : Producer { + private let _scheduler: ImmediateSchedulerType + private let _element: Element + + init(element: Element, scheduler: ImmediateSchedulerType) { + _scheduler = scheduler + _element = element + } + + override func subscribe(observer: O) -> Disposable { + let sink = JustScheduledSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + +class Just : Producer { + private let _element: Element + + init(element: Element) { + _element = element + } + + override func subscribe(observer: O) -> Disposable { + observer.on(.Next(_element)) + observer.on(.Completed) + return NopDisposable.instance + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift new file mode 100644 index 00000000000..54a3404dc52 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift @@ -0,0 +1,140 @@ +// +// Map.swift +// Rx +// +// Created by Krunoslav Zaher on 3/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class MapSink : Sink, ObserverType { + typealias Selector = (SourceType) throws -> ResultType + + typealias ResultType = O.E + typealias Element = SourceType + + private let _selector: Selector + + init(selector: Selector, observer: O) { + _selector = selector + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let element): + do { + let mappedElement = try _selector(element) + forwardOn(.Next(mappedElement)) + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + case .Error(let error): + forwardOn(.Error(error)) + dispose() + case .Completed: + forwardOn(.Completed) + dispose() + } + } +} + +class MapWithIndexSink : Sink, ObserverType { + typealias Selector = (SourceType, Int) throws -> ResultType + + typealias ResultType = O.E + typealias Element = SourceType + typealias Parent = MapWithIndex + + private let _selector: Selector + + private var _index = 0 + + init(selector: Selector, observer: O) { + _selector = selector + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let element): + do { + let mappedElement = try _selector(element, try incrementChecked(&_index)) + forwardOn(.Next(mappedElement)) + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + case .Error(let error): + forwardOn(.Error(error)) + dispose() + case .Completed: + forwardOn(.Completed) + dispose() + } + } +} + +class MapWithIndex : Producer { + typealias Selector = (SourceType, Int) throws -> ResultType + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: Selector) { + _source = source + _selector = selector + } + + override func run(observer: O) -> Disposable { + let sink = MapWithIndexSink(selector: _selector, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} + +#if TRACE_RESOURCES +public var numberOfMapOperators: Int32 = 0 +#endif + +class Map: Producer { + typealias Selector = (SourceType) throws -> ResultType + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: Selector) { + _source = source + _selector = selector + +#if TRACE_RESOURCES + AtomicIncrement(&numberOfMapOperators) +#endif + } + + override func composeMap(selector: ResultType throws -> R) -> Observable { + let originalSelector = _selector + return Map(source: _source, selector: { (s: SourceType) throws -> R in + let r: ResultType = try originalSelector(s) + return try selector(r) + }) + } + + override func run(observer: O) -> Disposable { + let sink = MapSink(selector: _selector, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } + + #if TRACE_RESOURCES + deinit { + AtomicDecrement(&numberOfMapOperators) + } + #endif +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift new file mode 100644 index 00000000000..0bba8ca7317 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift @@ -0,0 +1,423 @@ +// +// Merge.swift +// Rx +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: Limited concurrency version + +class MergeLimitedSinkIter + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = O.E + typealias DisposeKey = Bag.KeyType + typealias Parent = MergeLimitedSink + + private let _parent: Parent + private let _disposeKey: DisposeKey + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent, disposeKey: DisposeKey) { + _parent = parent + _disposeKey = disposeKey + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: + _parent.forwardOn(event) + case .Error: + _parent.forwardOn(event) + _parent.dispose() + case .Completed: + _parent._group.removeDisposable(_disposeKey) + if let next = _parent._queue.dequeue() { + _parent.subscribe(next, group: _parent._group) + } + else { + _parent._activeCount = _parent._activeCount - 1 + + if _parent._stopped && _parent._activeCount == 0 { + _parent.forwardOn(.Completed) + _parent.dispose() + } + } + } + } +} + +class MergeLimitedSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = S + typealias QueueType = Queue + + private let _maxConcurrent: Int + + let _lock = NSRecursiveLock() + + // state + private var _stopped = false + private var _activeCount = 0 + private var _queue = QueueType(capacity: 2) + + private let _sourceSubscription = SingleAssignmentDisposable() + private let _group = CompositeDisposable() + + init(maxConcurrent: Int, observer: O) { + _maxConcurrent = maxConcurrent + + _group.addDisposable(_sourceSubscription) + super.init(observer: observer) + } + + func run(source: Observable) -> Disposable { + _group.addDisposable(_sourceSubscription) + + let disposable = source.subscribe(self) + _sourceSubscription.disposable = disposable + return _group + } + + func subscribe(innerSource: E, group: CompositeDisposable) { + let subscription = SingleAssignmentDisposable() + + let key = group.addDisposable(subscription) + + if let key = key { + let observer = MergeLimitedSinkIter(parent: self, disposeKey: key) + + let disposable = innerSource.asObservable().subscribe(observer) + subscription.disposable = disposable + } + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let value): + let subscribe: Bool + if _activeCount < _maxConcurrent { + _activeCount += 1 + subscribe = true + } + else { + _queue.enqueue(value) + subscribe = false + } + + if subscribe { + self.subscribe(value, group: _group) + } + case .Error(let error): + forwardOn(.Error(error)) + dispose() + case .Completed: + if _activeCount == 0 { + forwardOn(.Completed) + dispose() + } + else { + _sourceSubscription.dispose() + } + + _stopped = true + } + } +} + +class MergeLimited : Producer { + private let _source: Observable + private let _maxConcurrent: Int + + init(source: Observable, maxConcurrent: Int) { + _source = source + _maxConcurrent = maxConcurrent + } + + override func run(observer: O) -> Disposable { + let sink = MergeLimitedSink(maxConcurrent: _maxConcurrent, observer: observer) + sink.disposable = sink.run(_source) + return sink + } +} + +// MARK: Merge + +final class MergeBasicSink : MergeSink { + override init(observer: O) { + super.init(observer: observer) + } + + override func performMap(element: S) throws -> S { + return element + } +} + +// MARK: flatMap + +final class FlatMapSink : MergeSink { + typealias Selector = (SourceType) throws -> S + + private let _selector: Selector + + init(selector: Selector, observer: O) { + _selector = selector + super.init(observer: observer) + } + + override func performMap(element: SourceType) throws -> S { + return try _selector(element) + } +} + +final class FlatMapWithIndexSink : MergeSink { + typealias Selector = (SourceType, Int) throws -> S + + private var _index = 0 + private let _selector: Selector + + init(selector: Selector, observer: O) { + _selector = selector + super.init(observer: observer) + } + + override func performMap(element: SourceType) throws -> S { + return try _selector(element, try incrementChecked(&_index)) + } +} + +// MARK: FlatMapFirst + +final class FlatMapFirstSink : MergeSink { + typealias Selector = (SourceType) throws -> S + + private let _selector: Selector + + override var subscribeNext: Bool { + return _group.count == MergeNoIterators + } + + init(selector: Selector, observer: O) { + _selector = selector + super.init(observer: observer) + } + + override func performMap(element: SourceType) throws -> S { + return try _selector(element) + } +} + +// It's value is one because initial source subscription is always in CompositeDisposable +private let MergeNoIterators = 1 + +class MergeSinkIter : ObserverType { + typealias Parent = MergeSink + typealias DisposeKey = CompositeDisposable.DisposeKey + typealias E = O.E + + private let _parent: Parent + private let _disposeKey: DisposeKey + + init(parent: Parent, disposeKey: DisposeKey) { + _parent = parent + _disposeKey = disposeKey + } + + func on(event: Event) { + switch event { + case .Next(let value): + _parent._lock.lock(); defer { _parent._lock.unlock() } // lock { + _parent.forwardOn(.Next(value)) + // } + case .Error(let error): + _parent._lock.lock(); defer { _parent._lock.unlock() } // lock { + _parent.forwardOn(.Error(error)) + _parent.dispose() + // } + case .Completed: + _parent._group.removeDisposable(_disposeKey) + // If this has returned true that means that `Completed` should be sent. + // In case there is a race who will sent first completed, + // lock will sort it out. When first Completed message is sent + // it will set observer to nil, and thus prevent further complete messages + // to be sent, and thus preserving the sequence grammar. + if _parent._stopped && _parent._group.count == MergeNoIterators { + _parent._lock.lock(); defer { _parent._lock.unlock() } // lock { + _parent.forwardOn(.Completed) + _parent.dispose() + // } + } + } + } +} + + +class MergeSink + : Sink + , ObserverType { + typealias ResultType = O.E + typealias Element = SourceType + + private let _lock = NSRecursiveLock() + + private var subscribeNext: Bool { + return true + } + + // state + private let _group = CompositeDisposable() + private let _sourceSubscription = SingleAssignmentDisposable() + + private var _stopped = false + + override init(observer: O) { + super.init(observer: observer) + } + + func performMap(element: SourceType) throws -> S { + abstractMethod() + } + + func on(event: Event) { + switch event { + case .Next(let element): + if !subscribeNext { + return + } + do { + let value = try performMap(element) + subscribeInner(value.asObservable()) + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + case .Error(let error): + _lock.lock(); defer { _lock.unlock() } // lock { + forwardOn(.Error(error)) + dispose() + // } + case .Completed: + _lock.lock(); defer { _lock.unlock() } // lock { + _stopped = true + if _group.count == MergeNoIterators { + forwardOn(.Completed) + dispose() + } + else { + _sourceSubscription.dispose() + } + //} + } + } + + func subscribeInner(source: Observable) { + let iterDisposable = SingleAssignmentDisposable() + if let disposeKey = _group.addDisposable(iterDisposable) { + let iter = MergeSinkIter(parent: self, disposeKey: disposeKey) + let subscription = source.subscribe(iter) + iterDisposable.disposable = subscription + } + } + + func run(source: Observable) -> Disposable { + _group.addDisposable(_sourceSubscription) + + let subscription = source.subscribe(self) + _sourceSubscription.disposable = subscription + + return _group + } +} + +// MARK: Producers + +final class FlatMap: Producer { + typealias Selector = (SourceType) throws -> S + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: Selector) { + _source = source + _selector = selector + } + + override func run(observer: O) -> Disposable { + let sink = FlatMapSink(selector: _selector, observer: observer) + sink.disposable = sink.run(_source) + return sink + } +} + +final class FlatMapWithIndex: Producer { + typealias Selector = (SourceType, Int) throws -> S + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: Selector) { + _source = source + _selector = selector + } + + override func run(observer: O) -> Disposable { + let sink = FlatMapWithIndexSink(selector: _selector, observer: observer) + sink.disposable = sink.run(_source) + return sink + } + +} + +final class FlatMapFirst: Producer { + typealias Selector = (SourceType) throws -> S + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: Selector) { + _source = source + _selector = selector + } + + override func run(observer: O) -> Disposable { + let sink = FlatMapFirstSink(selector: _selector, observer: observer) + sink.disposable = sink.run(_source) + return sink + } +} + +final class Merge : Producer { + private let _source: Observable + + init(source: Observable) { + _source = source + } + + override func run(observer: O) -> Disposable { + let sink = MergeBasicSink(observer: observer) + sink.disposable = sink.run(_source) + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift new file mode 100644 index 00000000000..f91a3a11e1b --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift @@ -0,0 +1,71 @@ +// +// Multicast.swift +// Rx +// +// Created by Krunoslav Zaher on 2/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class MulticastSink: Sink, ObserverType { + typealias Element = O.E + typealias ResultType = Element + typealias MutlicastType = Multicast + + private let _parent: MutlicastType + + init(parent: MutlicastType, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + do { + let subject = try _parent._subjectSelector() + let connectable = ConnectableObservableAdapter(source: _parent._source, subject: subject) + + let observable = try _parent._selector(connectable) + + let subscription = observable.subscribe(self) + let connection = connectable.connect() + + return BinaryDisposable(subscription, connection) + } + catch let e { + forwardOn(.Error(e)) + dispose() + return NopDisposable.instance + } + } + + func on(event: Event) { + forwardOn(event) + switch event { + case .Next: break + case .Error, .Completed: + dispose() + } + } +} + +class Multicast: Producer { + typealias SubjectSelectorType = () throws -> S + typealias SelectorType = (Observable) throws -> Observable + + private let _source: Observable + private let _subjectSelector: SubjectSelectorType + private let _selector: SelectorType + + init(source: Observable, subjectSelector: SubjectSelectorType, selector: SelectorType) { + _source = source + _subjectSelector = subjectSelector + _selector = selector + } + + override func run(observer: O) -> Disposable { + let sink = MulticastSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift new file mode 100644 index 00000000000..1b20b277877 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift @@ -0,0 +1,15 @@ +// +// Never.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Never : Producer { + override func subscribe(observer: O) -> Disposable { + return NopDisposable.instance + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift new file mode 100644 index 00000000000..2c458ff405a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift @@ -0,0 +1,133 @@ +// +// ObserveOn.swift +// RxSwift +// +// Created by Krunoslav Zaher on 7/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ObserveOn : Producer { + let scheduler: ImmediateSchedulerType + let source: Observable + + init(source: Observable, scheduler: ImmediateSchedulerType) { + self.scheduler = scheduler + self.source = source + +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) +#endif + } + + override func run(observer: O) -> Disposable { + let sink = ObserveOnSink(scheduler: scheduler, observer: observer) + sink._subscription.disposable = source.subscribe(sink) + return sink + } + +#if TRACE_RESOURCES + deinit { + AtomicDecrement(&resourceCount) + } +#endif +} + +enum ObserveOnState : Int32 { + // pump is not running + case Stopped = 0 + // pump is running + case Running = 1 +} + +class ObserveOnSink : ObserverBase { + typealias E = O.E + + let _scheduler: ImmediateSchedulerType + + var _lock = SpinLock() + + // state + var _state = ObserveOnState.Stopped + var _observer: O? + var _queue = Queue>(capacity: 10) + + let _scheduleDisposable = SerialDisposable() + let _subscription = SingleAssignmentDisposable() + + init(scheduler: ImmediateSchedulerType, observer: O) { + _scheduler = scheduler + _observer = observer + } + + override func onCore(event: Event) { + let shouldStart = _lock.calculateLocked { () -> Bool in + self._queue.enqueue(event) + + switch self._state { + case .Stopped: + self._state = .Running + return true + case .Running: + return false + } + } + + if shouldStart { + _scheduleDisposable.disposable = self._scheduler.scheduleRecursive((), action: self.run) + } + } + + func run(state: Void, recurse: Void -> Void) { + let (nextEvent, observer) = self._lock.calculateLocked { () -> (Event?, O?) in + if self._queue.count > 0 { + return (self._queue.dequeue(), self._observer) + } + else { + self._state = .Stopped + return (nil, self._observer) + } + } + + if let nextEvent = nextEvent { + observer?.on(nextEvent) + if nextEvent.isStopEvent { + dispose() + } + } + else { + return + } + + let shouldContinue = _shouldContinue_synchronized() + + if shouldContinue { + recurse() + } + } + + func _shouldContinue_synchronized() -> Bool { + _lock.lock(); defer { _lock.unlock() } // { + if self._queue.count > 0 { + return true + } + else { + self._state = .Stopped + return false + } + // } + } + + override func dispose() { + super.dispose() + + _subscription.dispose() + _scheduleDisposable.dispose() + + _lock.lock(); defer { _lock.unlock() } // { + _observer = nil + + // } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift new file mode 100644 index 00000000000..714b1304b26 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift @@ -0,0 +1,81 @@ +// +// ObserveOnSerialDispatchQueue.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if TRACE_RESOURCES +/** +Counts number of `SerialDispatchQueueObservables`. + +Purposed for unit tests. +*/ +public var numberOfSerialDispatchQueueObservables: AtomicInt = 0 +#endif + +class ObserveOnSerialDispatchQueueSink : ObserverBase { + let scheduler: SerialDispatchQueueScheduler + let observer: O + + let subscription = SingleAssignmentDisposable() + + var cachedScheduleLambda: ((ObserveOnSerialDispatchQueueSink, Event) -> Disposable)! + + init(scheduler: SerialDispatchQueueScheduler, observer: O) { + self.scheduler = scheduler + self.observer = observer + super.init() + + cachedScheduleLambda = { sink, event in + sink.observer.on(event) + + if event.isStopEvent { + sink.dispose() + } + + return NopDisposable.instance + } + } + + override func onCore(event: Event) { + self.scheduler.schedule((self, event), action: cachedScheduleLambda) + } + + override func dispose() { + super.dispose() + + subscription.dispose() + } +} + +class ObserveOnSerialDispatchQueue : Producer { + let scheduler: SerialDispatchQueueScheduler + let source: Observable + + init(source: Observable, scheduler: SerialDispatchQueueScheduler) { + self.scheduler = scheduler + self.source = source + +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) + AtomicIncrement(&numberOfSerialDispatchQueueObservables) +#endif + } + + override func run(observer: O) -> Disposable { + let sink = ObserveOnSerialDispatchQueueSink(scheduler: scheduler, observer: observer) + sink.subscription.disposable = source.subscribe(sink) + return sink + } + +#if TRACE_RESOURCES + deinit { + AtomicDecrement(&resourceCount) + AtomicDecrement(&numberOfSerialDispatchQueueObservables) + } +#endif +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift new file mode 100644 index 00000000000..84048e4bf53 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift @@ -0,0 +1,30 @@ +// +// Producer.swift +// Rx +// +// Created by Krunoslav Zaher on 2/20/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Producer : Observable { + override init() { + super.init() + } + + override func subscribe(observer: O) -> Disposable { + if !CurrentThreadScheduler.isScheduleRequired { + return run(observer) + } + else { + return CurrentThreadScheduler.instance.schedule(()) { _ in + return self.run(observer) + } + } + } + + func run(observer: O) -> Disposable { + abstractMethod() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift new file mode 100644 index 00000000000..d01da11a2ea --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift @@ -0,0 +1,59 @@ +// +// Range.swift +// Rx +// +// Created by Krunoslav Zaher on 9/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RangeProducer : Producer { + private let _start: E + private let _count: E + private let _scheduler: ImmediateSchedulerType + + init(start: E, count: E, scheduler: ImmediateSchedulerType) { + if count < 0 { + rxFatalError("count can't be negative") + } + + if start &+ (count - 1) < start { + rxFatalError("overflow of count") + } + + _start = start + _count = count + _scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = RangeSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + +class RangeSink : Sink { + typealias Parent = RangeProducer + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive(0 as O.E) { i, recurse in + if i < self._parent._count { + self.forwardOn(.Next(self._parent._start + i)) + recurse(i + 1) + } + else { + self.forwardOn(.Completed) + self.dispose() + } + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift new file mode 100644 index 00000000000..7709b431a2c --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift @@ -0,0 +1,74 @@ +// +// Reduce.swift +// Rx +// +// Created by Krunoslav Zaher on 4/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ReduceSink : Sink, ObserverType { + typealias ResultType = O.E + typealias Parent = Reduce + + private let _parent: Parent + private var _accumulation: AccumulateType + + init(parent: Parent, observer: O) { + _parent = parent + _accumulation = parent._seed + + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + do { + _accumulation = try _parent._accumulator(_accumulation, value) + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + case .Error(let e): + forwardOn(.Error(e)) + dispose() + case .Completed: + do { + let result = try _parent._mapResult(_accumulation) + forwardOn(.Next(result)) + forwardOn(.Completed) + dispose() + } + catch let e { + forwardOn(.Error(e)) + dispose() + } + } + } +} + +class Reduce : Producer { + typealias AccumulatorType = (AccumulateType, SourceType) throws -> AccumulateType + typealias ResultSelectorType = (AccumulateType) throws -> ResultType + + private let _source: Observable + private let _seed: AccumulateType + private let _accumulator: AccumulatorType + private let _mapResult: ResultSelectorType + + init(source: Observable, seed: AccumulateType, accumulator: AccumulatorType, mapResult: ResultSelectorType) { + _source = source + _seed = seed + _accumulator = accumulator + _mapResult = mapResult + } + + override func run(observer: O) -> Disposable { + let sink = ReduceSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift new file mode 100644 index 00000000000..e1450381dc8 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift @@ -0,0 +1,84 @@ +// +// RefCount.swift +// Rx +// +// Created by Krunoslav Zaher on 3/5/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RefCountSink + : Sink + , ObserverType { + typealias Element = O.E + typealias Parent = RefCount + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + let subscription = _parent._source.subscribeSafe(self) + + _parent._lock.lock(); defer { _parent._lock.unlock() } // { + if _parent._count == 0 { + _parent._count = 1 + _parent._connectableSubscription = _parent._source.connect() + } + else { + _parent._count = _parent._count + 1 + } + // } + + return AnonymousDisposable { + subscription.dispose() + self._parent._lock.lock(); defer { self._parent._lock.unlock() } // { + if self._parent._count == 1 { + self._parent._connectableSubscription!.dispose() + self._parent._count = 0 + self._parent._connectableSubscription = nil + } + else if self._parent._count > 1 { + self._parent._count = self._parent._count - 1 + } + else { + rxFatalError("Something went wrong with RefCount disposing mechanism") + } + // } + } + } + + func on(event: Event) { + switch event { + case .Next: + forwardOn(event) + case .Error, .Completed: + forwardOn(event) + dispose() + } + } +} + +class RefCount: Producer { + private let _lock = NSRecursiveLock() + + // state + private var _count = 0 + private var _connectableSubscription = nil as Disposable? + + private let _source: CO + + init(source: CO) { + _source = source + } + + override func run(observer: O) -> Disposable { + let sink = RefCountSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift new file mode 100644 index 00000000000..0b24510c3ef --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift @@ -0,0 +1,44 @@ +// +// Repeat.swift +// RxExample +// +// Created by Krunoslav Zaher on 9/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RepeatElement : Producer { + private let _element: Element + private let _scheduler: ImmediateSchedulerType + + init(element: Element, scheduler: ImmediateSchedulerType) { + _element = element + _scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = RepeatElementSink(parent: self, observer: observer) + sink.disposable = sink.run() + + return sink + } +} + +class RepeatElementSink : Sink { + typealias Parent = RepeatElement + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive(_parent._element) { e, recurse in + self.forwardOn(.Next(e)) + recurse(e) + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift new file mode 100644 index 00000000000..0bbb08cf1c5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift @@ -0,0 +1,150 @@ +// +// RetryWhen.swift +// Rx +// +// Created by Junior B. on 06/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RetryTriggerSink + : ObserverType { + typealias E = TriggerObservable.E + + typealias Parent = RetryWhenSequenceSinkIter + + private let _parent: Parent + + init(parent: Parent) { + _parent = parent + } + + func on(event: Event) { + switch event { + case .Next: + _parent._parent._lastError = nil + _parent._parent.schedule(.MoveNext) + case .Error(let e): + _parent._parent.forwardOn(.Error(e)) + _parent._parent.dispose() + case .Completed: + _parent._parent.forwardOn(.Completed) + _parent._parent.dispose() + } + } +} + +class RetryWhenSequenceSinkIter + : SingleAssignmentDisposable + , ObserverType { + typealias E = O.E + typealias Parent = RetryWhenSequenceSink + + private let _parent: Parent + private let _errorHandlerSubscription = SingleAssignmentDisposable() + + init(parent: Parent) { + _parent = parent + } + + func on(event: Event) { + switch event { + case .Next: + _parent.forwardOn(event) + case .Error(let error): + _parent._lastError = error + + if let failedWith = error as? Error { + // dispose current subscription + super.dispose() + + let errorHandlerSubscription = _parent._notifier.subscribe(RetryTriggerSink(parent: self)) + _errorHandlerSubscription.disposable = errorHandlerSubscription + _parent._errorSubject.on(.Next(failedWith)) + } + else { + _parent.forwardOn(.Error(error)) + _parent.dispose() + } + case .Completed: + _parent.forwardOn(event) + _parent.dispose() + } + } + + override func dispose() { + super.dispose() + _errorHandlerSubscription.dispose() + } +} + +class RetryWhenSequenceSink + : TailRecursiveSink { + typealias Element = O.E + typealias Parent = RetryWhenSequence + + let _lock = NSRecursiveLock() + + private let _parent: Parent + + private var _lastError: ErrorType? + private let _errorSubject = PublishSubject() + private let _handler: Observable + private let _notifier = PublishSubject() + + init(parent: Parent, observer: O) { + _parent = parent + _handler = parent._notificationHandler(_errorSubject).asObservable() + super.init(observer: observer) + } + + override func done() { + if let lastError = _lastError { + forwardOn(.Error(lastError)) + _lastError = nil + } + else { + forwardOn(.Completed) + } + + dispose() + } + + override func extract(observable: Observable) -> SequenceGenerator? { + // It is important to always return `nil` here because there are sideffects in the `run` method + // that are dependant on particular `retryWhen` operator so single operator stack can't be reused in this + // case. + return nil + } + + override func subscribeToNext(source: Observable) -> Disposable { + let iter = RetryWhenSequenceSinkIter(parent: self) + iter.disposable = source.subscribe(iter) + return iter + } + + override func run(sources: SequenceGenerator) -> Disposable { + let triggerSubscription = _handler.subscribe(_notifier.asObserver()) + let superSubscription = super.run(sources) + return StableCompositeDisposable.create(superSubscription, triggerSubscription) + } +} + +class RetryWhenSequence : Producer { + typealias Element = S.Generator.Element.E + + private let _sources: S + private let _notificationHandler: Observable -> TriggerObservable + + init(sources: S, notificationHandler: Observable -> TriggerObservable) { + _sources = sources + _notificationHandler = notificationHandler + } + + override func run(observer: O) -> Disposable { + let sink = RetryWhenSequenceSink(parent: self, observer: observer) + sink.disposable = sink.run((self._sources.generate(), nil)) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift new file mode 100644 index 00000000000..ef13f13ff70 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift @@ -0,0 +1,129 @@ +// +// Sample.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SamplerSink + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = SampleType + + typealias Parent = SampleSequenceSink + + private let _parent: Parent + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent) { + _parent = parent + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: + if let element = _parent._element { + if _parent._parent._onlyNew { + _parent._element = nil + } + + _parent.forwardOn(.Next(element)) + } + + if _parent._atEnd { + _parent.forwardOn(.Completed) + _parent.dispose() + } + case .Error(let e): + _parent.forwardOn(.Error(e)) + _parent.dispose() + case .Completed: + if let element = _parent._element { + _parent._element = nil + _parent.forwardOn(.Next(element)) + } + if _parent._atEnd { + _parent.forwardOn(.Completed) + _parent.dispose() + } + } + } +} + +class SampleSequenceSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = O.E + typealias Parent = Sample + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + private var _element = nil as Element? + private var _atEnd = false + + private let _sourceSubscription = SingleAssignmentDisposable() + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + _sourceSubscription.disposable = _parent._source.subscribe(self) + let samplerSubscription = _parent._sampler.subscribe(SamplerSink(parent: self)) + + return StableCompositeDisposable.create(_sourceSubscription, samplerSubscription) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let element): + _element = element + case .Error: + forwardOn(event) + dispose() + case .Completed: + _atEnd = true + _sourceSubscription.dispose() + } + } + +} + +class Sample : Producer { + private let _source: Observable + private let _sampler: Observable + private let _onlyNew: Bool + + init(source: Observable, sampler: Observable, onlyNew: Bool) { + _source = source + _sampler = sampler + _onlyNew = onlyNew + } + + override func run(observer: O) -> Disposable { + let sink = SampleSequenceSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift new file mode 100644 index 00000000000..bc0adc87988 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift @@ -0,0 +1,64 @@ +// +// Scan.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ScanSink : Sink, ObserverType { + typealias Parent = Scan + typealias E = ElementType + + private let _parent: Parent + private var _accumulate: Accumulate + + init(parent: Parent, observer: O) { + _parent = parent + _accumulate = parent._seed + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let element): + do { + _accumulate = try _parent._accumulator(_accumulate, element) + forwardOn(.Next(_accumulate)) + } + catch let error { + forwardOn(.Error(error)) + dispose() + } + case .Error(let error): + forwardOn(.Error(error)) + dispose() + case .Completed: + forwardOn(.Completed) + dispose() + } + } + +} + +class Scan: Producer { + typealias Accumulator = (Accumulate, Element) throws -> Accumulate + + private let _source: Observable + private let _seed: Accumulate + private let _accumulator: Accumulator + + init(source: Observable, seed: Accumulate, accumulator: Accumulator) { + _source = source + _seed = seed + _accumulator = accumulator + } + + override func run(observer: O) -> Disposable { + let sink = ScanSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift new file mode 100644 index 00000000000..0a31d9291da --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift @@ -0,0 +1,58 @@ +// +// Sequence.swift +// Rx +// +// Created by Krunoslav Zaher on 11/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SequenceSink : Sink { + typealias Parent = Sequence + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + return _parent._scheduler!.scheduleRecursive((0, _parent._elements)) { (state, recurse) in + if state.0 < state.1.count { + self.forwardOn(.Next(state.1[state.0])) + recurse((state.0 + 1, state.1)) + } + else { + self.forwardOn(.Completed) + } + } + } +} + +class Sequence : Producer { + private let _elements: [E] + private let _scheduler: ImmediateSchedulerType? + + init(elements: [E], scheduler: ImmediateSchedulerType?) { + _elements = elements + _scheduler = scheduler + } + + override func subscribe(observer: O) -> Disposable { + // optimized version without scheduler + guard _scheduler != nil else { + for element in _elements { + observer.on(.Next(element)) + } + + observer.on(.Completed) + return NopDisposable.instance + } + + let sink = SequenceSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift new file mode 100644 index 00000000000..52cb5ebe3df --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift @@ -0,0 +1,101 @@ +// +// ShareReplay1.swift +// Rx +// +// Created by Krunoslav Zaher on 10/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// optimized version of share replay for most common case +final class ShareReplay1 + : Observable + , ObserverType + , SynchronizedUnsubscribeType { + + typealias DisposeKey = Bag>.KeyType + + private let _source: Observable + + private var _lock = NSRecursiveLock() + + private var _connection: SingleAssignmentDisposable? + private var _element: Element? + private var _stopped = false + private var _stopEvent = nil as Event? + private var _observers = Bag>() + + init(source: Observable) { + self._source = source + } + + override func subscribe(observer: O) -> Disposable { + _lock.lock(); defer { _lock.unlock() } + return _synchronized_subscribe(observer) + } + + func _synchronized_subscribe(observer: O) -> Disposable { + if let element = self._element { + observer.on(.Next(element)) + } + + if let stopEvent = self._stopEvent { + observer.on(stopEvent) + return NopDisposable.instance + } + + let initialCount = self._observers.count + + let disposeKey = self._observers.insert(AnyObserver(observer)) + + if initialCount == 0 { + let connection = SingleAssignmentDisposable() + _connection = connection + + connection.disposable = self._source.subscribe(self) + } + + return SubscriptionDisposable(owner: self, key: disposeKey) + } + + func synchronizedUnsubscribe(disposeKey: DisposeKey) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_unsubscribe(disposeKey) + } + + func _synchronized_unsubscribe(disposeKey: DisposeKey) { + // if already unsubscribed, just return + if self._observers.removeKey(disposeKey) == nil { + return + } + + if _observers.count == 0 { + _connection?.dispose() + _connection = nil + } + } + + func on(event: Event) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_on(event) + } + + func _synchronized_on(event: Event) { + if _stopped { + return + } + + switch event { + case .Next(let element): + _element = element + case .Error, .Completed: + _stopEvent = event + _stopped = true + _connection?.dispose() + _connection = nil + } + + _observers.on(event) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift new file mode 100644 index 00000000000..af776b1ce9e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift @@ -0,0 +1,92 @@ +// +// ShareReplay1WhileConnected.swift +// Rx +// +// Created by Krunoslav Zaher on 12/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// optimized version of share replay for most common case +final class ShareReplay1WhileConnected + : Observable + , ObserverType + , SynchronizedUnsubscribeType { + + typealias DisposeKey = Bag>.KeyType + + private let _source: Observable + + private var _lock = NSRecursiveLock() + + private var _connection: SingleAssignmentDisposable? + private var _element: Element? + private var _observers = Bag>() + + init(source: Observable) { + self._source = source + } + + override func subscribe(observer: O) -> Disposable { + _lock.lock(); defer { _lock.unlock() } + return _synchronized_subscribe(observer) + } + + func _synchronized_subscribe(observer: O) -> Disposable { + if let element = self._element { + observer.on(.Next(element)) + } + + let initialCount = self._observers.count + + let disposeKey = self._observers.insert(AnyObserver(observer)) + + if initialCount == 0 { + let connection = SingleAssignmentDisposable() + _connection = connection + + connection.disposable = self._source.subscribe(self) + } + + return SubscriptionDisposable(owner: self, key: disposeKey) + } + + func synchronizedUnsubscribe(disposeKey: DisposeKey) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_unsubscribe(disposeKey) + } + + func _synchronized_unsubscribe(disposeKey: DisposeKey) { + // if already unsubscribed, just return + if self._observers.removeKey(disposeKey) == nil { + return + } + + if _observers.count == 0 { + _connection?.dispose() + _connection = nil + _element = nil + } + } + + func on(event: Event) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_on(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let element): + _element = element + _observers.on(event) + case .Error, .Completed: + _element = nil + _connection?.dispose() + _connection = nil + let observers = _observers + _observers = Bag() + observers.on(event) + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift new file mode 100644 index 00000000000..abf40d8d4c1 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift @@ -0,0 +1,76 @@ +// +// SingleAsync.swift +// Rx +// +// Created by Junior B. on 09/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SingleAsyncSink : Sink, ObserverType { + typealias Parent = SingleAsync + typealias E = ElementType + + private let _parent: Parent + private var _seenValue: Bool = false + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + do { + let forward = try _parent._predicate?(value) ?? true + if !forward { + return + } + } + catch let error { + forwardOn(.Error(error as ErrorType)) + dispose() + return + } + + if _seenValue == false { + _seenValue = true + forwardOn(.Next(value)) + } else { + forwardOn(.Error(RxError.MoreThanOneElement)) + dispose() + } + + case .Error: + forwardOn(event) + dispose() + case .Completed: + if (!_seenValue) { + forwardOn(.Error(RxError.NoElements)) + } else { + forwardOn(.Completed) + } + dispose() + } + } +} + +class SingleAsync: Producer { + typealias Predicate = (Element) throws -> Bool + + private let _source: Observable + private let _predicate: Predicate? + + init(source: Observable, predicate: Predicate? = nil) { + _source = source + _predicate = predicate + } + + override func run(observer: O) -> Disposable { + let sink = SingleAsyncSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift new file mode 100644 index 00000000000..36b1937f814 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift @@ -0,0 +1,57 @@ +// +// Sink.swift +// Rx +// +// Created by Krunoslav Zaher on 2/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Sink : SingleAssignmentDisposable { + private let _observer: O + + init(observer: O) { +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) +#endif + _observer = observer + } + + final func forwardOn(event: Event) { + if disposed { + return + } + _observer.on(event) + } + + final func forwarder() -> SinkForward { + return SinkForward(forward: self) + } + + deinit { +#if TRACE_RESOURCES + AtomicDecrement(&resourceCount) +#endif + } +} + +class SinkForward: ObserverType { + typealias E = O.E + + private let _forward: Sink + + init(forward: Sink) { + _forward = forward + } + + func on(event: Event) { + switch event { + case .Next: + _forward._observer.on(event) + case .Error, .Completed: + _forward._observer.on(event) + _forward.dispose() + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift new file mode 100644 index 00000000000..ea977d396fe --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift @@ -0,0 +1,128 @@ +// +// Skip.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// count version + +class SkipCountSink : Sink, ObserverType { + typealias Parent = SkipCount + typealias Element = ElementType + + let parent: Parent + + var remaining: Int + + init(parent: Parent, observer: O) { + self.parent = parent + self.remaining = parent.count + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + + if remaining <= 0 { + forwardOn(.Next(value)) + } + else { + remaining -= 1 + } + case .Error: + forwardOn(event) + self.dispose() + case .Completed: + forwardOn(event) + self.dispose() + } + } + +} + +class SkipCount: Producer { + let source: Observable + let count: Int + + init(source: Observable, count: Int) { + self.source = source + self.count = count + } + + override func run(observer: O) -> Disposable { + let sink = SkipCountSink(parent: self, observer: observer) + sink.disposable = source.subscribe(sink) + + return sink + } +} + +// time version + +class SkipTimeSink : Sink, ObserverType { + typealias Parent = SkipTime + typealias Element = ElementType + + let parent: Parent + + // state + var open = false + + init(parent: Parent, observer: O) { + self.parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + if open { + forwardOn(.Next(value)) + } + case .Error: + forwardOn(event) + self.dispose() + case .Completed: + forwardOn(event) + self.dispose() + } + } + + func tick() { + open = true + } + + func run() -> Disposable { + let disposeTimer = parent.scheduler.scheduleRelative((), dueTime: self.parent.duration) { + self.tick() + return NopDisposable.instance + } + + let disposeSubscription = parent.source.subscribe(self) + + return BinaryDisposable(disposeTimer, disposeSubscription) + } +} + +class SkipTime: Producer { + let source: Observable + let duration: RxTimeInterval + let scheduler: SchedulerType + + init(source: Observable, duration: RxTimeInterval, scheduler: SchedulerType) { + self.source = source + self.scheduler = scheduler + self.duration = duration + } + + override func run(observer: O) -> Disposable { + let sink = SkipTimeSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift new file mode 100644 index 00000000000..be3c69373f2 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift @@ -0,0 +1,125 @@ +// +// SkipUntil.swift +// Rx +// +// Created by Yury Korolev on 10/3/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SkipUntilSinkOther + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Parent = SkipUntilSink + typealias E = Other + + private let _parent: Parent + + var _lock: NSRecursiveLock { + return _parent._lock + } + + let _subscription = SingleAssignmentDisposable() + + init(parent: Parent) { + _parent = parent + #if TRACE_RESOURCES + AtomicIncrement(&resourceCount) + #endif + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: + _parent._forwardElements = true + _subscription.dispose() + case .Error(let e): + _parent.forwardOn(.Error(e)) + _parent.dispose() + case .Completed: + _subscription.dispose() + } + } + + #if TRACE_RESOURCES + deinit { + AtomicDecrement(&resourceCount) + } + #endif + +} + + +class SkipUntilSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = ElementType + typealias Parent = SkipUntil + + let _lock = NSRecursiveLock() + private let _parent: Parent + private var _forwardElements = false + + private let _sourceSubscription = SingleAssignmentDisposable() + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: + if _forwardElements { + forwardOn(event) + } + case .Error: + forwardOn(event) + dispose() + case .Completed: + if _forwardElements { + forwardOn(event) + } + _sourceSubscription.dispose() + } + } + + func run() -> Disposable { + let sourceSubscription = _parent._source.subscribe(self) + let otherObserver = SkipUntilSinkOther(parent: self) + let otherSubscription = _parent._other.subscribe(otherObserver) + _sourceSubscription.disposable = sourceSubscription + otherObserver._subscription.disposable = otherSubscription + + return StableCompositeDisposable.create(_sourceSubscription, otherObserver._subscription) + } +} + +class SkipUntil: Producer { + + private let _source: Observable + private let _other: Observable + + init(source: Observable, other: Observable) { + _source = source + _other = other + } + + override func run(observer: O) -> Disposable { + let sink = SkipUntilSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift new file mode 100644 index 00000000000..d16304a089e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift @@ -0,0 +1,115 @@ +// +// SkipWhile.swift +// Rx +// +// Created by Yury Korolev on 10/9/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +class SkipWhileSink : Sink, ObserverType { + + typealias Parent = SkipWhile + typealias Element = ElementType + + private let _parent: Parent + private var _running = false + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + if !_running { + do { + _running = try !_parent._predicate(value) + } catch let e { + forwardOn(.Error(e)) + dispose() + return + } + } + + if _running { + forwardOn(.Next(value)) + } + case .Error, .Completed: + forwardOn(event) + dispose() + } + } +} + +class SkipWhileSinkWithIndex : Sink, ObserverType { + + typealias Parent = SkipWhile + typealias Element = ElementType + + private let _parent: Parent + private var _index = 0 + private var _running = false + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + if !_running { + do { + _running = try !_parent._predicateWithIndex(value, _index) + try incrementChecked(&_index) + } catch let e { + forwardOn(.Error(e)) + dispose() + return + } + } + + if _running { + forwardOn(.Next(value)) + } + case .Error, .Completed: + forwardOn(event) + dispose() + } + } +} + +class SkipWhile: Producer { + typealias Predicate = (Element) throws -> Bool + typealias PredicateWithIndex = (Element, Int) throws -> Bool + + private let _source: Observable + private let _predicate: Predicate! + private let _predicateWithIndex: PredicateWithIndex! + + init(source: Observable, predicate: Predicate) { + _source = source + _predicate = predicate + _predicateWithIndex = nil + } + + init(source: Observable, predicate: PredicateWithIndex) { + _source = source + _predicate = nil + _predicateWithIndex = predicate + } + + override func run(observer: O) -> Disposable { + if let _ = _predicate { + let sink = SkipWhileSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } + else { + let sink = SkipWhileSinkWithIndex(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift new file mode 100644 index 00000000000..c60cb367971 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift @@ -0,0 +1,28 @@ +// +// StartWith.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class StartWith: Producer { + let elements: [Element] + let source: Observable + + init(source: Observable, elements: [Element]) { + self.source = source + self.elements = elements + super.init() + } + + override func run(observer: O) -> Disposable { + for e in elements { + observer.on(.Next(e)) + } + + return source.subscribe(observer) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift new file mode 100644 index 00000000000..1d461a3d620 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift @@ -0,0 +1,60 @@ +// +// SubscribeOn.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SubscribeOnSink : Sink, ObserverType { + typealias Element = O.E + typealias Parent = SubscribeOn + + let parent: Parent + + init(parent: Parent, observer: O) { + self.parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + forwardOn(event) + + if event.isStopEvent { + self.dispose() + } + } + + func run() -> Disposable { + let disposeEverything = SerialDisposable() + let cancelSchedule = SingleAssignmentDisposable() + + disposeEverything.disposable = cancelSchedule + + cancelSchedule.disposable = parent.scheduler.schedule(()) { (_) -> Disposable in + let subscription = self.parent.source.subscribe(self) + disposeEverything.disposable = ScheduledDisposable(scheduler: self.parent.scheduler, disposable: subscription) + return NopDisposable.instance + } + + return disposeEverything + } +} + +class SubscribeOn : Producer { + let source: Ob + let scheduler: ImmediateSchedulerType + + init(source: Ob, scheduler: ImmediateSchedulerType) { + self.source = source + self.scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = SubscribeOnSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift new file mode 100644 index 00000000000..2051275cc1b --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift @@ -0,0 +1,193 @@ +// +// Switch.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SwitchSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = SourceType + + private let _subscriptions: SingleAssignmentDisposable = SingleAssignmentDisposable() + private let _innerSubscription: SerialDisposable = SerialDisposable() + + let _lock = NSRecursiveLock() + + // state + private var _stopped = false + private var _latest = 0 + private var _hasLatest = false + + override init(observer: O) { + super.init(observer: observer) + } + + func run(source: Observable) -> Disposable { + let subscription = source.subscribe(self) + _subscriptions.disposable = subscription + return StableCompositeDisposable.create(_subscriptions, _innerSubscription) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func performMap(element: SourceType) throws -> S { + abstractMethod() + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let element): + do { + let observable = try performMap(element).asObservable() + _hasLatest = true + _latest = _latest &+ 1 + let latest = _latest + + let d = SingleAssignmentDisposable() + _innerSubscription.disposable = d + + let observer = SwitchSinkIter(parent: self, id: latest, _self: d) + let disposable = observable.subscribe(observer) + d.disposable = disposable + } + catch let error { + forwardOn(.Error(error)) + dispose() + } + case .Error(let error): + forwardOn(.Error(error)) + dispose() + case .Completed: + _stopped = true + + _subscriptions.dispose() + + if !_hasLatest { + forwardOn(.Completed) + dispose() + } + } + } +} + +class SwitchSinkIter + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = S.E + typealias Parent = SwitchSink + + private let _parent: Parent + private let _id: Int + private let _self: Disposable + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent, id: Int, _self: Disposable) { + _parent = parent + _id = id + self._self = _self + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: break + case .Error, .Completed: + _self.dispose() + } + + if _parent._latest != _id { + return + } + + switch event { + case .Next: + _parent.forwardOn(event) + case .Error: + _parent.forwardOn(event) + _parent.dispose() + case .Completed: + _parent._hasLatest = false + if _parent._stopped { + _parent.forwardOn(event) + _parent.dispose() + } + } + } +} + +// MARK: Specializations + +final class SwitchIdentitySink : SwitchSink { + override init(observer: O) { + super.init(observer: observer) + } + + override func performMap(element: S) throws -> S { + return element + } +} + +final class MapSwitchSink : SwitchSink { + typealias Selector = SourceType throws -> S + + private let _selector: Selector + + init(selector: Selector, observer: O) { + _selector = selector + super.init(observer: observer) + } + + override func performMap(element: SourceType) throws -> S { + return try _selector(element) + } +} + +// MARK: Producers + +final class Switch : Producer { + private let _source: Observable + + init(source: Observable) { + _source = source + } + + override func run(observer: O) -> Disposable { + let sink = SwitchIdentitySink(observer: observer) + sink.disposable = sink.run(_source) + return sink + } +} + +final class FlatMapLatest : Producer { + typealias Selector = SourceType throws -> S + + private let _source: Observable + private let _selector: Selector + + init(source: Observable, selector: Selector) { + _source = source + _selector = selector + } + + override func run(observer: O) -> Disposable { + let sink = MapSwitchSink(selector: _selector, observer: observer) + sink.disposable = sink.run(_source) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift new file mode 100644 index 00000000000..d551100476c --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift @@ -0,0 +1,144 @@ +// +// Take.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// count version + +class TakeCountSink : Sink, ObserverType { + typealias Parent = TakeCount + typealias E = ElementType + + private let _parent: Parent + + private var _remaining: Int + + init(parent: Parent, observer: O) { + _parent = parent + _remaining = parent._count + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + + if _remaining > 0 { + _remaining -= 1 + + forwardOn(.Next(value)) + + if _remaining == 0 { + forwardOn(.Completed) + dispose() + } + } + case .Error: + forwardOn(event) + dispose() + case .Completed: + forwardOn(event) + dispose() + } + } + +} + +class TakeCount: Producer { + private let _source: Observable + private let _count: Int + + init(source: Observable, count: Int) { + if count < 0 { + rxFatalError("count can't be negative") + } + _source = source + _count = count + } + + override func run(observer: O) -> Disposable { + let sink = TakeCountSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} + +// time version + +class TakeTimeSink + : Sink + , LockOwnerType + , ObserverType + , SynchronizedOnType { + typealias Parent = TakeTime + typealias E = ElementType + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let value): + forwardOn(.Next(value)) + case .Error: + forwardOn(event) + dispose() + case .Completed: + forwardOn(event) + dispose() + } + } + + func tick() { + _lock.lock(); defer { _lock.unlock() } + + forwardOn(.Completed) + dispose() + } + + func run() -> Disposable { + let disposeTimer = _parent._scheduler.scheduleRelative((), dueTime: _parent._duration) { + self.tick() + return NopDisposable.instance + } + + let disposeSubscription = _parent._source.subscribe(self) + + return BinaryDisposable(disposeTimer, disposeSubscription) + } +} + +class TakeTime : Producer { + typealias TimeInterval = RxTimeInterval + + private let _source: Observable + private let _duration: TimeInterval + private let _scheduler: SchedulerType + + init(source: Observable, duration: TimeInterval, scheduler: SchedulerType) { + _source = source + _scheduler = scheduler + _duration = duration + } + + override func run(observer: O) -> Disposable { + let sink = TakeTimeSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift new file mode 100644 index 00000000000..2a479d393f0 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift @@ -0,0 +1,63 @@ +// +// TakeLast.swift +// Rx +// +// Created by Tomi Koskinen on 25/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + +class TakeLastSink : Sink, ObserverType { + typealias Parent = TakeLast + typealias E = ElementType + + private let _parent: Parent + + private var _elements: Queue + + init(parent: Parent, observer: O) { + _parent = parent + _elements = Queue(capacity: parent._count + 1) + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + _elements.enqueue(value) + if _elements.count > self._parent._count { + _elements.dequeue() + } + case .Error: + forwardOn(event) + dispose() + case .Completed: + for e in _elements { + forwardOn(.Next(e)) + } + forwardOn(.Completed) + dispose() + } + } +} + +class TakeLast: Producer { + private let _source: Observable + private let _count: Int + + init(source: Observable, count: Int) { + if count < 0 { + rxFatalError("count can't be negative") + } + _source = source + _count = count + } + + override func run(observer: O) -> Disposable { + let sink = TakeLastSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift new file mode 100644 index 00000000000..f1e36d9774e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift @@ -0,0 +1,120 @@ +// +// TakeUntil.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TakeUntilSinkOther + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Parent = TakeUntilSink + typealias E = Other + + private let _parent: Parent + + var _lock: NSRecursiveLock { + return _parent._lock + } + + private let _subscription = SingleAssignmentDisposable() + + init(parent: Parent) { + _parent = parent +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) +#endif + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: + _parent.forwardOn(.Completed) + _parent.dispose() + case .Error(let e): + _parent.forwardOn(.Error(e)) + _parent.dispose() + case .Completed: + _parent._open = true + _subscription.dispose() + } + } + +#if TRACE_RESOURCES + deinit { + AtomicDecrement(&resourceCount) + } +#endif +} + +class TakeUntilSink + : Sink + , LockOwnerType + , ObserverType + , SynchronizedOnType { + typealias E = ElementType + typealias Parent = TakeUntil + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + private var _open = false + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next: + forwardOn(event) + case .Error: + forwardOn(event) + dispose() + case .Completed: + forwardOn(event) + dispose() + } + } + + func run() -> Disposable { + let otherObserver = TakeUntilSinkOther(parent: self) + let otherSubscription = _parent._other.subscribe(otherObserver) + otherObserver._subscription.disposable = otherSubscription + let sourceSubscription = _parent._source.subscribe(self) + + return StableCompositeDisposable.create(sourceSubscription, otherObserver._subscription) + } +} + +class TakeUntil: Producer { + + private let _source: Observable + private let _other: Observable + + init(source: Observable, other: Observable) { + _source = source + _other = other + } + + override func run(observer: O) -> Disposable { + let sink = TakeUntilSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift new file mode 100644 index 00000000000..a660bb813bb --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift @@ -0,0 +1,132 @@ +// +// TakeWhile.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TakeWhileSink + : Sink + , ObserverType { + typealias Parent = TakeWhile + typealias Element = ElementType + + private let _parent: Parent + + private var _running = true + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + if !_running { + return + } + + do { + _running = try _parent._predicate(value) + } catch let e { + forwardOn(.Error(e)) + dispose() + return + } + + if _running { + forwardOn(.Next(value)) + } else { + forwardOn(.Completed) + dispose() + } + case .Error, .Completed: + forwardOn(event) + dispose() + } + } + +} + +class TakeWhileSinkWithIndex + : Sink + , ObserverType { + typealias Parent = TakeWhile + typealias Element = ElementType + + private let _parent: Parent + + private var _running = true + private var _index = 0 + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + if !_running { + return + } + + do { + _running = try _parent._predicateWithIndex(value, _index) + try incrementChecked(&_index) + } catch let e { + forwardOn(.Error(e)) + dispose() + return + } + + if _running { + forwardOn(.Next(value)) + } else { + forwardOn(.Completed) + dispose() + } + case .Error, .Completed: + forwardOn(event) + dispose() + } + } + +} + +class TakeWhile: Producer { + typealias Predicate = (Element) throws -> Bool + typealias PredicateWithIndex = (Element, Int) throws -> Bool + + private let _source: Observable + private let _predicate: Predicate! + private let _predicateWithIndex: PredicateWithIndex! + + init(source: Observable, predicate: Predicate) { + _source = source + _predicate = predicate + _predicateWithIndex = nil + } + + init(source: Observable, predicate: PredicateWithIndex) { + _source = source + _predicate = nil + _predicateWithIndex = predicate + } + + override func run(observer: O) -> Disposable { + if let _ = _predicate { + let sink = TakeWhileSink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } else { + let sink = TakeWhileSinkWithIndex(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift new file mode 100644 index 00000000000..33e9837dc4b --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift @@ -0,0 +1,104 @@ +// +// Throttle.swift +// Rx +// +// Created by Krunoslav Zaher on 3/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ThrottleSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = O.E + typealias ParentType = Throttle + + private let _parent: ParentType + + let _lock = NSRecursiveLock() + + // state + private var _id = 0 as UInt64 + private var _value: Element? = nil + + let cancellable = SerialDisposable() + + init(parent: ParentType, observer: O) { + _parent = parent + + super.init(observer: observer) + } + + func run() -> Disposable { + let subscription = _parent._source.subscribe(self) + + return StableCompositeDisposable.create(subscription, cancellable) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case .Next(let element): + _id = _id &+ 1 + let currentId = _id + _value = element + + + let scheduler = _parent._scheduler + let dueTime = _parent._dueTime + + let d = SingleAssignmentDisposable() + self.cancellable.disposable = d + d.disposable = scheduler.scheduleRelative(currentId, dueTime: dueTime, action: self.propagate) + case .Error: + _value = nil + forwardOn(event) + dispose() + case .Completed: + if let value = _value { + _value = nil + forwardOn(.Next(value)) + } + forwardOn(.Completed) + dispose() + } + } + + func propagate(currentId: UInt64) -> Disposable { + _lock.lock(); defer { _lock.unlock() } // { + let originalValue = _value + + if let value = originalValue where _id == currentId { + _value = nil + forwardOn(.Next(value)) + } + // } + return NopDisposable.instance + } +} + +class Throttle : Producer { + + private let _source: Observable + private let _dueTime: RxTimeInterval + private let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = ThrottleSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } + +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift new file mode 100644 index 00000000000..fe6a1b85396 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift @@ -0,0 +1,120 @@ +// +// Timeout.swift +// Rx +// +// Created by Tomi Koskinen on 13/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TimeoutSink: Sink, LockOwnerType, ObserverType { + typealias E = ElementType + typealias Parent = Timeout + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + private let _timerD = SerialDisposable() + private let _subscription = SerialDisposable() + + private var _id = 0 + private var _switched = false + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + let original = SingleAssignmentDisposable() + _subscription.disposable = original + + _createTimeoutTimer() + + original.disposable = _parent._source.subscribeSafe(self) + + return StableCompositeDisposable.create(_subscription, _timerD) + } + + func on(event: Event) { + switch event { + case .Next: + var onNextWins = false + + _lock.performLocked() { + onNextWins = !self._switched + if onNextWins { + self._id = self._id &+ 1 + } + } + + if onNextWins { + forwardOn(event) + self._createTimeoutTimer() + } + case .Error, .Completed: + var onEventWins = false + + _lock.performLocked() { + onEventWins = !self._switched + if onEventWins { + self._id = self._id &+ 1 + } + } + + if onEventWins { + forwardOn(event) + self.dispose() + } + } + } + + private func _createTimeoutTimer() { + if _timerD.disposed { + return + } + + let nextTimer = SingleAssignmentDisposable() + _timerD.disposable = nextTimer + + nextTimer.disposable = _parent._scheduler.scheduleRelative(_id, dueTime: _parent._dueTime) { state in + + var timerWins = false + + self._lock.performLocked() { + self._switched = (state == self._id) + timerWins = self._switched + } + + if timerWins { + self._subscription.disposable = self._parent._other.subscribeSafe(self.forwarder()) + } + + return NopDisposable.instance + } + } +} + + +class Timeout : Producer { + + private let _source: Observable + private let _dueTime: RxTimeInterval + private let _other: Observable + private let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, other: Observable, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _other = other + _scheduler = scheduler + } + + override func run(observer: O) -> Disposable { + let sink = TimeoutSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift new file mode 100644 index 00000000000..dcbb2bfd260 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift @@ -0,0 +1,72 @@ +// +// Timer.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TimerSink : Sink { + typealias Parent = Timer + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + return _parent._scheduler.schedulePeriodic(0 as O.E, startAfter: _parent._dueTime, period: _parent._period!) { state in + self.forwardOn(.Next(state)) + return state &+ 1 + } + } +} + +class TimerOneOffSink : Sink { + typealias Parent = Timer + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRelative((), dueTime: _parent._dueTime) { (_) -> Disposable in + self.forwardOn(.Next(0)) + self.forwardOn(.Completed) + + return NopDisposable.instance + } + } +} + +class Timer: Producer { + private let _scheduler: SchedulerType + private let _dueTime: RxTimeInterval + private let _period: RxTimeInterval? + + init(dueTime: RxTimeInterval, period: RxTimeInterval?, scheduler: SchedulerType) { + _scheduler = scheduler + _dueTime = dueTime + _period = period + } + + override func run(observer: O) -> Disposable { + if let _ = _period { + let sink = TimerSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } + else { + let sink = TimerOneOffSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift new file mode 100644 index 00000000000..cb5c428143c --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift @@ -0,0 +1,50 @@ +// +// ToArray.swift +// Rx +// +// Created by Junior B. on 20/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ToArraySink : Sink, ObserverType { + typealias Parent = ToArray + + let _parent: Parent + var _list = Array() + + init(parent: Parent, observer: O) { + _parent = parent + + super.init(observer: observer) + } + + func on(event: Event) { + switch event { + case .Next(let value): + self._list.append(value) + case .Error(let e): + forwardOn(.Error(e)) + self.dispose() + case .Completed: + forwardOn(.Next(_list)) + forwardOn(.Completed) + self.dispose() + } + } +} + +class ToArray : Producer<[SourceType]> { + let _source: Observable + + init(source: Observable) { + _source = source + } + + override func run(observer: O) -> Disposable { + let sink = ToArraySink(parent: self, observer: observer) + sink.disposable = _source.subscribe(sink) + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift new file mode 100644 index 00000000000..6aa229823ca --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift @@ -0,0 +1,78 @@ +// +// Using.swift +// Rx +// +// Created by Yury Korolev on 10/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class UsingSink : Sink, ObserverType { + + typealias Parent = Using + typealias E = O.E + + private let _parent: Parent + + init(parent: Parent, observer: O) { + _parent = parent + super.init(observer: observer) + } + + func run() -> Disposable { + var disposable = NopDisposable.instance + + do { + let resource = try _parent._resourceFactory() + disposable = resource + let source = try _parent._observableFactory(resource) + + return StableCompositeDisposable.create( + source.subscribe(self), + disposable + ) + } catch let error { + return StableCompositeDisposable.create( + Observable.error(error).subscribe(self), + disposable + ) + } + } + + func on(event: Event) { + switch event { + case let .Next(value): + forwardOn(.Next(value)) + case let .Error(error): + forwardOn(.Error(error)) + dispose() + case .Completed: + forwardOn(.Completed) + dispose() + } + } +} + +class Using: Producer { + + typealias E = SourceType + + typealias ResourceFactory = () throws -> ResourceType + typealias ObservableFactory = ResourceType throws -> Observable + + private let _resourceFactory: ResourceFactory + private let _observableFactory: ObservableFactory + + + init(resourceFactory: ResourceFactory, observableFactory: ObservableFactory) { + _resourceFactory = resourceFactory + _observableFactory = observableFactory + } + + override func run(observer: O) -> Disposable { + let sink = UsingSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift new file mode 100644 index 00000000000..24060a8493e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift @@ -0,0 +1,152 @@ +// +// Window.swift +// Rx +// +// Created by Junior B. on 29/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class WindowTimeCountSink> + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Parent = WindowTimeCount + typealias E = Element + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + private var _subject = PublishSubject() + private var _count = 0 + private var _windowId = 0 + + private let _timerD = SerialDisposable() + private let _refCountDisposable: RefCountDisposable + private let _groupDisposable = CompositeDisposable() + + init(parent: Parent, observer: O) { + _parent = parent + + _groupDisposable.addDisposable(_timerD) + + _refCountDisposable = RefCountDisposable(disposable: _groupDisposable) + super.init(observer: observer) + } + + func run() -> Disposable { + + forwardOn(.Next(AddRef(source: _subject, refCount: _refCountDisposable).asObservable())) + createTimer(_windowId) + + _groupDisposable.addDisposable(_parent._source.subscribeSafe(self)) + return _refCountDisposable + } + + func startNewWindowAndCompleteCurrentOne() { + _subject.on(.Completed) + _subject = PublishSubject() + + forwardOn(.Next(AddRef(source: _subject, refCount: _refCountDisposable).asObservable())) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + var newWindow = false + var newId = 0 + + switch event { + case .Next(let element): + _subject.on(.Next(element)) + + do { + try incrementChecked(&_count) + } catch (let e) { + _subject.on(.Error(e as ErrorType)) + dispose() + } + + if (_count == _parent._count) { + newWindow = true + _count = 0 + _windowId += 1 + newId = _windowId + self.startNewWindowAndCompleteCurrentOne() + } + + case .Error(let error): + _subject.on(.Error(error)) + forwardOn(.Error(error)) + dispose() + case .Completed: + _subject.on(.Completed) + forwardOn(.Completed) + dispose() + } + + if newWindow { + createTimer(newId) + } + } + + func createTimer(windowId: Int) { + if _timerD.disposed { + return + } + + if _windowId != windowId { + return + } + + let nextTimer = SingleAssignmentDisposable() + + _timerD.disposable = nextTimer + + nextTimer.disposable = _parent._scheduler.scheduleRelative(windowId, dueTime: _parent._timeSpan) { previousWindowId in + + var newId = 0 + + self._lock.performLocked { + if previousWindowId != self._windowId { + return + } + + self._count = 0 + self._windowId = self._windowId &+ 1 + newId = self._windowId + self.startNewWindowAndCompleteCurrentOne() + } + + self.createTimer(newId) + + return NopDisposable.instance + } + } +} + +class WindowTimeCount : Producer> { + + private let _timeSpan: RxTimeInterval + private let _count: Int + private let _scheduler: SchedulerType + private let _source: Observable + + init(source: Observable, timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) { + _source = source + _timeSpan = timeSpan + _count = count + _scheduler = scheduler + } + + override func run>(observer: O) -> Disposable { + let sink = WindowTimeCountSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift new file mode 100644 index 00000000000..7d0ab9f615c --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift @@ -0,0 +1,122 @@ +// +// WithLatestFrom.swift +// RxExample +// +// Created by Yury Korolev on 10/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class WithLatestFromSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + + typealias Parent = WithLatestFrom + typealias E = FirstType + + private let _parent: Parent + + var _lock = NSRecursiveLock() + private var _latest: SecondType? + + init(parent: Parent, observer: O) { + _parent = parent + + super.init(observer: observer) + } + + func run() -> Disposable { + let sndSubscription = SingleAssignmentDisposable() + let sndO = WithLatestFromSecond(parent: self, disposable: sndSubscription) + + sndSubscription.disposable = _parent._second.subscribe(sndO) + let fstSubscription = _parent._first.subscribe(self) + + return StableCompositeDisposable.create(fstSubscription, sndSubscription) + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case let .Next(value): + guard let latest = _latest else { return } + do { + let res = try _parent._resultSelector(value, latest) + + forwardOn(.Next(res)) + } catch let e { + forwardOn(.Error(e)) + dispose() + } + case .Completed: + forwardOn(.Completed) + dispose() + case let .Error(error): + forwardOn(.Error(error)) + dispose() + } + } +} + +class WithLatestFromSecond + : ObserverType + , LockOwnerType + , SynchronizedOnType { + + typealias Parent = WithLatestFromSink + typealias E = SecondType + + private let _parent: Parent + private let _disposable: Disposable + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent, disposable: Disposable) { + _parent = parent + _disposable = disposable + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + switch event { + case let .Next(value): + _parent._latest = value + case .Completed: + _disposable.dispose() + case let .Error(error): + _parent.forwardOn(.Error(error)) + _parent.dispose() + } + } +} + +class WithLatestFrom: Producer { + typealias ResultSelector = (FirstType, SecondType) throws -> ResultType + + private let _first: Observable + private let _second: Observable + private let _resultSelector: ResultSelector + + init(first: Observable, second: Observable, resultSelector: ResultSelector) { + _first = first + _second = second + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = WithLatestFromSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift new file mode 100644 index 00000000000..d083a30a582 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift @@ -0,0 +1,137 @@ +// +// Zip+CollectionType.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ZipCollectionTypeSink + : Sink { + typealias Parent = ZipCollectionType + typealias SourceElement = C.Generator.Element.E + + private let _parent: Parent + + private let _lock = NSRecursiveLock() + + // state + private var _numberOfValues = 0 + private var _values: [Queue] + private var _isDone: [Bool] + private var _numberOfDone = 0 + private var _subscriptions: [SingleAssignmentDisposable] + + init(parent: Parent, observer: O) { + _parent = parent + _values = [Queue](count: parent.count, repeatedValue: Queue(capacity: 4)) + _isDone = [Bool](count: parent.count, repeatedValue: false) + _subscriptions = Array() + _subscriptions.reserveCapacity(parent.count) + + for _ in 0 ..< parent.count { + _subscriptions.append(SingleAssignmentDisposable()) + } + + super.init(observer: observer) + } + + func on(event: Event, atIndex: Int) { + _lock.lock(); defer { _lock.unlock() } // { + switch event { + case .Next(let element): + _values[atIndex].enqueue(element) + + if _values[atIndex].count == 1 { + _numberOfValues += 1 + } + + if _numberOfValues < _parent.count { + let numberOfOthersThatAreDone = _numberOfDone - (_isDone[atIndex] ? 1 : 0) + if numberOfOthersThatAreDone == _parent.count - 1 { + self.forwardOn(.Completed) + self.dispose() + } + return + } + + do { + var arguments = [SourceElement]() + arguments.reserveCapacity(_parent.count) + + // recalculate number of values + _numberOfValues = 0 + + for i in 0 ..< _values.count { + arguments.append(_values[i].dequeue()!) + if _values[i].count > 0 { + _numberOfValues += 1 + } + } + + let result = try _parent.resultSelector(arguments) + self.forwardOn(.Next(result)) + } + catch let error { + self.forwardOn(.Error(error)) + self.dispose() + } + + case .Error(let error): + self.forwardOn(.Error(error)) + self.dispose() + case .Completed: + if _isDone[atIndex] { + return + } + + _isDone[atIndex] = true + _numberOfDone += 1 + + if _numberOfDone == _parent.count { + self.forwardOn(.Completed) + self.dispose() + } + else { + _subscriptions[atIndex].dispose() + } + } + // } + } + + func run() -> Disposable { + var j = 0 + for i in _parent.sources.startIndex ..< _parent.sources.endIndex { + let index = j + let source = _parent.sources[i].asObservable() + _subscriptions[j].disposable = source.subscribe(AnyObserver { event in + self.on(event, atIndex: index) + }) + j += 1 + } + + return CompositeDisposable(disposables: _subscriptions.map { $0 }) + } +} + +class ZipCollectionType : Producer { + typealias ResultSelector = [C.Generator.Element.E] throws -> R + + let sources: C + let resultSelector: ResultSelector + let count: Int + + init(sources: C, resultSelector: ResultSelector) { + self.sources = sources + self.resultSelector = resultSelector + self.count = Int(self.sources.count.toIntMax()) + } + + override func run(observer: O) -> Disposable { + let sink = ZipCollectionTypeSink(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift new file mode 100644 index 00000000000..891c2c40ca3 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift @@ -0,0 +1,829 @@ +// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project +// +// Zip+arity.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + + +// 2 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, resultSelector: (O1.E, O2.E) throws -> E) + -> Observable { + return Zip2( + source1: source1.asObservable(), source2: source2.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink2_ : ZipSink { + typealias R = O.E + typealias Parent = Zip2 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 2, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!) + } +} + +class Zip2 : Producer { + typealias ResultSelector = (E1, E2) throws -> R + + let source1: Observable + let source2: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink2_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 3 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, _ source3: O3, resultSelector: (O1.E, O2.E, O3.E) throws -> E) + -> Observable { + return Zip3( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink3_ : ZipSink { + typealias R = O.E + typealias Parent = Zip3 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 3, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + subscription3.disposable = _parent.source3.subscribe(observer3) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!) + } +} + +class Zip3 : Producer { + typealias ResultSelector = (E1, E2, E3) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink3_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 4 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: (O1.E, O2.E, O3.E, O4.E) throws -> E) + -> Observable { + return Zip4( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink4_ : ZipSink { + typealias R = O.E + typealias Parent = Zip4 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 4, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + subscription3.disposable = _parent.source3.subscribe(observer3) + subscription4.disposable = _parent.source4.subscribe(observer4) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!) + } +} + +class Zip4 : Producer { + typealias ResultSelector = (E1, E2, E3, E4) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink4_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 5 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) + -> Observable { + return Zip5( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink5_ : ZipSink { + typealias R = O.E + typealias Parent = Zip5 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 5, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + subscription3.disposable = _parent.source3.subscribe(observer3) + subscription4.disposable = _parent.source4.subscribe(observer4) + subscription5.disposable = _parent.source5.subscribe(observer5) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!) + } +} + +class Zip5 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink5_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 6 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) + -> Observable { + return Zip6( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink6_ : ZipSink { + typealias R = O.E + typealias Parent = Zip6 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + var _values6: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 6, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + case 5: return _values6.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + let observer6 = ZipObserver(lock: _lock, parent: self, index: 5, setNextValue: { self._values6.enqueue($0) }, this: subscription6) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + subscription3.disposable = _parent.source3.subscribe(observer3) + subscription4.disposable = _parent.source4.subscribe(observer4) + subscription5.disposable = _parent.source5.subscribe(observer5) + subscription6.disposable = _parent.source6.subscribe(observer6) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!, _values6.dequeue()!) + } +} + +class Zip6 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + let source6: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + self.source6 = source6 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink6_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 7 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) + -> Observable { + return Zip7( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink7_ : ZipSink { + typealias R = O.E + typealias Parent = Zip7 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + var _values6: Queue = Queue(capacity: 2) + var _values7: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 7, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + case 5: return _values6.count > 0 + case 6: return _values7.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + let observer6 = ZipObserver(lock: _lock, parent: self, index: 5, setNextValue: { self._values6.enqueue($0) }, this: subscription6) + let observer7 = ZipObserver(lock: _lock, parent: self, index: 6, setNextValue: { self._values7.enqueue($0) }, this: subscription7) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + subscription3.disposable = _parent.source3.subscribe(observer3) + subscription4.disposable = _parent.source4.subscribe(observer4) + subscription5.disposable = _parent.source5.subscribe(observer5) + subscription6.disposable = _parent.source6.subscribe(observer6) + subscription7.disposable = _parent.source7.subscribe(observer7) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!, _values6.dequeue()!, _values7.dequeue()!) + } +} + +class Zip7 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + let source6: Observable + let source7: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + self.source6 = source6 + self.source7 = source7 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink7_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} + + + +// 8 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func zip + (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) + -> Observable { + return Zip8( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), source8: source8.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink8_ : ZipSink { + typealias R = O.E + typealias Parent = Zip8 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + var _values6: Queue = Queue(capacity: 2) + var _values7: Queue = Queue(capacity: 2) + var _values8: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O) { + _parent = parent + super.init(arity: 8, observer: observer) + } + + override func hasElements(index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + case 5: return _values6.count > 0 + case 6: return _values7.count > 0 + case 7: return _values8.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + let subscription8 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + let observer6 = ZipObserver(lock: _lock, parent: self, index: 5, setNextValue: { self._values6.enqueue($0) }, this: subscription6) + let observer7 = ZipObserver(lock: _lock, parent: self, index: 6, setNextValue: { self._values7.enqueue($0) }, this: subscription7) + let observer8 = ZipObserver(lock: _lock, parent: self, index: 7, setNextValue: { self._values8.enqueue($0) }, this: subscription8) + + subscription1.disposable = _parent.source1.subscribe(observer1) + subscription2.disposable = _parent.source2.subscribe(observer2) + subscription3.disposable = _parent.source3.subscribe(observer3) + subscription4.disposable = _parent.source4.subscribe(observer4) + subscription5.disposable = _parent.source5.subscribe(observer5) + subscription6.disposable = _parent.source6.subscribe(observer6) + subscription7.disposable = _parent.source7.subscribe(observer7) + subscription8.disposable = _parent.source8.subscribe(observer8) + + return CompositeDisposable(disposables: [ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7, + subscription8 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!, _values6.dequeue()!, _values7.dequeue()!, _values8.dequeue()!) + } +} + +class Zip8 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7, E8) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + let source6: Observable + let source7: Observable + let source8: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, source8: Observable, resultSelector: ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + self.source6 = source6 + self.source7 = source7 + self.source8 = source8 + + _resultSelector = resultSelector + } + + override func run(observer: O) -> Disposable { + let sink = ZipSink8_(parent: self, observer: observer) + sink.disposable = sink.run() + return sink + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift new file mode 100644 index 00000000000..108326517e9 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift @@ -0,0 +1,157 @@ +// +// Zip.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol ZipSinkProtocol : class +{ + func next(index: Int) + func fail(error: ErrorType) + func done(index: Int) +} + +class ZipSink : Sink, ZipSinkProtocol { + typealias Element = O.E + + let _arity: Int + + let _lock = NSRecursiveLock() + + // state + private var _isDone: [Bool] + + init(arity: Int, observer: O) { + _isDone = [Bool](count: arity, repeatedValue: false) + _arity = arity + + super.init(observer: observer) + } + + func getResult() throws -> Element { + abstractMethod() + } + + func hasElements(index: Int) -> Bool { + abstractMethod() + } + + func next(index: Int) { + var hasValueAll = true + + for i in 0 ..< _arity { + if !hasElements(i) { + hasValueAll = false + break + } + } + + if hasValueAll { + do { + let result = try getResult() + self.forwardOn(.Next(result)) + } + catch let e { + self.forwardOn(.Error(e)) + dispose() + } + } + else { + var allOthersDone = true + + let arity = _isDone.count + for i in 0 ..< arity { + if i != index && !_isDone[i] { + allOthersDone = false + break + } + } + + if allOthersDone { + forwardOn(.Completed) + self.dispose() + } + } + } + + func fail(error: ErrorType) { + forwardOn(.Error(error)) + dispose() + } + + func done(index: Int) { + _isDone[index] = true + + var allDone = true + + for done in _isDone { + if !done { + allDone = false + break + } + } + + if allDone { + forwardOn(.Completed) + dispose() + } + } +} + +class ZipObserver + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = ElementType + typealias ValueSetter = (ElementType) -> () + + private var _parent: ZipSinkProtocol? + + let _lock: NSRecursiveLock + + // state + private let _index: Int + private let _this: Disposable + private let _setNextValue: ValueSetter + + init(lock: NSRecursiveLock, parent: ZipSinkProtocol, index: Int, setNextValue: ValueSetter, this: Disposable) { + _lock = lock + _parent = parent + _index = index + _this = this + _setNextValue = setNextValue + } + + func on(event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(event: Event) { + if let _ = _parent { + switch event { + case .Next(_): + break + case .Error(_): + _this.dispose() + case .Completed: + _this.dispose() + } + } + + if let parent = _parent { + switch event { + case .Next(let value): + _setNextValue(value) + parent.next(_index) + case .Error(let error): + parent.fail(error) + case .Completed: + parent.done(_index) + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift new file mode 100644 index 00000000000..8613eb5a62f --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift @@ -0,0 +1,64 @@ +// +// Observable+Aggregate.swift +// Rx +// +// Created by Krunoslav Zaher on 3/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: reduce + +extension ObservableType { + + /** + Applies an `accumulator` function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified `seed` value is used as the initial accumulator value. + + For aggregation behavior with incremental intermediate results, see `scan`. + + - seealso: [reduce operator on reactivex.io](http://reactivex.io/documentation/operators/reduce.html) + + - parameter seed: The initial accumulator value. + - parameter accumulator: A accumulator function to be invoked on each element. + - parameter mapResult: A function to transform the final accumulator value into the result value. + - returns: An observable sequence containing a single element with the final accumulator value. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func reduce(seed: A, accumulator: (A, E) throws -> A, mapResult: (A) throws -> R) + -> Observable { + return Reduce(source: self.asObservable(), seed: seed, accumulator: accumulator, mapResult: mapResult) + } + + /** + Applies an `accumulator` function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified `seed` value is used as the initial accumulator value. + + For aggregation behavior with incremental intermediate results, see `scan`. + + - seealso: [reduce operator on reactivex.io](http://reactivex.io/documentation/operators/reduce.html) + + - parameter seed: The initial accumulator value. + - parameter accumulator: A accumulator function to be invoked on each element. + - returns: An observable sequence containing a single element with the final accumulator value. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func reduce(seed: A, accumulator: (A, E) throws -> A) + -> Observable { + return Reduce(source: self.asObservable(), seed: seed, accumulator: accumulator, mapResult: { $0 }) + } + + /** + Converts an Observable into another Observable that emits the whole sequence as a single array and then terminates. + + For aggregation behavior see `reduce`. + + - seealso: [toArray operator on reactivex.io](http://reactivex.io/documentation/operators/to.html) + + - returns: An observable sequence containing all the emitted elements as array. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func toArray() + -> Observable<[E]> { + return ToArray(source: self.asObservable()) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift new file mode 100644 index 00000000000..8e91eb3c0aa --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift @@ -0,0 +1,190 @@ +// +// Observable+Binding.swift +// Rx +// +// Created by Krunoslav Zaher on 3/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: multicast + +extension ObservableType { + + /** + Multicasts the source sequence notifications through the specified subject to the resulting connectable observable. + + Upon connection of the connectable observable, the subject is subscribed to the source exactly one, and messages are forwarded to the observers registered with the connectable observable. + + For specializations with fixed subject types, see `publish` and `replay`. + + - seealso: [multicast operator on reactivex.io](http://reactivex.io/documentation/operators/publish.html) + + - parameter subject: Subject to push source elements into. + - returns: A connectable observable sequence that upon connection causes the source sequence to push results into the specified subject. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func multicast(subject: S) + -> ConnectableObservable { + return ConnectableObservableAdapter(source: self.asObservable(), subject: subject) + } + + /** + Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. + + Each subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's invocation. + + For specializations with fixed subject types, see `publish` and `replay`. + + - seealso: [multicast operator on reactivex.io](http://reactivex.io/documentation/operators/publish.html) + + - parameter subjectSelector: Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function. + - parameter selector: Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func multicast(subjectSelector: () throws -> S, selector: (Observable) throws -> Observable) + -> Observable { + return Multicast( + source: self.asObservable(), + subjectSelector: subjectSelector, + selector: selector + ) + } +} + +// MARK: publish + +extension ObservableType { + + /** + Returns a connectable observable sequence that shares a single subscription to the underlying sequence. + + This operator is a specialization of `multicast` using a `PublishSubject`. + + - seealso: [publish operator on reactivex.io](http://reactivex.io/documentation/operators/publish.html) + + - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func publish() -> ConnectableObservable { + return self.multicast(PublishSubject()) + } +} + +// MARK: replay + +extension ObservableType { + + /** + Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize elements. + + This operator is a specialization of `multicast` using a `ReplaySubject`. + + - seealso: [replay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - parameter bufferSize: Maximum element count of the replay buffer. + - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func replay(bufferSize: Int) + -> ConnectableObservable { + return self.multicast(ReplaySubject.create(bufferSize: bufferSize)) + } + + /** + Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all elements. + + This operator is a specialization of `multicast` using a `ReplaySubject`. + + - seealso: [replay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func replayAll() + -> ConnectableObservable { + return self.multicast(ReplaySubject.createUnbounded()) + } +} + +// MARK: refcount + +extension ConnectableObservableType { + + /** + Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence. + + - seealso: [refCount operator on reactivex.io](http://reactivex.io/documentation/operators/refCount.html) + + - returns: An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func refCount() -> Observable { + return RefCount(source: self) + } +} + +// MARK: share + +extension ObservableType { + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence. + + This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + - seealso: [share operator on reactivex.io](http://reactivex.io/documentation/operators/refcount.html) + + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func share() -> Observable { + return self.publish().refCount() + } +} + +// MARK: shareReplay + +extension ObservableType { + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays maximum number of elements in buffer. + + This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - parameter bufferSize: Maximum element count of the replay buffer. + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func shareReplay(bufferSize: Int) + -> Observable { + if bufferSize == 1 { + return ShareReplay1(source: self.asObservable()) + } + else { + return self.replay(bufferSize).refCount() + } + } + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays latest element in buffer. + + This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + Unlike `shareReplay(bufferSize: Int)`, this operator will clear latest element from replay buffer in case number of subscribers drops from one to zero. In case sequence + completes or errors out replay buffer is also cleared. + + - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func shareReplayLatestWhileConnected() + -> Observable { + return ShareReplay1WhileConnected(source: self.asObservable()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift new file mode 100644 index 00000000000..f8875a53c50 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift @@ -0,0 +1,62 @@ +// +// Observable+Concurrency.swift +// Rx +// +// Created by Krunoslav Zaher on 3/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: observeOn + +extension ObservableType { + + /** + Wraps the source sequence in order to run its observer callbacks on the specified scheduler. + + This only invokes observer callbacks on a `scheduler`. In case the subscription and/or unsubscription + actions have side-effects that require to be run on a scheduler, use `subscribeOn`. + + - seealso: [observeOn operator on reactivex.io](http://reactivex.io/documentation/operators/observeon.html) + + - parameter scheduler: Scheduler to notify observers on. + - returns: The source sequence whose observations happen on the specified scheduler. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func observeOn(scheduler: ImmediateSchedulerType) + -> Observable { + if let scheduler = scheduler as? SerialDispatchQueueScheduler { + return ObserveOnSerialDispatchQueue(source: self.asObservable(), scheduler: scheduler) + } + else { + return ObserveOn(source: self.asObservable(), scheduler: scheduler) + } + } +} + +// MARK: subscribeOn + +extension ObservableType { + + /** + Wraps the source sequence in order to run its subscription and unsubscription logic on the specified + scheduler. + + This operation is not commonly used. + + This only performs the side-effects of subscription and unsubscription on the specified scheduler. + + In order to invoke observer callbacks on a `scheduler`, use `observeOn`. + + - seealso: [subscribeOn operator on reactivex.io](http://reactivex.io/documentation/operators/subscribeon.html) + + - parameter scheduler: Scheduler to perform subscription and unsubscription actions on. + - returns: The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func subscribeOn(scheduler: ImmediateSchedulerType) + -> Observable { + return SubscribeOn(source: self, scheduler: scheduler) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift new file mode 100644 index 00000000000..f14f9c285a2 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift @@ -0,0 +1,219 @@ +// +// Observable+Creation.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension Observable { + // MARK: create + + /** + Creates an observable sequence from a specified subscribe method implementation. + + - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html) + + - parameter subscribe: Implementation of the resulting observable sequence's `subscribe` method. + - returns: The observable sequence with the specified implementation for the `subscribe` method. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func create(subscribe: (AnyObserver) -> Disposable) -> Observable { + return AnonymousObservable(subscribe) + } + + // MARK: empty + + /** + Returns an empty observable sequence, using the specified scheduler to send out the single `Completed` message. + + - seealso: [empty operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) + + - returns: An observable sequence with no elements. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func empty() -> Observable { + return Empty() + } + + // MARK: never + + /** + Returns a non-terminating observable sequence, which can be used to denote an infinite duration. + + - seealso: [never operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) + + - returns: An observable sequence whose observers will never get called. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func never() -> Observable { + return Never() + } + + // MARK: just + + /** + Returns an observable sequence that contains a single element. + + - seealso: [just operator on reactivex.io](http://reactivex.io/documentation/operators/just.html) + + - parameter element: Single element in the resulting observable sequence. + - returns: An observable sequence containing the single specified element. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func just(element: E) -> Observable { + return Just(element: element) + } + + /** + Returns an observable sequence that contains a single element. + + - seealso: [just operator on reactivex.io](http://reactivex.io/documentation/operators/just.html) + + - parameter element: Single element in the resulting observable sequence. + - parameter: Scheduler to send the single element on. + - returns: An observable sequence containing the single specified element. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func just(element: E, scheduler: ImmediateSchedulerType) -> Observable { + return JustScheduled(element: element, scheduler: scheduler) + } + + // MARK: fail + + /** + Returns an observable sequence that terminates with an `error`. + + - seealso: [throw operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) + + - returns: The observable sequence that terminates with specified error. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func error(error: ErrorType) -> Observable { + return Error(error: error) + } + + // MARK: of + + /** + This method creates a new Observable instance with a variable number of elements. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - parameter elements: Elements to generate. + - parameter scheduler: Scheduler to send elements on. If `nil`, elements are sent immediatelly on subscription. + - returns: The observable sequence whose elements are pulled from the given arguments. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func of(elements: E ..., scheduler: ImmediateSchedulerType? = nil) -> Observable { + return Sequence(elements: elements, scheduler: scheduler) + } + + // MARK: defer + + /** + Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. + + - seealso: [defer operator on reactivex.io](http://reactivex.io/documentation/operators/defer.html) + + - parameter observableFactory: Observable factory function to invoke for each observer that subscribes to the resulting sequence. + - returns: An observable sequence whose observers trigger an invocation of the given observable factory function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func deferred(observableFactory: () throws -> Observable) + -> Observable { + return Deferred(observableFactory: observableFactory) + } + + /** + Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler + to run the loop send out observer messages. + + - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html) + + - parameter initialState: Initial state. + - parameter condition: Condition to terminate generation (upon returning `false`). + - parameter iterate: Iteration step function. + - parameter scheduler: Scheduler on which to run the generator loop. + - returns: The generated sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func generate(initialState initialState: E, condition: E throws -> Bool, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance, iterate: E throws -> E) -> Observable { + return Generate(initialState: initialState, condition: condition, iterate: iterate, resultSelector: { $0 }, scheduler: scheduler) + } + + /** + Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages. + + - seealso: [repeat operator on reactivex.io](http://reactivex.io/documentation/operators/repeat.html) + + - parameter element: Element to repeat. + - parameter scheduler: Scheduler to run the producer loop on. + - returns: An observable sequence that repeats the given element infinitely. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func repeatElement(element: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return RepeatElement(element: element, scheduler: scheduler) + } + + /** + Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. + + - seealso: [using operator on reactivex.io](http://reactivex.io/documentation/operators/using.html) + + - parameter resourceFactory: Factory function to obtain a resource object. + - parameter observableFactory: Factory function to obtain an observable sequence that depends on the obtained resource. + - returns: An observable sequence whose lifetime controls the lifetime of the dependent resource object. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func using(resourceFactory: () throws -> R, observableFactory: R throws -> Observable) -> Observable { + return Using(resourceFactory: resourceFactory, observableFactory: observableFactory) + } +} + +extension Observable where Element : SignedIntegerType { + /** + Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages. + + - seealso: [range operator on reactivex.io](http://reactivex.io/documentation/operators/range.html) + + - parameter start: The value of the first integer in the sequence. + - parameter count: The number of sequential integers to generate. + - parameter scheduler: Scheduler to run the generator loop on. + - returns: An observable sequence that contains a range of sequential integral numbers. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func range(start start: E, count: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return RangeProducer(start: start, count: count, scheduler: scheduler) + } +} + +extension SequenceType { + /** + Converts a sequence to an observable sequence. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - returns: The observable sequence whose elements are pulled from the given enumerable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func toObservable(scheduler: ImmediateSchedulerType? = nil) -> Observable { + return Sequence(elements: Array(self), scheduler: scheduler) + } +} + +extension Array { + /** + Converts a sequence to an observable sequence. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - returns: The observable sequence whose elements are pulled from the given enumerable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func toObservable(scheduler: ImmediateSchedulerType? = nil) -> Observable { + return Sequence(elements: self, scheduler: scheduler) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift new file mode 100644 index 00000000000..5d058789b81 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift @@ -0,0 +1,28 @@ +// +// Observable+Debug.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: debug + +extension ObservableType { + + /** + Prints received events for all observers on standard output. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter identifier: Identifier that is printed together with event description to standard output. + - returns: An observable sequence whose events are printed to standard output. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) + -> Observable { + return Debug(source: self.asObservable(), identifier: identifier, file: file, line: line, function: function) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift new file mode 100644 index 00000000000..ae2bf50be73 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift @@ -0,0 +1,330 @@ +// +// Observable+Multiple.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: combineLatest + +extension CollectionType where Generator.Element : ObservableType { + + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combinelatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func combineLatest(resultSelector: [Generator.Element.E] throws -> R) -> Observable { + return CombineLatestCollectionType(sources: self, resultSelector: resultSelector) + } +} + +// MARK: zip + +extension CollectionType where Generator.Element : ObservableType { + + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func zip(resultSelector: [Generator.Element.E] throws -> R) -> Observable { + return ZipCollectionType(sources: self, resultSelector: resultSelector) + } +} + +// MARK: switch + +extension ObservableType where E : ObservableConvertibleType { + + /** + Transforms an observable sequence of observable sequences into an observable sequence + producing values only from the most recent observable sequence. + + Each time a new inner observable sequence is received, unsubscribe from the + previous inner observable sequence. + + - seealso: [switch operator on reactivex.io](http://reactivex.io/documentation/operators/switch.html) + + - returns: The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func switchLatest() -> Observable { + return Switch(source: asObservable()) + } +} + +// MARK: concat + +extension ObservableType { + + /** + Concatenates the second observable sequence to `self` upon successful termination of `self`. + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - parameter second: Second observable sequence. + - returns: An observable sequence that contains the elements of `self`, followed by those of the second sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func concat(second: O) -> Observable { + return [asObservable(), second.asObservable()].concat() + } +} + +extension SequenceType where Generator.Element : ObservableType { + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + This operator has tail recursive optimizations that will prevent stack overflow. + + Optimizations will be performed in cases equivalent to following: + + [1, [2, [3, .....].concat()].concat].concat() + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func concat() + -> Observable { + return Concat(sources: self, count: nil) + } +} + +extension CollectionType where Generator.Element : ObservableType { + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + This operator has tail recursive optimizations that will prevent stack overflow and enable generating + infinite observable sequences while using limited amount of memory during generation. + + Optimizations will be performed in cases equivalent to following: + + [1, [2, [3, .....].concat()].concat].concat() + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func concat() + -> Observable { + return Concat(sources: self, count: self.count.toIntMax()) + } +} + +extension ObservableType where E : ObservableConvertibleType { + + /** + Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully. + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each observed inner sequence, in sequential order. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func concat() -> Observable { + return merge(maxConcurrent: 1) + } +} + +// MARK: merge + +extension ObservableType where E : ObservableConvertibleType { + + /** + Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence. + + - seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html) + + - returns: The observable sequence that merges the elements of the observable sequences. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func merge() -> Observable { + return Merge(source: asObservable()) + } + + /** + Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences. + + - seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html) + + - parameter maxConcurrent: Maximum number of inner observable sequences being subscribed to concurrently. + - returns: The observable sequence that merges the elements of the inner sequences. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func merge(maxConcurrent maxConcurrent: Int) + -> Observable { + return MergeLimited(source: asObservable(), maxConcurrent: maxConcurrent) + } +} + +// MARK: catch + +extension ObservableType { + + /** + Continues an observable sequence that is terminated by an error with the observable sequence produced by the handler. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - parameter handler: Error handler function, producing another observable sequence. + - returns: An observable sequence containing the source sequence's elements, followed by the elements produced by the handler's resulting observable sequence in case an error occurred. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func catchError(handler: (ErrorType) throws -> Observable) + -> Observable { + return Catch(source: asObservable(), handler: handler) + } + + /** + Continues an observable sequence that is terminated by an error with a single element. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - parameter element: Last element in an observable sequence in case error occurs. + - returns: An observable sequence containing the source sequence's elements, followed by the `element` in case an error occurred. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func catchErrorJustReturn(element: E) + -> Observable { + return Catch(source: asObservable(), handler: { _ in Observable.just(element) }) + } + +} + +extension SequenceType where Generator.Element : ObservableType { + /** + Continues an observable sequence that is terminated by an error with the next observable sequence. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - returns: An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func catchError() + -> Observable { + return CatchSequence(sources: self) + } +} + +// MARK: takeUntil + +extension ObservableType { + + /** + Returns the elements from the source observable sequence until the other observable sequence produces an element. + + - seealso: [takeUntil operator on reactivex.io](http://reactivex.io/documentation/operators/takeuntil.html) + + - parameter other: Observable sequence that terminates propagation of elements of the source sequence. + - returns: An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func takeUntil(other: O) + -> Observable { + return TakeUntil(source: asObservable(), other: other.asObservable()) + } +} + +// MARK: skipUntil + +extension ObservableType { + + /** + Returns the elements from the source observable sequence that are emitted after the other observable sequence produces an element. + + - seealso: [skipUntil operator on reactivex.io](http://reactivex.io/documentation/operators/skipuntil.html) + + - parameter other: Observable sequence that starts propagation of elements of the source sequence. + - returns: An observable sequence containing the elements of the source sequence that are emitted after the other sequence emits an item. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func skipUntil(other: O) + -> Observable { + return SkipUntil(source: asObservable(), other: other.asObservable()) + } +} + +// MARK: amb + +extension ObservableType { + + /** + Propagates the observable sequence that reacts first. + + - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html) + + - parameter right: Second observable sequence. + - returns: An observable sequence that surfaces either of the given sequences, whichever reacted first. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func amb + (right: O2) + -> Observable { + return Amb(left: asObservable(), right: right.asObservable()) + } +} + +extension SequenceType where Generator.Element : ObservableType { + + /** + Propagates the observable sequence that reacts first. + + - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html) + + - returns: An observable sequence that surfaces any of the given sequences, whichever reacted first. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func amb() + -> Observable { + return self.reduce(Observable.never()) { a, o in + return a.amb(o.asObservable()) + } + } +} + +// withLatestFrom + +extension ObservableType { + + /** + Merges two observable sequences into one observable sequence by combining each element from self with the latest element from the second source, if any. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter second: Second observable source. + - parameter resultSelector: Function to invoke for each element from the self combined with the latest element from the second source, if any. + - returns: An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function. + */ + public func withLatestFrom(second: SecondO, resultSelector: (E, SecondO.E) throws -> ResultType) -> Observable { + return WithLatestFrom(first: asObservable(), second: second.asObservable(), resultSelector: resultSelector) + } + + /** + Merges two observable sequences into one observable sequence by using latest element from the second sequence every time when `self` emitts an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter second: Second observable source. + - returns: An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function. + */ + public func withLatestFrom(second: SecondO) -> Observable { + return WithLatestFrom(first: asObservable(), second: second.asObservable(), resultSelector: { $1 }) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift new file mode 100644 index 00000000000..088fb61f183 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift @@ -0,0 +1,258 @@ +// +// Observable+Single.swift +// Rx +// +// Created by Krunoslav Zaher on 2/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: distinct until changed + +extension ObservableType where E: Equatable { + + /** + Returns an observable sequence that contains only distinct contiguous elements according to equality operator. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - returns: An observable sequence only containing the distinct contiguous elements, based on equality operator, from the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func distinctUntilChanged() + -> Observable { + return self.distinctUntilChanged({ $0 }, comparer: { ($0 == $1) }) + } +} + +extension ObservableType { + /** + Returns an observable sequence that contains only distinct contiguous elements according to the `keySelector`. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - parameter keySelector: A function to compute the comparison key for each element. + - returns: An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func distinctUntilChanged(keySelector: (E) throws -> K) + -> Observable { + return self.distinctUntilChanged(keySelector, comparer: { $0 == $1 }) + } + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the `comparer`. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - parameter comparer: Equality comparer for computed key values. + - returns: An observable sequence only containing the distinct contiguous elements, based on `comparer`, from the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func distinctUntilChanged(comparer: (lhs: E, rhs: E) throws -> Bool) + -> Observable { + return self.distinctUntilChanged({ $0 }, comparer: comparer) + } + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - parameter keySelector: A function to compute the comparison key for each element. + - parameter comparer: Equality comparer for computed key values. + - returns: An observable sequence only containing the distinct contiguous elements, based on a computed key value and the comparer, from the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func distinctUntilChanged(keySelector: (E) throws -> K, comparer: (lhs: K, rhs: K) throws -> Bool) + -> Observable { + return DistinctUntilChanged(source: self.asObservable(), selector: keySelector, comparer: comparer) + } +} + +// MARK: doOn + +extension ObservableType { + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter eventHandler: Action to invoke for each event in the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func doOn(eventHandler: (Event) throws -> Void) + -> Observable { + return Do(source: self.asObservable(), eventHandler: eventHandler) + } + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func doOn(onNext onNext: (E throws -> Void)? = nil, onError: (ErrorType throws -> Void)? = nil, onCompleted: (() throws -> Void)? = nil) + -> Observable { + return Do(source: self.asObservable()) { e in + switch e { + case .Next(let element): + try onNext?(element) + case .Error(let e): + try onError?(e) + case .Completed: + try onCompleted?() + } + } + } + + /** + Invokes an action for each Next event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func doOnNext(onNext: (E throws -> Void)) + -> Observable { + return self.doOn(onNext: onNext) + } + + /** + Invokes an action for the Error event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func doOnError(onError: (ErrorType throws -> Void)) + -> Observable { + return self.doOn(onError: onError) + } + + /** + Invokes an action for the Completed event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func doOnCompleted(onCompleted: (() throws -> Void)) + -> Observable { + return self.doOn(onCompleted: onCompleted) + } +} + +// MARK: startWith + +extension ObservableType { + + /** + Prepends a sequence of values to an observable sequence. + + - seealso: [startWith operator on reactivex.io](http://reactivex.io/documentation/operators/startwith.html) + + - parameter elements: Elements to prepend to the specified sequence. + - returns: The source sequence prepended with the specified values. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func startWith(elements: E ...) + -> Observable { + return StartWith(source: self.asObservable(), elements: elements) + } +} + +// MARK: retry + +extension ObservableType { + + /** + Repeats the source observable sequence until it successfully terminates. + + **This could potentially create an infinite sequence.** + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - returns: Observable sequence to repeat until it successfully terminates. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func retry() -> Observable { + return CatchSequence(sources: InfiniteSequence(repeatedValue: self.asObservable())) + } + + /** + Repeats the source observable sequence the specified number of times in case of an error or until it successfully terminates. + + If you encounter an error and want it to retry once, then you must use `retry(2)` + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - parameter maxAttemptCount: Maximum number of times to repeat the sequence. + - returns: An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func retry(maxAttemptCount: Int) + -> Observable { + return CatchSequence(sources: Repeat(count: maxAttemptCount, repeatedValue: self.asObservable())) + } + + /** + Repeats the source observable sequence on error when the notifier emits a next value. + If the source observable errors and the notifier completes, it will complete the source sequence. + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - parameter notificationHandler: A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable. + - returns: An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func retryWhen(notificationHandler: Observable -> TriggerObservable) + -> Observable { + return RetryWhenSequence(sources: InfiniteSequence(repeatedValue: self.asObservable()), notificationHandler: notificationHandler) + } + + /** + Repeats the source observable sequence on error when the notifier emits a next value. + If the source observable errors and the notifier completes, it will complete the source sequence. + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - parameter notificationHandler: A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable. + - returns: An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func retryWhen(notificationHandler: Observable -> TriggerObservable) + -> Observable { + return RetryWhenSequence(sources: InfiniteSequence(repeatedValue: self.asObservable()), notificationHandler: notificationHandler) + } +} + +// MARK: scan + +extension ObservableType { + + /** + Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value. + + For aggregation behavior with no intermediate results, see `reduce`. + + - seealso: [scan operator on reactivex.io](http://reactivex.io/documentation/operators/scan.html) + + - parameter seed: The initial accumulator value. + - parameter accumulator: An accumulator function to be invoked on each element. + - returns: An observable sequence containing the accumulated values. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func scan(seed: A, accumulator: (A, E) throws -> A) + -> Observable { + return Scan(source: self.asObservable(), seed: seed, accumulator: accumulator) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift new file mode 100644 index 00000000000..96fe5fe24ec --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift @@ -0,0 +1,323 @@ +// +// Observable+StandardSequenceOperators.swift +// Rx +// +// Created by Krunoslav Zaher on 2/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: filter aka where + +extension ObservableType { + + /** + Filters the elements of an observable sequence based on a predicate. + + - seealso: [filter operator on reactivex.io](http://reactivex.io/documentation/operators/filter.html) + + - parameter predicate: A function to test each source element for a condition. + - returns: An observable sequence that contains elements from the input sequence that satisfy the condition. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func filter(predicate: (E) throws -> Bool) + -> Observable { + return Filter(source: asObservable(), predicate: predicate) + } +} + +// MARK: takeWhile + +extension ObservableType { + + /** + Returns elements from an observable sequence as long as a specified condition is true. + + - seealso: [takeWhile operator on reactivex.io](http://reactivex.io/documentation/operators/takewhile.html) + + - parameter predicate: A function to test each element for a condition. + - returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func takeWhile(predicate: (E) throws -> Bool) + -> Observable { + return TakeWhile(source: asObservable(), predicate: predicate) + } + + /** + Returns elements from an observable sequence as long as a specified condition is true. + + The element's index is used in the logic of the predicate function. + + - seealso: [takeWhile operator on reactivex.io](http://reactivex.io/documentation/operators/takewhile.html) + + - parameter predicate: A function to test each element for a condition; the second parameter of the function represents the index of the source element. + - returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func takeWhileWithIndex(predicate: (E, Int) throws -> Bool) + -> Observable { + return TakeWhile(source: asObservable(), predicate: predicate) + } +} + +// MARK: take + +extension ObservableType { + + /** + Returns a specified number of contiguous elements from the start of an observable sequence. + + - seealso: [take operator on reactivex.io](http://reactivex.io/documentation/operators/take.html) + + - parameter count: The number of elements to return. + - returns: An observable sequence that contains the specified number of elements from the start of the input sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func take(count: Int) + -> Observable { + if count == 0 { + return Observable.empty() + } + else { + return TakeCount(source: asObservable(), count: count) + } + } +} + +// MARK: takeLast + +extension ObservableType { + + /** + Returns a specified number of contiguous elements from the end of an observable sequence. + + This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed. + + - seealso: [takeLast operator on reactivex.io](http://reactivex.io/documentation/operators/takelast.html) + + - parameter count: Number of elements to take from the end of the source sequence. + - returns: An observable sequence containing the specified number of elements from the end of the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func takeLast(count: Int) + -> Observable { + return TakeLast(source: asObservable(), count: count) + } +} + + +// MARK: skip + +extension ObservableType { + + /** + Bypasses a specified number of elements in an observable sequence and then returns the remaining elements. + + - seealso: [skip operator on reactivex.io](http://reactivex.io/documentation/operators/skip.html) + + - parameter count: The number of elements to skip before returning the remaining elements. + - returns: An observable sequence that contains the elements that occur after the specified index in the input sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func skip(count: Int) + -> Observable { + return SkipCount(source: asObservable(), count: count) + } +} + +// MARK: SkipWhile + +extension ObservableType { + + /** + Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. + + - seealso: [skipWhile operator on reactivex.io](http://reactivex.io/documentation/operators/skipwhile.html) + + - parameter predicate: A function to test each element for a condition. + - returns: An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func skipWhile(predicate: (E) throws -> Bool) -> Observable { + return SkipWhile(source: asObservable(), predicate: predicate) + } + + /** + Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. + The element's index is used in the logic of the predicate function. + + - seealso: [skipWhile operator on reactivex.io](http://reactivex.io/documentation/operators/skipwhile.html) + + - parameter predicate: A function to test each element for a condition; the second parameter of the function represents the index of the source element. + - returns: An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func skipWhileWithIndex(predicate: (E, Int) throws -> Bool) -> Observable { + return SkipWhile(source: asObservable(), predicate: predicate) + } +} + +// MARK: map aka select + +extension ObservableType { + + /** + Projects each element of an observable sequence into a new form. + + - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) + + - parameter selector: A transform function to apply to each source element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source. + + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func map(selector: E throws -> R) + -> Observable { + return self.asObservable().composeMap(selector) + } + + /** + Projects each element of an observable sequence into a new form by incorporating the element's index. + + - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) + + - parameter selector: A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func mapWithIndex(selector: (E, Int) throws -> R) + -> Observable { + return MapWithIndex(source: asObservable(), selector: selector) + } +} + +// MARK: flatMap + +extension ObservableType { + + /** + Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + + - seealso: [flatMap operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to each element. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func flatMap(selector: (E) throws -> O) + -> Observable { + return FlatMap(source: asObservable(), selector: selector) + } + + /** + Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence. + + - seealso: [flatMap operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to each element; the second parameter of the function represents the index of the source element. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func flatMapWithIndex(selector: (E, Int) throws -> O) + -> Observable { + return FlatMapWithIndex(source: asObservable(), selector: selector) + } +} + +// MARK: flatMapFirst + +extension ObservableType { + + /** + Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + If element is received while there is some projected observable sequence being merged it will simply be ignored. + + - seealso: [flatMapFirst operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to element that was observed while no observable is executing in parallel. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence that was received while no other sequence was being calculated. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func flatMapFirst(selector: (E) throws -> O) + -> Observable { + return FlatMapFirst(source: asObservable(), selector: selector) + } +} + +// MARK: flatMapLatest + +extension ObservableType { + /** + Projects each element of an observable sequence into a new sequence of observable sequences and then + transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + + It is a combination of `map` + `switchLatest` operator + + - seealso: [flatMapLatest operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to each element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source producing an + Observable of Observable sequences and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func flatMapLatest(selector: (E) throws -> O) + -> Observable { + return FlatMapLatest(source: asObservable(), selector: selector) + } +} + +// MARK: elementAt + +extension ObservableType { + + /** + Returns a sequence emitting only item _n_ emitted by an Observable + + - seealso: [elementAt operator on reactivex.io](http://reactivex.io/documentation/operators/elementat.html) + + - parameter index: The index of the required item (starting from 0). + - returns: An observable sequence that emits the desired item as its own sole emission. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func elementAt(index: Int) + -> Observable { + return ElementAt(source: asObservable(), index: index, throwOnEmpty: true) + } +} + +// MARK: single + +extension ObservableType { + + /** + The single operator is similar to first, but throws a `RxError.NoElements` or `RxError.MoreThanOneElement` + if the source Observable does not emit exactly one item before successfully completing. + + - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) + + - returns: An observable sequence that emits a single item or throws an exception if more (or none) of them are emitted. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func single() + -> Observable { + return SingleAsync(source: asObservable()) + } + + /** + The single operator is similar to first, but throws a `RxError.NoElements` or `RxError.MoreThanOneElement` + if the source Observable does not emit exactly one item before successfully completing. + + - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) + + - parameter predicate: A function to test each source element for a condition. + - returns: An observable sequence that emits a single item or throws an exception if more (or none) of them are emitted. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func single(predicate: (E) throws -> Bool) + -> Observable { + return SingleAsync(source: asObservable(), predicate: predicate) + } + +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift new file mode 100644 index 00000000000..d1c93be0eb2 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift @@ -0,0 +1,274 @@ +// +// Observable+Time.swift +// Rx +// +// Created by Krunoslav Zaher on 3/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: throttle +extension ObservableType { + + /** + Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers. + + `throttle` and `debounce` are synonyms. + + - seealso: [debounce operator on reactivex.io](http://reactivex.io/documentation/operators/debounce.html) + + - parameter dueTime: Throttling duration for each element. + - parameter scheduler: Scheduler to run the throttle timers and send events on. + - returns: The throttled sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func throttle(dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Throttle(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) + } + + /** + Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers. + + `throttle` and `debounce` are synonyms. + + - seealso: [debounce operator on reactivex.io](http://reactivex.io/documentation/operators/debounce.html) + + - parameter dueTime: Throttling duration for each element. + - parameter scheduler: Scheduler to run the throttle timers and send events on. + - returns: The throttled sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func debounce(dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Throttle(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) + } +} + +// MARK: sample + +extension ObservableType { + + /** + Samples the source observable sequence using a samper observable sequence producing sampling ticks. + + Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence. + + **In case there were no new elements between sampler ticks, no element is sent to the resulting sequence.** + + - seealso: [sample operator on reactivex.io](http://reactivex.io/documentation/operators/sample.html) + + - parameter sampler: Sampling tick sequence. + - returns: Sampled observable sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func sample(sampler: O) + -> Observable { + return Sample(source: self.asObservable(), sampler: sampler.asObservable(), onlyNew: true) + } +} + +extension Observable where Element : SignedIntegerType { + /** + Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages. + + - seealso: [interval operator on reactivex.io](http://reactivex.io/documentation/operators/interval.html) + + - parameter period: Period for producing the values in the resulting sequence. + - parameter scheduler: Scheduler to run the timer on. + - returns: An observable sequence that produces a value after each period. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func interval(period: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Timer(dueTime: period, + period: period, + scheduler: scheduler + ) + } +} + +// MARK: timer + +extension Observable where Element: SignedIntegerType { + /** + Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers. + + - seealso: [timer operator on reactivex.io](http://reactivex.io/documentation/operators/timer.html) + + - parameter dueTime: Relative time at which to produce the first value. + - parameter period: Period to produce subsequent values. + - parameter scheduler: Scheduler to run timers on. + - returns: An observable sequence that produces a value after due time has elapsed and then each period. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public static func timer(dueTime: RxTimeInterval, period: RxTimeInterval? = nil, scheduler: SchedulerType) + -> Observable { + return Timer( + dueTime: dueTime, + period: period, + scheduler: scheduler + ) + } +} + +// MARK: take + +extension ObservableType { + + /** + Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + + - seealso: [take operator on reactivex.io](http://reactivex.io/documentation/operators/take.html) + + - parameter duration: Duration for taking elements from the start of the sequence. + - parameter scheduler: Scheduler to run the timer on. + - returns: An observable sequence with the elements taken during the specified duration from the start of the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func take(duration: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return TakeTime(source: self.asObservable(), duration: duration, scheduler: scheduler) + } +} + +// MARK: skip + +extension ObservableType { + + /** + Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + + - seealso: [skip operator on reactivex.io](http://reactivex.io/documentation/operators/skip.html) + + - parameter duration: Duration for skipping elements from the start of the sequence. + - parameter scheduler: Scheduler to run the timer on. + - returns: An observable sequence with the elements skipped during the specified duration from the start of the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func skip(duration: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return SkipTime(source: self.asObservable(), duration: duration, scheduler: scheduler) + } +} + +// MARK: ignoreElements + +extension ObservableType { + + /** + Skips elements and completes (or errors) when the receiver completes (or errors). Equivalent to filter that always returns false. + + - seealso: [ignoreElements operator on reactivex.io](http://reactivex.io/documentation/operators/ignoreelements.html) + + - returns: An observable sequence that skips all elements of the source sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func ignoreElements() + -> Observable { + return filter { _ -> Bool in + return false + } + } +} + +// MARK: delaySubscription + +extension ObservableType { + + /** + Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. + + - seealso: [delay operator on reactivex.io](http://reactivex.io/documentation/operators/delay.html) + + - parameter dueTime: Relative time shift of the subscription. + - parameter scheduler: Scheduler to run the subscription delay timer on. + - returns: Time-shifted sequence. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func delaySubscription(dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return DelaySubscription(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) + } +} + +// MARK: buffer + +extension ObservableType { + + /** + Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed, using the specified scheduler to run timers. + + A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first. + + - seealso: [buffer operator on reactivex.io](http://reactivex.io/documentation/operators/buffer.html) + + - parameter timeSpan: Maximum time length of a buffer. + - parameter count: Maximum element count of a buffer. + - parameter scheduler: Scheduler to run buffering timers on. + - returns: An observable sequence of buffers. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func buffer(timeSpan timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) + -> Observable<[E]> { + return BufferTimeCount(source: self.asObservable(), timeSpan: timeSpan, count: count, scheduler: scheduler) + } +} + +// MARK: window + +extension ObservableType { + + /** + Projects each element of an observable sequence into a window that is completed when either it’s full or a given amount of time has elapsed. + + - seealso: [window operator on reactivex.io](http://reactivex.io/documentation/operators/window.html) + + - parameter timeSpan: Maximum time length of a window. + - parameter count: Maximum element count of a window. + - parameter scheduler: Scheduler to run windowing timers on. + - returns: An observable sequence of windows (instances of `Observable`). + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func window(timeSpan timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) + -> Observable> { + return WindowTimeCount(source: self.asObservable(), timeSpan: timeSpan, count: count, scheduler: scheduler) + } +} + +// MARK: timeout + +extension ObservableType { + + /** + Applies a timeout policy for each element in the observable sequence. If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutError is propagated to the observer. + + - seealso: [timeout operator on reactivex.io](http://reactivex.io/documentation/operators/timeout.html) + + - parameter dueTime: Maximum duration between values before a timeout occurs. + - parameter scheduler: Scheduler to run the timeout timer on. + - returns: An observable sequence with a TimeoutError in case of a timeout. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func timeout(dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Timeout(source: self.asObservable(), dueTime: dueTime, other: Observable.error(RxError.Timeout), scheduler: scheduler) + } + + /** + Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers. If the next element isn't received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on. + + - seealso: [timeout operator on reactivex.io](http://reactivex.io/documentation/operators/timeout.html) + + - parameter dueTime: Maximum duration between values before a timeout occurs. + - parameter other: Sequence to return in case of a timeout. + - parameter scheduler: Scheduler to run the timeout timer on. + - returns: The source sequence switching to the other sequence in case of a timeout. + */ + @warn_unused_result(message="http://git.io/rxs.uo") + public func timeout(dueTime: RxTimeInterval, other: O, scheduler: SchedulerType) + -> Observable { + return Timeout(source: self.asObservable(), dueTime: dueTime, other: other.asObservable(), scheduler: scheduler) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObserverType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObserverType.swift new file mode 100644 index 00000000000..0cd46e3967a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/ObserverType.swift @@ -0,0 +1,56 @@ +// +// ObserverType.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Supports push-style iteration over an observable sequence. +*/ +public protocol ObserverType { + /** + The type of elements in sequence that observer can observe. + */ + associatedtype E + + /** + Notify observer about sequence event. + + - parameter event: Event that occured. + */ + func on(event: Event) +} + +/** +Convenience API extensions to provide alternate next, error, completed events +*/ +public extension ObserverType { + + /** + Convenience method equivalent to `on(.Next(element: E))` + + - parameter element: Next element to send to observer(s) + */ + final func onNext(element: E) { + on(.Next(element)) + } + + /** + Convenience method equivalent to `on(.Completed)` + */ + final func onCompleted() { + on(.Completed) + } + + /** + Convenience method equivalent to `on(.Error(error: ErrorType))` + - parameter error: ErrorType to send to observer(s) + */ + final func onError(error: ErrorType) { + on(.Error(error)) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift new file mode 100644 index 00000000000..2bb8f0a4891 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift @@ -0,0 +1,34 @@ +// +// AnonymousObserver.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class AnonymousObserver : ObserverBase { + typealias Element = ElementType + + typealias EventHandler = Event -> Void + + private let _eventHandler : EventHandler + + init(_ eventHandler: EventHandler) { +#if TRACE_RESOURCES + AtomicIncrement(&resourceCount) +#endif + _eventHandler = eventHandler + } + + override func onCore(event: Event) { + return _eventHandler(event) + } + +#if TRACE_RESOURCES + deinit { + AtomicDecrement(&resourceCount) + } +#endif +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift new file mode 100644 index 00000000000..0795952162e --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift @@ -0,0 +1,39 @@ +// +// ObserverBase.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ObserverBase : Disposable, ObserverType { + typealias E = ElementType + + private var _isStopped: AtomicInt = 0 + + func on(event: Event) { + switch event { + case .Next: + if _isStopped == 0 { + onCore(event) + } + case .Error, .Completed: + + if !AtomicCompareAndSwap(0, 1, &_isStopped) { + return + } + + onCore(event) + } + } + + func onCore(event: Event) { + abstractMethod() + } + + func dispose() { + _isStopped = 1 + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift new file mode 100644 index 00000000000..1afecb46209 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift @@ -0,0 +1,151 @@ +// +// TailRecursiveSink.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +enum TailRecursiveSinkCommand { + case MoveNext + case Dispose +} + +#if DEBUG || TRACE_RESOURCES + public var maxTailRecursiveSinkStackSize = 0 +#endif + +/// This class is usually used with `Generator` version of the operators. +class TailRecursiveSink + : Sink + , InvocableWithValueType { + typealias Value = TailRecursiveSinkCommand + typealias E = O.E + typealias SequenceGenerator = (generator: S.Generator, remaining: IntMax?) + + var _generators: [SequenceGenerator] = [] + var _disposed = false + var _subscription = SerialDisposable() + + // this is thread safe object + var _gate = AsyncLock>>() + + override init(observer: O) { + super.init(observer: observer) + } + + func run(sources: SequenceGenerator) -> Disposable { + _generators.append(sources) + + schedule(.MoveNext) + + return _subscription + } + + func invoke(command: TailRecursiveSinkCommand) { + switch command { + case .Dispose: + disposeCommand() + case .MoveNext: + moveNextCommand() + } + } + + // simple implementation for now + func schedule(command: TailRecursiveSinkCommand) { + _gate.invoke(InvocableScheduledItem(invocable: self, state: command)) + } + + func done() { + forwardOn(.Completed) + dispose() + } + + func extract(observable: Observable) -> SequenceGenerator? { + abstractMethod() + } + + // should be done on gate locked + + private func moveNextCommand() { + var next: Observable? = nil + + repeat { + guard let (g, left) = _generators.last else { + break + } + + if _disposed { + return + } + + _generators.removeLast() + + var e = g + + guard let nextCandidate = e.next()?.asObservable() else { + continue + } + + // `left` is a hint of how many elements are left in generator. + // In case this is the last element, then there is no need to push + // that generator on stack. + // + // This is an optimization used to make sure in tail recursive case + // there is no memory leak in case this operator is used to generate non terminating + // sequence. + + if let knownOriginalLeft = left { + // `- 1` because generator.next() has just been called + if knownOriginalLeft - 1 >= 1 { + _generators.append((e, knownOriginalLeft - 1)) + } + } + else { + _generators.append((e, nil)) + } + + let nextGenerator = extract(nextCandidate) + + if let nextGenerator = nextGenerator { + _generators.append(nextGenerator) + #if DEBUG || TRACE_RESOURCES + if maxTailRecursiveSinkStackSize < _generators.count { + maxTailRecursiveSinkStackSize = _generators.count + } + #endif + } + else { + next = nextCandidate + } + } while next == nil + + if next == nil { + done() + return + } + + let disposable = SingleAssignmentDisposable() + _subscription.disposable = disposable + disposable.disposable = subscribeToNext(next!) + } + + func subscribeToNext(source: Observable) -> Disposable { + abstractMethod() + } + + func disposeCommand() { + _disposed = true + _generators.removeAll(keepCapacity: false) + } + + override func dispose() { + super.dispose() + + _subscription.dispose() + + schedule(.Dispose) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift new file mode 100644 index 00000000000..418c9b163b2 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift @@ -0,0 +1,45 @@ +// +// Platform.Darwin.swift +// Rx +// +// Created by Krunoslav Zaher on 12/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(OSX) || os(iOS) || os(tvOS) || os(watchOS) + + import Darwin + import Foundation + + #if TRACE_RESOURCES + public typealias AtomicInt = Int32 + #else + typealias AtomicInt = Int32 + #endif + + let AtomicCompareAndSwap = OSAtomicCompareAndSwap32 + let AtomicIncrement = OSAtomicIncrement32 + let AtomicDecrement = OSAtomicDecrement32 + + extension NSThread { + static func setThreadLocalStorageValue(value: T?, forKey key: protocol) { + let currentThread = NSThread.currentThread() + let threadDictionary = currentThread.threadDictionary + + if let newValue = value { + threadDictionary.setObject(newValue, forKey: key) + } + else { + threadDictionary.removeObjectForKey(key) + } + + } + static func getThreadLocalStorageValueForKey(key: protocol) -> T? { + let currentThread = NSThread.currentThread() + let threadDictionary = currentThread.threadDictionary + + return threadDictionary[key] as? T + } + } + +#endif diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift new file mode 100644 index 00000000000..f5b93681cd0 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift @@ -0,0 +1,222 @@ +// +// Platform.Linux.swift +// Rx +// +// Created by Krunoslav Zaher on 12/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(Linux) + //////////////////////////////////////////////////////////////////////////////// + // This is not the greatest API in the world, this is just a tribute. + // !!! Proof of concept until libdispatch becomes operational. !!! + //////////////////////////////////////////////////////////////////////////////// + + import Foundation + import XCTest + import Glibc + import SwiftShims + + // MARK: CoreFoundation run loop mock + + public typealias CFRunLoopRef = Int + public let kCFRunLoopDefaultMode = "CFRunLoopDefaultMode" + + typealias Action = () -> () + + var queue = Queue(capacity: 100) + + var runLoopCounter = 0 + + extension NSThread { + public var isMainThread: Bool { + return true + } + } + + public func CFRunLoopWakeUp(runLoop: CFRunLoopRef) { + } + + public func CFRunLoopStop(runLoop: CFRunLoopRef) { + runLoopCounter -= 1 + } + + public func CFRunLoopPerformBlock(runLoop: CFRunLoopRef, _ mode: String, _ action: () -> ()) { + queue.enqueue(action) + } + + public func CFRunLoopRun() { + runLoopCounter += 1 + let currentValueOfCounter = runLoopCounter + while let front = queue.dequeue() { + front() + if runLoopCounter < currentValueOfCounter - 1 { + fatalError("called stop twice") + } + + if runLoopCounter == currentValueOfCounter - 1 { + break + } + } + } + + public func CFRunLoopGetCurrent() -> CFRunLoopRef { + return 0 + } + + // MARK: Atomic, just something that works for single thread case + + #if TRACE_RESOURCES + public typealias AtomicInt = Int64 + #else + typealias AtomicInt = Int64 + #endif + + func AtomicIncrement(increment: UnsafeMutablePointer) -> AtomicInt { + increment.memory = increment.memory + 1 + return increment.memory + } + + func AtomicDecrement(increment: UnsafeMutablePointer) -> AtomicInt { + increment.memory = increment.memory - 1 + return increment.memory + } + + func AtomicCompareAndSwap(l: AtomicInt, _ r: AtomicInt, _ target: UnsafeMutablePointer) -> Bool { + //return __sync_val_compare_and_swap(target, l, r) + if target.memory == l { + target.memory = r + return true + } + + return false + } + + extension NSThread { + static func setThreadLocalStorageValue(value: T?, forKey key: String) { + let currentThread = NSThread.currentThread() + var threadDictionary = currentThread.threadDictionary + + if let newValue = value { + threadDictionary[key] = newValue + } + else { + threadDictionary[key] = nil + } + + currentThread.threadDictionary = threadDictionary + } + + static func getThreadLocalStorageValueForKey(key: String) -> T? { + let currentThread = NSThread.currentThread() + let threadDictionary = currentThread.threadDictionary + + return threadDictionary[key] as? T + } + } + + // + + // MARK: objc mock + + public func objc_sync_enter(lock: AnyObject) { + } + + public func objc_sync_exit(lock: AnyObject) { + + } + + + // MARK: libdispatch + + public typealias dispatch_time_t = Int + public typealias dispatch_source_t = Int + public typealias dispatch_source_type_t = Int + public typealias dispatch_queue_t = Int + public typealias dispatch_object_t = Int + public typealias dispatch_block_t = () -> () + public typealias dispatch_queue_attr_t = Int + public typealias qos_class_t = Int + + public let DISPATCH_QUEUE_SERIAL = 0 + + public let DISPATCH_QUEUE_PRIORITY_HIGH = 1 + public let DISPATCH_QUEUE_PRIORITY_DEFAULT = 2 + public let DISPATCH_QUEUE_PRIORITY_LOW = 3 + + public let QOS_CLASS_USER_INTERACTIVE = 0 + public let QOS_CLASS_USER_INITIATED = 1 + public let QOS_CLASS_DEFAULT = 2 + public let QOS_CLASS_UTILITY = 3 + public let QOS_CLASS_BACKGROUND = 4 + + public let DISPATCH_SOURCE_TYPE_TIMER = 0 + public let DISPATCH_TIME_FOREVER = 1 as UInt64 + public let NSEC_PER_SEC = 1 + + public let DISPATCH_TIME_NOW = -1 + + public func dispatch_time(when: dispatch_time_t, _ delta: Int64) -> dispatch_time_t { + return when + Int(delta) + } + + public func dispatch_queue_create(label: UnsafePointer, _ attr: dispatch_queue_attr_t!) -> dispatch_queue_t! { + return 0 + } + + public func dispatch_set_target_queue(object: dispatch_object_t!, _ queue: dispatch_queue_t!) { + } + + public func dispatch_async(queue2: dispatch_queue_t, _ block: dispatch_block_t) { + queue.enqueue(block) + } + + public func dispatch_source_create(type: dispatch_source_type_t, _ handle: UInt, _ mask: UInt, _ queue: dispatch_queue_t!) -> dispatch_source_t! { + return 0 + } + + public func dispatch_source_set_timer(source: dispatch_source_t, _ start: dispatch_time_t, _ interval: UInt64, _ leeway: UInt64) { + + } + + public func dispatch_source_set_event_handler(source: dispatch_source_t, _ handler: dispatch_block_t!) { + queue.enqueue(handler) + } + + public func dispatch_resume(object: dispatch_object_t) { + } + + public func dispatch_source_cancel(source: dispatch_source_t) { + } + + public func dispatch_get_global_queue(identifier: Int, _ flags: UInt) -> dispatch_queue_t! { + return 0 + } + + public func dispatch_get_main_queue() -> dispatch_queue_t! { + return 0 + } + + // MARK: XCTest + + public class Expectation { + public func fulfill() { + } + } + + extension XCTestCase { + public func setUp() { + } + + public func tearDown() { + } + + public func expectationWithDescription(description: String) -> Expectation { + return Expectation() + } + + public func waitForExpectationsWithTimeout(time: NSTimeInterval, action: ErrorType? -> Void) { + } + } + +#endif diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Rx.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Rx.swift new file mode 100644 index 00000000000..8e33574e976 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Rx.swift @@ -0,0 +1,42 @@ +// +// Rx.swift +// Rx +// +// Created by Krunoslav Zaher on 2/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if TRACE_RESOURCES +/// Counts internal Rx resource allocations (Observables, Observers, Disposables, etc.). This provides a simple way to detect leaks during development. +public var resourceCount: AtomicInt = 0 +#endif + +/// Swift does not implement abstract methods. This method is used as a runtime check to ensure that methods which intended to be abstract (i.e., they should be implemented in subclasses) are not called directly on the superclass. +@noreturn func abstractMethod() -> Void { + rxFatalError("Abstract method") +} + +@noreturn func rxFatalError(lastMessage: String) { + // The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours. + fatalError(lastMessage) +} + +func incrementChecked(inout i: Int) throws -> Int { + if i == Int.max { + throw RxError.Overflow + } + let result = i + i += 1 + return result +} + +func decrementChecked(inout i: Int) throws -> Int { + if i == Int.min { + throw RxError.Overflow + } + let result = i + i -= 1 + return result +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/RxMutableBox.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/RxMutableBox.swift new file mode 100644 index 00000000000..6f5e5c3e648 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/RxMutableBox.swift @@ -0,0 +1,37 @@ +// +// RxMutableBox.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Creates mutable reference wrapper for any type. +*/ +class RxMutableBox : CustomDebugStringConvertible { + /** + Wrapped value + */ + var value : T + + /** + Creates reference wrapper for `value`. + + - parameter value: Value to wrap. + */ + init (_ value: T) { + self.value = value + } +} + +extension RxMutableBox { + /** + - returns: Box description. + */ + var debugDescription: String { + return "MutatingBox(\(self.value))" + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/SchedulerType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/SchedulerType.swift new file mode 100644 index 00000000000..b88d9cd0701 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/SchedulerType.swift @@ -0,0 +1,78 @@ +// +// SchedulerType.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type that represents time interval in the context of RxSwift. +*/ +public typealias RxTimeInterval = NSTimeInterval + +/** +Type that represents absolute time in the context of RxSwift. +*/ +public typealias RxTime = NSDate + +/** +Represents an object that schedules units of work. +*/ +public protocol SchedulerType: ImmediateSchedulerType { + + /** + - returns: Current time. + */ + var now : RxTime { + get + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func scheduleRelative(state: StateType, dueTime: RxTimeInterval, action: (StateType) -> Disposable) -> Disposable + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func schedulePeriodic(state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: (StateType) -> StateType) -> Disposable +} + +extension SchedulerType { + + /** + Periodic task will be emulated using recursive scheduling. + + - parameter state: Initial state passed to the action upon the first iteration. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - returns: The disposable object used to cancel the scheduled recurring action (best effort). + */ + public func schedulePeriodic(state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: (StateType) -> StateType) -> Disposable { + let schedule = SchedulePeriodicRecursive(scheduler: self, startAfter: startAfter, period: period, action: action, state: state) + + return schedule.start() + } + + func scheduleRecursive(state: State, dueTime: RxTimeInterval, action: (state: State, scheduler: AnyRecursiveScheduler) -> ()) -> Disposable { + let scheduler = AnyRecursiveScheduler(scheduler: self, action: action) + + scheduler.schedule(state, dueTime: dueTime) + + return AnonymousDisposable(scheduler.dispose) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift new file mode 100644 index 00000000000..3f8207aa6a1 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift @@ -0,0 +1,147 @@ +// +// ConcurrentDispatchQueueScheduler.swift +// RxSwift +// +// Created by Krunoslav Zaher on 7/5/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts the work that needs to be performed on a specific `dispatch_queue_t`. You can also pass a serial dispatch queue, it shouldn't cause any problems. + +This scheduler is suitable when some work needs to be performed in background. +*/ +public class ConcurrentDispatchQueueScheduler: SchedulerType { + public typealias TimeInterval = NSTimeInterval + public typealias Time = NSDate + + private let _queue : dispatch_queue_t + + public var now : NSDate { + return NSDate() + } + + // leeway for scheduling timers + private var _leeway: Int64 = 0 + + /** + Constructs new `ConcurrentDispatchQueueScheduler` that wraps `queue`. + + - parameter queue: Target dispatch queue. + */ + public init(queue: dispatch_queue_t) { + _queue = queue + } + + /** + Convenience init for scheduler that wraps one of the global concurrent dispatch queues. + + - parameter globalConcurrentQueueQOS: Target global dispatch queue, by quality of service class. + */ + @available(iOS 8, OSX 10.10, *) + public convenience init(globalConcurrentQueueQOS: DispatchQueueSchedulerQOS) { + let priority = globalConcurrentQueueQOS.QOSClass + self.init(queue: dispatch_get_global_queue(priority, UInt(0))) + } + + + class func convertTimeIntervalToDispatchInterval(timeInterval: NSTimeInterval) -> Int64 { + return Int64(timeInterval * Double(NSEC_PER_SEC)) + } + + class func convertTimeIntervalToDispatchTime(timeInterval: NSTimeInterval) -> dispatch_time_t { + return dispatch_time(DISPATCH_TIME_NOW, convertTimeIntervalToDispatchInterval(timeInterval)) + } + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func schedule(state: StateType, action: StateType -> Disposable) -> Disposable { + return self.scheduleInternal(state, action: action) + } + + func scheduleInternal(state: StateType, action: StateType -> Disposable) -> Disposable { + let cancel = SingleAssignmentDisposable() + + dispatch_async(_queue) { + if cancel.disposed { + return + } + + cancel.disposable = action(state) + } + + return cancel + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func scheduleRelative(state: StateType, dueTime: NSTimeInterval, action: (StateType) -> Disposable) -> Disposable { + let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _queue) + + let dispatchInterval = MainScheduler.convertTimeIntervalToDispatchTime(dueTime) + + let compositeDisposable = CompositeDisposable() + + dispatch_source_set_timer(timer, dispatchInterval, DISPATCH_TIME_FOREVER, 0) + dispatch_source_set_event_handler(timer, { + if compositeDisposable.disposed { + return + } + compositeDisposable.addDisposable(action(state)) + }) + dispatch_resume(timer) + + compositeDisposable.addDisposable(AnonymousDisposable { + dispatch_source_cancel(timer) + }) + + return compositeDisposable + } + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedulePeriodic(state: StateType, startAfter: TimeInterval, period: TimeInterval, action: (StateType) -> StateType) -> Disposable { + let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _queue) + + let initial = MainScheduler.convertTimeIntervalToDispatchTime(startAfter) + let dispatchInterval = MainScheduler.convertTimeIntervalToDispatchInterval(period) + + var timerState = state + + let validDispatchInterval = dispatchInterval < 0 ? 0 : UInt64(dispatchInterval) + + dispatch_source_set_timer(timer, initial, validDispatchInterval, 0) + let cancel = AnonymousDisposable { + dispatch_source_cancel(timer) + } + dispatch_source_set_event_handler(timer, { + if cancel.disposed { + return + } + timerState = action(timerState) + }) + dispatch_resume(timer) + + return cancel + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift new file mode 100644 index 00000000000..c26be800cf5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift @@ -0,0 +1,90 @@ +// +// ConcurrentMainScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 10/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts work that needs to be performed on `MainThread`. In case `schedule` methods are called from main thread, it will perform action immediately without scheduling. + +This scheduler is optimized for `subscribeOn` operator. If you want to observe observable sequence elements on main thread using `observeOn` operator, +`MainScheduler` is more suitable for that purpose. +*/ +public final class ConcurrentMainScheduler : SchedulerType { + public typealias TimeInterval = NSTimeInterval + public typealias Time = NSDate + + private let _mainScheduler: MainScheduler + private let _mainQueue: dispatch_queue_t + + /** + - returns: Current time. + */ + public var now : NSDate { + return _mainScheduler.now + } + + private init(mainScheduler: MainScheduler) { + _mainQueue = dispatch_get_main_queue() + _mainScheduler = mainScheduler + } + + /** + Singleton instance of `ConcurrentMainScheduler` + */ + public static let instance = ConcurrentMainScheduler(mainScheduler: MainScheduler.instance) + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { + if NSThread.currentThread().isMainThread { + return action(state) + } + + let cancel = SingleAssignmentDisposable() + + dispatch_async(_mainQueue) { + if cancel.disposed { + return + } + + cancel.disposable = action(state) + } + + return cancel + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func scheduleRelative(state: StateType, dueTime: NSTimeInterval, action: (StateType) -> Disposable) -> Disposable { + return _mainScheduler.scheduleRelative(state, dueTime: dueTime, action: action) + } + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedulePeriodic(state: StateType, startAfter: TimeInterval, period: TimeInterval, action: (StateType) -> StateType) -> Disposable { + return _mainScheduler.schedulePeriodic(state, startAfter: startAfter, period: period, action: action) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift new file mode 100644 index 00000000000..b1c638847a1 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift @@ -0,0 +1,147 @@ +// +// CurrentThreadScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(Linux) + let CurrentThreadSchedulerKeyInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" + let CurrentThreadSchedulerQueueKeyInstance = "RxSwift.CurrentThreadScheduler.Queue" + + typealias CurrentThreadSchedulerValue = NSString + let CurrentThreadSchedulerValueInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" as NSString +#else + let CurrentThreadSchedulerKeyInstance = CurrentThreadSchedulerKey() + let CurrentThreadSchedulerQueueKeyInstance = CurrentThreadSchedulerQueueKey() + + typealias CurrentThreadSchedulerValue = CurrentThreadSchedulerKey + let CurrentThreadSchedulerValueInstance = CurrentThreadSchedulerKeyInstance + + class CurrentThreadSchedulerKey : NSObject, NSCopying { + override func isEqual(object: AnyObject?) -> Bool { + return object === CurrentThreadSchedulerKeyInstance + } + + override var hash: Int { return -904739208 } + + override func copy() -> AnyObject { + return CurrentThreadSchedulerKeyInstance + } + + func copyWithZone(zone: NSZone) -> AnyObject { + return CurrentThreadSchedulerKeyInstance + } + } + + class CurrentThreadSchedulerQueueKey : NSObject, NSCopying { + override func isEqual(object: AnyObject?) -> Bool { + return object === CurrentThreadSchedulerQueueKeyInstance + } + + override var hash: Int { return -904739207 } + + override func copy() -> AnyObject { + return CurrentThreadSchedulerQueueKeyInstance + } + + func copyWithZone(zone: NSZone) -> AnyObject { + return CurrentThreadSchedulerQueueKeyInstance + } + } +#endif + +/** +Represents an object that schedules units of work on the current thread. + +This is the default scheduler for operators that generate elements. + +This scheduler is also sometimes called `trampoline scheduler`. +*/ +public class CurrentThreadScheduler : ImmediateSchedulerType { + typealias ScheduleQueue = RxMutableBox> + + /** + The singleton instance of the current thread scheduler. + */ + public static let instance = CurrentThreadScheduler() + + static var queue : ScheduleQueue? { + get { + return NSThread.getThreadLocalStorageValueForKey(CurrentThreadSchedulerQueueKeyInstance) + } + set { + NSThread.setThreadLocalStorageValue(newValue, forKey: CurrentThreadSchedulerQueueKeyInstance) + } + } + + /** + Gets a value that indicates whether the caller must call a `schedule` method. + */ + public static private(set) var isScheduleRequired: Bool { + get { + let value: CurrentThreadSchedulerValue? = NSThread.getThreadLocalStorageValueForKey(CurrentThreadSchedulerKeyInstance) + return value == nil + } + set(isScheduleRequired) { + NSThread.setThreadLocalStorageValue(isScheduleRequired ? nil : CurrentThreadSchedulerValueInstance, forKey: CurrentThreadSchedulerKeyInstance) + } + } + + /** + Schedules an action to be executed as soon as possible on current thread. + + If this method is called on some thread that doesn't have `CurrentThreadScheduler` installed, scheduler will be + automatically installed and uninstalled after all work is performed. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { + if CurrentThreadScheduler.isScheduleRequired { + CurrentThreadScheduler.isScheduleRequired = false + + let disposable = action(state) + + defer { + CurrentThreadScheduler.isScheduleRequired = true + CurrentThreadScheduler.queue = nil + } + + guard let queue = CurrentThreadScheduler.queue else { + return disposable + } + + while let latest = queue.value.dequeue() { + if latest.disposed { + continue + } + latest.invoke() + } + + return disposable + } + + let existingQueue = CurrentThreadScheduler.queue + + let queue: RxMutableBox> + if let existingQueue = existingQueue { + queue = existingQueue + } + else { + queue = RxMutableBox(Queue(capacity: 1)) + CurrentThreadScheduler.queue = queue + } + + let scheduledItem = ScheduledItem(action: action, state: state) + queue.value.enqueue(scheduledItem) + + // In Xcode 7.3, `return scheduledItem` causes segmentation fault 11 on release build. + // To workaround this compiler issue, returns AnonymousDisposable that disposes scheduledItem. + return AnonymousDisposable(scheduledItem.dispose) + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift new file mode 100644 index 00000000000..96154807d75 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift @@ -0,0 +1,54 @@ +// +// DispatchQueueSchedulerQOS.swift +// RxSwift +// +// Created by John C. "Hsoi" Daub on 12/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Identifies one of the global concurrent dispatch queues with specified quality of service class. +*/ +public enum DispatchQueueSchedulerQOS { + + /** + Identifies global dispatch queue with `QOS_CLASS_USER_INTERACTIVE` + */ + case UserInteractive + + /** + Identifies global dispatch queue with `QOS_CLASS_USER_INITIATED` + */ + case UserInitiated + + /** + Identifies global dispatch queue with `QOS_CLASS_DEFAULT` + */ + case Default + + /** + Identifies global dispatch queue with `QOS_CLASS_UTILITY` + */ + case Utility + + /** + Identifies global dispatch queue with `QOS_CLASS_BACKGROUND` + */ + case Background +} + + +@available(iOS 8, OSX 10.10, *) +extension DispatchQueueSchedulerQOS { + var QOSClass: qos_class_t { + switch self { + case .UserInteractive: return QOS_CLASS_USER_INTERACTIVE + case .UserInitiated: return QOS_CLASS_USER_INITIATED + case .Default: return QOS_CLASS_DEFAULT + case .Utility: return QOS_CLASS_UTILITY + case .Background: return QOS_CLASS_BACKGROUND + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift new file mode 100644 index 00000000000..949748e15ed --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift @@ -0,0 +1,25 @@ +// +// HistoricalScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 12/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Provides a virtual time scheduler that uses `NSDate` for absolute time and `NSTimeInterval` for relative time. +*/ +public class HistoricalScheduler : VirtualTimeScheduler { + + /** + Creates a new historical scheduler with initial clock value. + + - parameter initialClock: Initial value for virtual clock. + */ + public init(initialClock: RxTime = NSDate(timeIntervalSince1970: 0)) { + super.init(initialClock: initialClock, converter: HistoricalSchedulerTimeConverter()) + } + +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift new file mode 100644 index 00000000000..8384beb4319 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift @@ -0,0 +1,83 @@ +// +// HistoricalSchedulerTimeConverter.swift +// Rx +// +// Created by Krunoslav Zaher on 12/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Converts historial virtual time into real time. + + Since historical virtual time is also measured in `NSDate`, this converter is identity function. + */ +public struct HistoricalSchedulerTimeConverter : VirtualTimeConverterType { + /** + Virtual time unit used that represents ticks of virtual clock. + */ + public typealias VirtualTimeUnit = RxTime + + /** + Virtual time unit used to represent differences of virtual times. + */ + public typealias VirtualTimeIntervalUnit = RxTimeInterval + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertFromVirtualTime(virtualTime: VirtualTimeUnit) -> RxTime { + return virtualTime + } + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertToVirtualTime(time: RxTime) -> VirtualTimeUnit { + return time + } + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertFromVirtualTimeInterval(virtualTimeInterval: VirtualTimeIntervalUnit) -> RxTimeInterval { + return virtualTimeInterval + } + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertToVirtualTimeInterval(timeInterval: RxTimeInterval) -> VirtualTimeIntervalUnit { + return timeInterval + } + + /** + Offsets `NSDate` by time interval. + + - parameter time: Time. + - parameter timeInterval: Time interval offset. + - returns: Time offsetted by time interval. + */ + public func offsetVirtualTime(time time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit { + return time.dateByAddingTimeInterval(offset) + } + + /** + Compares two `NSDate`s. + */ + public func compareVirtualTime(lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison { + switch lhs.compare(rhs) { + case .OrderedAscending: + return .LessThan + case .OrderedSame: + return .Equal + case .OrderedDescending: + return .GreaterThan + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift new file mode 100644 index 00000000000..fc54fd5120a --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift @@ -0,0 +1,39 @@ +// +// ImmediateScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 10/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an object that schedules units of work to run immediately on the current thread. +*/ +private class ImmediateScheduler : ImmediateSchedulerType { + + private let _asyncLock = AsyncLock() + + /** + Schedules an action to be executed immediatelly. + + In case `schedule` is called recursively from inside of `action` callback, scheduled `action` will be enqueued + and executed after current `action`. (`AsyncLock` behavior) + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { + let disposable = SingleAssignmentDisposable() + _asyncLock.invoke(AnonymousInvocable { + if disposable.disposed { + return + } + disposable.disposable = action(state) + }) + + return disposable + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift new file mode 100644 index 00000000000..8525db45845 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift @@ -0,0 +1,21 @@ +// +// AnonymousInvocable.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct AnonymousInvocable : InvocableType { + private let _action: () -> () + + init(_ action: () -> ()) { + _action = action + } + + func invoke() { + _action() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift new file mode 100644 index 00000000000..1a4e3aa44e0 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift @@ -0,0 +1,24 @@ +// +// InvocableScheduledItem.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct InvocableScheduledItem : InvocableType { + + let _invocable: I + let _state: I.Value + + init(invocable: I, state: I.Value) { + _invocable = invocable + _state = state + } + + func invoke() { + _invocable.invoke(_state) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift new file mode 100644 index 00000000000..1632e71dada --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift @@ -0,0 +1,19 @@ +// +// InvocableType.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol InvocableType { + func invoke() +} + +protocol InvocableWithValueType { + associatedtype Value + + func invoke(value: Value) +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift new file mode 100644 index 00000000000..d4c9a2c65b5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift @@ -0,0 +1,37 @@ +// +// ScheduledItem.swift +// Rx +// +// Created by Krunoslav Zaher on 9/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct ScheduledItem + : ScheduledItemType + , InvocableType { + typealias Action = T -> Disposable + + private let _action: Action + private let _state: T + + private let _disposable = SingleAssignmentDisposable() + + var disposed: Bool { + return _disposable.disposed + } + + init(action: Action, state: T) { + _action = action + _state = state + } + + func invoke() { + _disposable.disposable = _action(_state) + } + + func dispose() { + _disposable.dispose() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift new file mode 100644 index 00000000000..2a1eca272da --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift @@ -0,0 +1,15 @@ +// +// ScheduledItemType.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol ScheduledItemType + : Cancelable + , InvocableType { + func invoke() +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift new file mode 100644 index 00000000000..ed109df7447 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift @@ -0,0 +1,73 @@ +// +// MainScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts work that needs to be performed on `MainThread`. In case `schedule` methods are called from main thread, it will perform action immediately without scheduling. + +This scheduler is usually used to perform UI work. + +Main scheduler is a specialization of `SerialDispatchQueueScheduler`. + +This scheduler is optimized for `observeOn` operator. To ensure observable sequence is subscribed on main thread using `subscribeOn` +operator please use `ConcurrentMainScheduler` because it is more optimized for that purpose. +*/ +public final class MainScheduler : SerialDispatchQueueScheduler { + + private let _mainQueue: dispatch_queue_t + + var numberEnqueued: AtomicInt = 0 + + private init() { + _mainQueue = dispatch_get_main_queue() + super.init(serialQueue: _mainQueue) + } + + /** + Singleton instance of `MainScheduler` + */ + public static let instance = MainScheduler() + + /** + Singleton instance of `MainScheduler` that always schedules work asynchronously + and doesn't perform optimizations for calls scheduled from main thread. + */ + public static let asyncInstance = SerialDispatchQueueScheduler(serialQueue: dispatch_get_main_queue()) + + /** + In case this method is called on a background thread it will throw an exception. + */ + public class func ensureExecutingOnScheduler(errorMessage: String? = nil) { + if !NSThread.currentThread().isMainThread { + rxFatalError(errorMessage ?? "Executing on backgound thread. Please use `MainScheduler.instance.schedule` to schedule work on main thread.") + } + } + + override func scheduleInternal(state: StateType, action: StateType -> Disposable) -> Disposable { + let currentNumberEnqueued = AtomicIncrement(&numberEnqueued) + + if NSThread.currentThread().isMainThread && currentNumberEnqueued == 1 { + let disposable = action(state) + AtomicDecrement(&numberEnqueued) + return disposable + } + + let cancel = SingleAssignmentDisposable() + + dispatch_async(_mainQueue) { + if !cancel.disposed { + action(state) + } + + AtomicDecrement(&self.numberEnqueued) + } + + return cancel + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift new file mode 100644 index 00000000000..8cfba8cafb5 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift @@ -0,0 +1,57 @@ +// +// OperationQueueScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 4/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts the work that needs to be performed on a specific `NSOperationQueue`. + +This scheduler is suitable for cases when there is some bigger chunk of work that needs to be performed in background and you want to fine tune concurrent processing using `maxConcurrentOperationCount`. +*/ +public class OperationQueueScheduler: ImmediateSchedulerType { + public let operationQueue: NSOperationQueue + + /** + Constructs new instance of `OperationQueueScheduler` that performs work on `operationQueue`. + + - parameter operationQueue: Operation queue targeted to perform work on. + */ + public init(operationQueue: NSOperationQueue) { + self.operationQueue = operationQueue + } + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { + + let compositeDisposable = CompositeDisposable() + + weak var compositeDisposableWeak = compositeDisposable + + let operation = NSBlockOperation { + if compositeDisposableWeak?.disposed ?? false { + return + } + + let disposable = action(state) + compositeDisposableWeak?.addDisposable(disposable) + } + + self.operationQueue.addOperation(operation) + + compositeDisposable.addDisposable(AnonymousDisposable(operation.cancel)) + + return compositeDisposable + } + +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift new file mode 100644 index 00000000000..dac4360cc81 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift @@ -0,0 +1,193 @@ +// +// RecursiveScheduler.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type erased recursive scheduler. +*/ +class AnyRecursiveScheduler { + typealias Action = (state: State, scheduler: AnyRecursiveScheduler) -> Void + + private let _lock = NSRecursiveLock() + + // state + private let _group = CompositeDisposable() + + private var _scheduler: SchedulerType + private var _action: Action? + + init(scheduler: SchedulerType, action: Action) { + _action = action + _scheduler = scheduler + } + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the recursive action. + */ + func schedule(state: State, dueTime: RxTimeInterval) { + + var isAdded = false + var isDone = false + + var removeKey: CompositeDisposable.DisposeKey? = nil + let d = _scheduler.scheduleRelative(state, dueTime: dueTime) { (state) -> Disposable in + // best effort + if self._group.disposed { + return NopDisposable.instance + } + + let action = self._lock.calculateLocked { () -> Action? in + if isAdded { + self._group.removeDisposable(removeKey!) + } + else { + isDone = true + } + + return self._action + } + + if let action = action { + action(state: state, scheduler: self) + } + + return NopDisposable.instance + } + + _lock.performLocked { + if !isDone { + removeKey = _group.addDisposable(d) + isAdded = true + } + } + } + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + */ + func schedule(state: State) { + + var isAdded = false + var isDone = false + + var removeKey: CompositeDisposable.DisposeKey? = nil + let d = _scheduler.schedule(state) { (state) -> Disposable in + // best effort + if self._group.disposed { + return NopDisposable.instance + } + + let action = self._lock.calculateLocked { () -> Action? in + if isAdded { + self._group.removeDisposable(removeKey!) + } + else { + isDone = true + } + + return self._action + } + + if let action = action { + action(state: state, scheduler: self) + } + + return NopDisposable.instance + } + + _lock.performLocked { + if !isDone { + removeKey = _group.addDisposable(d) + isAdded = true + } + } + } + + func dispose() { + _lock.performLocked { + _action = nil + } + _group.dispose() + } +} + +/** +Type erased recursive scheduler. +*/ +class RecursiveImmediateScheduler { + typealias Action = (state: State, recurse: State -> Void) -> Void + + private var _lock = SpinLock() + private let _group = CompositeDisposable() + + private var _action: Action? + private let _scheduler: ImmediateSchedulerType + + init(action: Action, scheduler: ImmediateSchedulerType) { + _action = action + _scheduler = scheduler + } + + // immediate scheduling + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + */ + func schedule(state: State) { + + var isAdded = false + var isDone = false + + var removeKey: CompositeDisposable.DisposeKey? = nil + let d = _scheduler.schedule(state) { (state) -> Disposable in + // best effort + if self._group.disposed { + return NopDisposable.instance + } + + let action = self._lock.calculateLocked { () -> Action? in + if isAdded { + self._group.removeDisposable(removeKey!) + } + else { + isDone = true + } + + return self._action + } + + if let action = action { + action(state: state, recurse: self.schedule) + } + + return NopDisposable.instance + } + + _lock.performLocked { + if !isDone { + removeKey = _group.addDisposable(d) + isAdded = true + } + } + } + + func dispose() { + _lock.performLocked { + _action = nil + } + _group.dispose() + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift new file mode 100644 index 00000000000..3906d7a708b --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift @@ -0,0 +1,63 @@ +// +// SchedulerServices+Emulation.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +enum SchedulePeriodicRecursiveCommand { + case Tick + case DispatchStart +} + +class SchedulePeriodicRecursive { + typealias RecursiveAction = State -> State + typealias RecursiveScheduler = AnyRecursiveScheduler + + private let _scheduler: SchedulerType + private let _startAfter: RxTimeInterval + private let _period: RxTimeInterval + private let _action: RecursiveAction + + private var _state: State + private var _pendingTickCount: AtomicInt = 0 + + init(scheduler: SchedulerType, startAfter: RxTimeInterval, period: RxTimeInterval, action: RecursiveAction, state: State) { + _scheduler = scheduler + _startAfter = startAfter + _period = period + _action = action + _state = state + } + + func start() -> Disposable { + return _scheduler.scheduleRecursive(SchedulePeriodicRecursiveCommand.Tick, dueTime: _startAfter, action: self.tick) + } + + func tick(command: SchedulePeriodicRecursiveCommand, scheduler: RecursiveScheduler) -> Void { + // Tries to emulate periodic scheduling as best as possible. + // The problem that could arise is if handling periodic ticks take too long, or + // tick interval is short. + switch command { + case .Tick: + scheduler.schedule(.Tick, dueTime: _period) + + // The idea is that if on tick there wasn't any item enqueued, schedule to perform work immediatelly. + // Else work will be scheduled after previous enqueued work completes. + if AtomicIncrement(&_pendingTickCount) == 1 { + self.tick(.DispatchStart, scheduler: scheduler) + } + + case .DispatchStart: + _state = _action(_state) + // Start work and schedule check is this last batch of work + if AtomicDecrement(&_pendingTickCount) > 0 { + // This gives priority to scheduler emulation, it's not perfect, but helps + scheduler.schedule(SchedulePeriodicRecursiveCommand.DispatchStart) + } + } + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift new file mode 100644 index 00000000000..8376f9a4326 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift @@ -0,0 +1,184 @@ +// +// SerialDispatchQueueScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts the work that needs to be performed on a specific `dispatch_queue_t`. It will make sure +that even if concurrent dispatch queue is passed, it's transformed into a serial one. + +It is extremely important that this scheduler is serial, because +certain operator perform optimizations that rely on that property. + +Because there is no way of detecting is passed dispatch queue serial or +concurrent, for every queue that is being passed, worst case (concurrent) +will be assumed, and internal serial proxy dispatch queue will be created. + +This scheduler can also be used with internal serial queue alone. + +In case some customization need to be made on it before usage, +internal serial queue can be customized using `serialQueueConfiguration` +callback. +*/ +public class SerialDispatchQueueScheduler: SchedulerType { + public typealias TimeInterval = NSTimeInterval + public typealias Time = NSDate + + private let _serialQueue : dispatch_queue_t + + /** + - returns: Current time. + */ + public var now : NSDate { + return NSDate() + } + + // leeway for scheduling timers + private var _leeway: Int64 = 0 + + init(serialQueue: dispatch_queue_t) { + _serialQueue = serialQueue + } + + /** + Constructs new `SerialDispatchQueueScheduler` with internal serial queue named `internalSerialQueueName`. + + Additional dispatch queue properties can be set after dispatch queue is created using `serialQueueConfiguration`. + + - parameter internalSerialQueueName: Name of internal serial dispatch queue. + - parameter serialQueueConfiguration: Additional configuration of internal serial dispatch queue. + */ + public convenience init(internalSerialQueueName: String, serialQueueConfiguration: ((dispatch_queue_t) -> Void)? = nil) { + let queue = dispatch_queue_create(internalSerialQueueName, DISPATCH_QUEUE_SERIAL) + serialQueueConfiguration?(queue) + self.init(serialQueue: queue) + } + + /** + Constructs new `SerialDispatchQueueScheduler` named `internalSerialQueueName` that wraps `queue`. + + - parameter queue: Possibly concurrent dispatch queue used to perform work. + - parameter internalSerialQueueName: Name of internal serial dispatch queue proxy. + */ + public convenience init(queue: dispatch_queue_t, internalSerialQueueName: String) { + let serialQueue = dispatch_queue_create(internalSerialQueueName, DISPATCH_QUEUE_SERIAL) + dispatch_set_target_queue(serialQueue, queue) + self.init(serialQueue: serialQueue) + } + + /** + Constructs new `SerialDispatchQueueScheduler` that wraps on of the global concurrent dispatch queues. + + - parameter globalConcurrentQueueQOS: Identifier for global dispatch queue with specified quality of service class. + - parameter internalSerialQueueName: Custom name for internal serial dispatch queue proxy. + */ + @available(iOS 8, OSX 10.10, *) + public convenience init(globalConcurrentQueueQOS: DispatchQueueSchedulerQOS, internalSerialQueueName: String = "rx.global_dispatch_queue.serial") { + let priority = globalConcurrentQueueQOS.QOSClass + self.init(queue: dispatch_get_global_queue(priority, UInt(0)), internalSerialQueueName: internalSerialQueueName) + } + + class func convertTimeIntervalToDispatchInterval(timeInterval: NSTimeInterval) -> Int64 { + return Int64(timeInterval * Double(NSEC_PER_SEC)) + } + + class func convertTimeIntervalToDispatchTime(timeInterval: NSTimeInterval) -> dispatch_time_t { + return dispatch_time(DISPATCH_TIME_NOW, convertTimeIntervalToDispatchInterval(timeInterval)) + } + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { + return self.scheduleInternal(state, action: action) + } + + func scheduleInternal(state: StateType, action: (StateType) -> Disposable) -> Disposable { + let cancel = SingleAssignmentDisposable() + + dispatch_async(_serialQueue) { + if cancel.disposed { + return + } + + + cancel.disposable = action(state) + } + + return cancel + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func scheduleRelative(state: StateType, dueTime: NSTimeInterval, action: (StateType) -> Disposable) -> Disposable { + let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _serialQueue) + + let dispatchInterval = MainScheduler.convertTimeIntervalToDispatchTime(dueTime) + + let compositeDisposable = CompositeDisposable() + + dispatch_source_set_timer(timer, dispatchInterval, DISPATCH_TIME_FOREVER, 0) + dispatch_source_set_event_handler(timer, { + if compositeDisposable.disposed { + return + } + compositeDisposable.addDisposable(action(state)) + }) + dispatch_resume(timer) + + compositeDisposable.addDisposable(AnonymousDisposable { + dispatch_source_cancel(timer) + }) + + return compositeDisposable + } + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedulePeriodic(state: StateType, startAfter: TimeInterval, period: TimeInterval, action: (StateType) -> StateType) -> Disposable { + let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _serialQueue) + + let initial = MainScheduler.convertTimeIntervalToDispatchTime(startAfter) + let dispatchInterval = MainScheduler.convertTimeIntervalToDispatchInterval(period) + + var timerState = state + + let validDispatchInterval = dispatchInterval < 0 ? 0 : UInt64(dispatchInterval) + + dispatch_source_set_timer(timer, initial, validDispatchInterval, 0) + let cancel = AnonymousDisposable { + dispatch_source_cancel(timer) + } + dispatch_source_set_event_handler(timer, { + if cancel.disposed { + return + } + timerState = action(timerState) + }) + dispatch_resume(timer) + + return cancel + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift new file mode 100644 index 00000000000..61a58ca62f7 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift @@ -0,0 +1,115 @@ +// +// VirtualTimeConverterType.swift +// Rx +// +// Created by Krunoslav Zaher on 12/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Parametrization for virtual time used by `VirtualTimeScheduler`s. +*/ +public protocol VirtualTimeConverterType { + /** + Virtual time unit used that represents ticks of virtual clock. + */ + associatedtype VirtualTimeUnit + + /** + Virtual time unit used to represent differences of virtual times. + */ + associatedtype VirtualTimeIntervalUnit + + /** + Converts virtual time to real time. + + - parameter virtualTime: Virtual time to convert to `NSDate`. + - returns: `NSDate` corresponding to virtual time. + */ + func convertFromVirtualTime(virtualTime: VirtualTimeUnit) -> RxTime + + /** + Converts real time to virtual time. + + - parameter time: `NSDate` to convert to virtual time. + - returns: Virtual time corresponding to `NSDate`. + */ + func convertToVirtualTime(time: RxTime) -> VirtualTimeUnit + + /** + Converts from virtual time interval to `NSTimeInterval`. + + - parameter virtualTimeInterval: Virtual time interval to convert to `NSTimeInterval`. + - returns: `NSTimeInterval` corresponding to virtual time interval. + */ + func convertFromVirtualTimeInterval(virtualTimeInterval: VirtualTimeIntervalUnit) -> RxTimeInterval + + /** + Converts from virtual time interval to `NSTimeInterval`. + + - parameter timeInterval: `NSTimeInterval` to convert to virtual time interval. + - returns: Virtual time interval corresponding to time interval. + */ + func convertToVirtualTimeInterval(timeInterval: RxTimeInterval) -> VirtualTimeIntervalUnit + + /** + Offsets virtual time by virtual time interval. + + - parameter time: Virtual time. + - parameter offset: Virtual time interval. + - returns: Time corresponding to time offsetted by virtual time interval. + */ + func offsetVirtualTime(time time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit + + /** + This is aditional abstraction because `NSDate` is unfortunately not comparable. + Extending `NSDate` with `Comparable` would be too risky because of possible collisions with other libraries. + */ + func compareVirtualTime(lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison +} + +/** + Virtual time comparison result. + + This is aditional abstraction because `NSDate` is unfortunately not comparable. + Extending `NSDate` with `Comparable` would be too risky because of possible collisions with other libraries. +*/ +public enum VirtualTimeComparison { + /** + lhs < rhs. + */ + case LessThan + /** + lhs == rhs. + */ + case Equal + /** + lhs > rhs. + */ + case GreaterThan +} + +extension VirtualTimeComparison { + /** + lhs < rhs. + */ + var lessThen: Bool { + return self == .LessThan + } + + /** + lhs > rhs + */ + var greaterThan: Bool { + return self == .GreaterThan + } + + /** + lhs == rhs + */ + var equal: Bool { + return self == .Equal + } +} diff --git a/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift new file mode 100644 index 00000000000..9c480619e24 --- /dev/null +++ b/samples/client/petstore/swift/rxswift/SwaggerClientTests/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift @@ -0,0 +1,292 @@ +// +// VirtualTimeScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 2/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Base class for virtual time schedulers using a priority queue for scheduled items. +*/ +public class VirtualTimeScheduler + : SchedulerType + , CustomDebugStringConvertible { + + public typealias VirtualTime = Converter.VirtualTimeUnit + public typealias VirtualTimeInterval = Converter.VirtualTimeIntervalUnit + + private var _running : Bool + + private var _clock: VirtualTime + + private var _schedulerQueue : PriorityQueue> + private var _converter: Converter + + private var _nextId = 0 + + /** + - returns: Current time. + */ + public var now: RxTime { + return _converter.convertFromVirtualTime(clock) + } + + /** + - returns: Scheduler's absolute time clock value. + */ + public var clock: VirtualTime { + return _clock + } + + /** + Creates a new virtual time scheduler. + + - parameter initialClock: Initial value for the clock. + */ + public init(initialClock: VirtualTime, converter: Converter) { + _clock = initialClock + _running = false + _converter = converter + _schedulerQueue = PriorityQueue(hasHigherPriority: { + switch converter.compareVirtualTime($0.time, $1.time) { + case .LessThan: + return true + case .Equal: + return $0.id < $1.id + case .GreaterThan: + return false + } + }) + #if TRACE_RESOURCES + AtomicIncrement(&resourceCount) + #endif + } + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(state: StateType, action: StateType -> Disposable) -> Disposable { + return self.scheduleRelative(state, dueTime: 0.0) { a in + return action(a) + } + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleRelative(state: StateType, dueTime: RxTimeInterval, action: StateType -> Disposable) -> Disposable { + let time = self.now.dateByAddingTimeInterval(dueTime) + let absoluteTime = _converter.convertToVirtualTime(time) + let adjustedTime = self.adjustScheduledTime(absoluteTime) + return scheduleAbsoluteVirtual(state, time: adjustedTime, action: action) + } + + /** + Schedules an action to be executed after relative time has passed. + + - parameter state: State passed to the action to be executed. + - parameter time: Absolute time when to execute the action. If this is less or equal then `now`, `now + 1` will be used. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleRelativeVirtual(state: StateType, dueTime: VirtualTimeInterval, action: StateType -> Disposable) -> Disposable { + let time = _converter.offsetVirtualTime(time: self.clock, offset: dueTime) + return scheduleAbsoluteVirtual(state, time: time, action: action) + } + + /** + Schedules an action to be executed at absolute virtual time. + + - parameter state: State passed to the action to be executed. + - parameter time: Absolute time when to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleAbsoluteVirtual(state: StateType, time: Converter.VirtualTimeUnit, action: StateType -> Disposable) -> Disposable { + MainScheduler.ensureExecutingOnScheduler() + + let compositeDisposable = CompositeDisposable() + + let item = VirtualSchedulerItem(action: { + let dispose = action(state) + return dispose + }, time: time, id: _nextId) + + _nextId += 1 + + _schedulerQueue.enqueue(item) + + compositeDisposable.addDisposable(item) + + return compositeDisposable + } + + /** + Adjusts time of scheduling before adding item to schedule queue. + */ + public func adjustScheduledTime(time: Converter.VirtualTimeUnit) -> Converter.VirtualTimeUnit { + return time + } + + /** + Starts the virtual time scheduler. + */ + public func start() { + MainScheduler.ensureExecutingOnScheduler() + + if _running { + return + } + + _running = true + repeat { + guard let next = findNext() else { + break + } + + if _converter.compareVirtualTime(next.time, self.clock).greaterThan { + _clock = next.time + } + + next.invoke() + _schedulerQueue.remove(next) + } while _running + + _running = false + } + + func findNext() -> VirtualSchedulerItem? { + while let front = _schedulerQueue.peek() { + if front.disposed { + _schedulerQueue.remove(front) + continue + } + + return front + } + + return nil + } + + /** + Advances the scheduler's clock to the specified time, running all work till that point. + + - parameter virtualTime: Absolute time to advance the scheduler's clock to. + */ + public func advanceTo(virtualTime: VirtualTime) { + MainScheduler.ensureExecutingOnScheduler() + + if _running { + fatalError("Scheduler is already running") + } + + _running = true + repeat { + guard let next = findNext() else { + break + } + + if _converter.compareVirtualTime(next.time, virtualTime).greaterThan { + break + } + + if _converter.compareVirtualTime(next.time, self.clock).greaterThan { + _clock = next.time + } + + next.invoke() + _schedulerQueue.remove(next) + } while _running + + _clock = virtualTime + _running = false + } + + /** + Advances the scheduler's clock by the specified relative time. + */ + public func sleep(virtualInterval: VirtualTimeInterval) { + MainScheduler.ensureExecutingOnScheduler() + + let sleepTo = _converter.offsetVirtualTime(time: clock, offset: virtualInterval) + if _converter.compareVirtualTime(sleepTo, clock).lessThen { + fatalError("Can't sleep to past.") + } + + _clock = sleepTo + } + + /** + Stops the virtual time scheduler. + */ + public func stop() { + MainScheduler.ensureExecutingOnScheduler() + + _running = false + } + + #if TRACE_RESOURCES + deinit { + AtomicDecrement(&resourceCount) + } + #endif +} + +// MARK: description + +extension VirtualTimeScheduler { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + return self._schedulerQueue.debugDescription + } +} + +class VirtualSchedulerItem