Comments (6)
Fyi - Iād encourage leveraging this code base
OHHTTPStubs
https://github.com/AliSoftware/OHHTTPStubs/blob/master/Examples/Swift/MainViewController.swift
I took this code one step further and allowed Charles saved traffic to replay with one line
https://github.com/johndpope/HAR-playback-swift
from restofire.
Thanks for sharing!
OHHTTPStubs are good but adding it as a dependency is something I would like to avoid. I am thinking more of a variable containing response as a string that will simulate the actual API on the basis of launch argument.
So it is more aligned to testing your views with the api contract before the actual api is created.
I am not sure about the implementation right now and what all things to consider while implementing this functionality.
Thoughts?
from restofire.
I've seen this cruder approach with json string payloads from junior coders - when the end point api mutates - you end up with a bunch of rotten code.
It also leaves a lot of case switching out to if test // load this string just creates a pile of poo.
You can always fork OHHTTPStubs and simply rename it StubFire
The crux of use case from my POV - boils down to
enable stubbing
intercept specified end points.
if url == "/getFriends"
then load /parse using alamofire from a corresponding versioned json file with http status code 200.
api changes / load a different one.
disable stubbing.
Here's some code I crafted to load a response from swagger.
https://gist.github.com/johndpope/009b9301ef422daca4c3588aad7b337b
https://github.com/AliSoftware/OHHTTPStubs/blob/master/Examples/Swift/MainViewController.swift
If you want to avoid third party dependencies - then by that rational you're also saying you want to not include Alamofire - which is crazy talk.
from restofire.
Thanks for sharing links. HAR-playback-swift looks very cool.
And nothing against using third party libraries but stubbing is a part of testing. Adding OHHTTPStubs as a dependency will force users to embed the framework inside their IPAs which they won't want to do. I will let users add them separately and create their own stubs.
from restofire.
you can target framework dependencies for different build configurations.
eg.
pod 'OHHTTPStubs' #, :configurations => ['Debug']
from restofire.
Thanks! Will investigate how can this be integrated with Carthage and SPM also.
from restofire.
Related Issues (20)
- Command failed due to signal: Segmantation fault: 11 HOT 3
- Example Usage with ObjectMapper
- Failed to serialize Requestable Model HOT 3
- Downloading image or file? HOT 2
- Doesn't work with SPM HOT 1
- XCODE 9 UrlError.Code error HOT 1
- Alamofire 4? HOT 1
- Feature: Request Delegates HOT 3
- Feature: Streamable Protocols
- Feature: Add Keypath to Configurable HOT 1
- Chore: Usage Example with FlowCoordinators
- Chore: Usage example of Custom Response Serializer
- Feature: Support internet connectivity with Alamofire Protocols HOT 2
- Feature: Encodable Parameters
- Feature: Update to Swift 4.1 and Xcode 9.3
- Broken example HOT 2
- Swift Package Manager installation does not work HOT 3
- Error in readme HOT 4
- iOS 13 issue "resource exceeds maximum size" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restofire.