All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- None.
- None.
- None.
- None.
- None.
- None.
- New methods for requesting raw
Data
response to allow for using alternative decoding methods such as SwiftyJSON:performRawDataRequest(AndWait)
(classic approach),rawDataPublisher
(Combine) andrawDataResponse
(Swift concurrency).
- Made the
baseUrl
parameter ofApiProvider
editable.
- New async
response
method based on the new concurrency features available in Swift 5.5.
- New
mockingBehavior
parameter onApiProvider
for testing purposes. Specify one withdelay
andscheduler
, e.g..seconds(0.5)
andDispatchQueue.main.eraseToAnyScheduler()
. Providesnil
by default to make actual requests. - New optional
mockedResponse
computed property onEndpoint
protocol expecting an output of typeMockedResponse
. Use this to provide mocked responses when using amockingBehavior
in tests. See the PostmanEchoEndpoint in the tests for a usage example via themock
convenience method.
- Moved
baseUrl
fromEndpoint
toApiProvider
. This allows for specifying differentbaseUrl
even whenEndpoint
is implemented in a library by passing it in the app. - Renamed
HttpBasicAuthPlugin
toHttpAuthPlugin
with a newscheme
parameter that accepts one of.basic
or.bearer
to support multiple authentication methods.
- Microya now supports Combine publishers, just call
publisher(on:decodeBodyTo:)
orpublisher(on:)
instead ofperformRequest(on:decodeBodyTo:)
orperformRequest(on:)
and you'll get anAnyPublisher
request stream to subscribe to. In success cases you will receive the decoded typed object, in error cases anApiError
object exactly like within theperformRequest
completion closure. But instead of aResult
type you can usesink
orcatch
from the Combine framework.
- The
queryParameters
is no longer of type[String: String]
, but[String: QueryParameterValue]
now. Existing code like["search": searchTerm]
will need to be updated to["search": .string(searchTerm)]
. Apart from.string
this now also allows specifying an array of strings like so:["tags": .array(userSelectedTags)]
. String & array literals are supported directly, e.g.["sort": "createdAt"]
or["sort": ["createdAt", "id"]]
.
- New
ApiProvider
type encapsulating different request methods with support for plugins. - New asynchronous
performRequest
methods with completion callbacks. (#2) - New
Plugin
class to subclass for integrating into the networking logic via callbacks. - New pre-implemented plugins:
HttpBasicAuth
,ProgressIndicator
,RequestLogger
,ResponseLogger
. - New
EmptyResponseBody
type to use whenever the body is expected to be empty or should be ignored.
- Renamed
JsonApi
protocol toEndpoint
. - Renamed
Method
toHttpMethod
and addedbody: Data
to the casespost
andpatch
. - Moved the
request
method fromJsonApi
to the newApiProvider
& renamed toperformRequestAndWait
. - Generally improved the cases in
JsonApiError
& renamed the type toApiError
. - Moved CI from Bitrise to GitHub Actions.
- The
bodyData: Data?
requirement onJsonApi
(bodies are not part ofHttpMethod
, see above). - Installation is no longer possible via CocoaPods or Carthage. Please use SwiftPM instead.
- Make some fields of the
JsonApi
protocol optional by providing default implementation.
- Add
JsonApi
type similar toTargetType
in Moya with additional JSONCodable
support. - Add basic usage documentation based on the Microsoft Translator API.