Skip to content

Commit

Permalink
Swifty 1.1.0
Browse files Browse the repository at this point in the history
Swifty now supports the `Codable` Protocol, plus adds support response mocking.

#### Added
- Adds a new `.json(encodable: encoder:)` modifier to attach `Encodable` objects into request bodies.
- Adds a new method `.loadJSON<T: Decodable>(decodable: decoder:)` to support loading `Decodable` objects from network responses directly.
- Adds a new `.mock(withFile: OfType)` modifier to mock responses of requests using files in the main bundle.
- Tests for Codable Support & Response Mocking.

#### Fixed
- The `creationError` property in `NetworkResource` is now public, so that it can be utilized by a user's custom extensions.

- Regenerated Docs
  • Loading branch information
biocross committed Dec 13, 2017
1 parent b37f4ea commit 376df05
Show file tree
Hide file tree
Showing 53 changed files with 831 additions and 72 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change Log

## [1.1.0](https://github.com/Flipkart/Swifty/releases/tag/1.1.0)
Released on 2017-12-14.

Swifty now supports the `Codable` Protocol, plus adds support response mocking.

#### Added
- Adds a new `.json(encodable: encoder:)` modifier to attach `Encodable` objects into request bodies.
- Adds a new method `.loadJSON<T: Decodable>(decodable: decoder:)` to support loading `Decodable` objects from network responses directly.
- Adds a new `.mock(withFile: OfType)` modifier to mock responses of requests using files in the main bundle.
- Tests for Codable Support & Response Mocking.

#### Fixed
- The `creationError` property in `NetworkResource` is now public, so that it can be utilized by a user's custom extensions.

## [1.0.2](https://github.com/Flipkart/Swifty/releases/tag/1.0.2)
Released on 2017-11-17.

Expand Down
2 changes: 1 addition & 1 deletion Swifty.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Swifty'
s.version = '1.0.2'
s.version = '1.1.0'
s.summary = 'Lightweight & Fast Network Abstraction Layer for iOS'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/BaseResource.html
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ <h4>Return Value</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/Constraint.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
187 changes: 181 additions & 6 deletions docs/Classes/NetworkResource.html

Large diffs are not rendered by default.

128 changes: 127 additions & 1 deletion docs/Classes/NetworkResourceWithBody.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,70 @@ <h4>Return Value</h4>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:6Swifty23NetworkResourceWithBodyC4jsonACx9encodable_10Foundation11JSONEncoderC7encoderts9EncodableRzlF"></a>
<a name="//apple_ref/swift/Method/json(encodable:encoder:)" class="dashAnchor"></a>
<a class="token" href="#/s:6Swifty23NetworkResourceWithBodyC4jsonACx9encodable_10Foundation11JSONEncoderC7encoderts9EncodableRzlF">json(encodable:encoder:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Sets the HTTP Body as JSON encoded from a type conforming to the <code>Encodable (Codable)</code> protocol</p>

<p>Internally sets the Content-Type header of the resource to <q>application/json</q></p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">@discardableResult</span> <span class="kd">func</span> <span class="n">json</span><span class="o">&lt;</span><span class="kt">T</span><span class="p">:</span> <span class="kt">Encodable</span><span class="o">&gt;</span><span class="p">(</span><span class="nv">encodable</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">encoder</span><span class="p">:</span> <span class="kt">JSONEncoder</span> <span class="o">=</span> <span class="kt">JSONEncoder</span><span class="p">())</span> <span class="o">-&gt;</span> <span class="kt">NetworkResourceWithBody</span></code></pre>

</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>body</em>
</code>
</td>
<td>
<div>
<p>A type conforming to the <code>Encodable</code> Protocol</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>options</em>
</code>
</td>
<td>
<div>
<p>The <code>JSONEncoder</code> instance to use. Defaults to <code>JSONEncoder()</code></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>NetworkResourceWithBody</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
Expand Down Expand Up @@ -641,6 +705,68 @@ <h3 class="section-name">Request Options Modifiers</h3>
</a>
</div>
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/c:@CM@Swifty@objc(cs)NetworkResourceWithBody(im)mockWithFile:ofType:"></a>
<a name="//apple_ref/swift/Method/mock(withFile:ofType:)" class="dashAnchor"></a>
<a class="token" href="#/c:@CM@Swifty@objc(cs)NetworkResourceWithBody(im)mockWithFile:ofType:">mock(withFile:ofType:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Mocks the response of the resource with the contents of the given filename. Note that if a request is mocked, it&rsquo;ll never hit the network, and will NOT pass the Request Interceptors. It will, however, pass through the Response Intereptors.</p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">@objc</span> <span class="kd">@discardableResult</span> <span class="k">override</span> <span class="kd">func</span> <span class="nf">mock</span><span class="p">(</span><span class="nv">withFile</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">ofType</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"json"</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">NetworkResourceWithBody</span></code></pre>

</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>withFile</em>
</code>
</td>
<td>
<div>
<p>The name (without extension) of the file containing the mocked response. The file must be present in the main bundle (<code>Bundle.main</code>)</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>ofType</em>
</code>
</td>
<td>
<div>
<p>The extension of the file. Defaults to <code>.json</code> if not provided.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<h4>Return Value</h4>
<p>NetworkResourceWithBody</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
Expand Down Expand Up @@ -809,7 +935,7 @@ <h4>Return Value</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/NetworkResponse.html
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/Swifty.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/SwiftyError.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/SwiftyInspector.html
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
31 changes: 29 additions & 2 deletions docs/Classes/WebServiceError.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>JSON Encoding failure.</p>
<p>JSON Array Encoding failure.</p>

</div>
<div class="declaration">
Expand All @@ -371,6 +371,33 @@ <h4>Declaration</h4>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:6Swifty15WebServiceErrorC22codableEncodingFailureSo7NSErrorCs0D0_pSg5error_tFZ"></a>
<a name="//apple_ref/swift/Method/codableEncodingFailure(error:)" class="dashAnchor"></a>
<a class="token" href="#/s:6Swifty15WebServiceErrorC22codableEncodingFailureSo7NSErrorCs0D0_pSg5error_tFZ">codableEncodingFailure(error:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Codable Encoding failure.</p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">codableEncodingFailure</span><span class="p">(</span><span class="nv">error</span><span class="p">:</span> <span class="kt">Error</span><span class="p">?)</span> <span class="o">-&gt;</span> <span class="kt">NSError</span></code></pre>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
Expand All @@ -379,7 +406,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums/SwiftyErrorCodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums/URLSessionTaskPriority.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-10-31)</p>
<p>&copy; 2017 <a class="link" href="https://github.com/biocross" target="_blank" rel="external">Siddharth Gupta</a>. All rights reserved. (Last updated: 2017-12-14)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down

0 comments on commit 376df05

Please sign in to comment.