You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand the code, the auth property is intended to be set when instantiating the siteRequest object. This would make sense since the auth method probably shouldn't be able to be changed once set, and it will discourage having unnecessary long-lived objects. That would make your example code this:
let instance = LemmyAPI(baseUrl: url)
let siteRequest = GetSiteRequest(auth: jwt)
let siteResponse = try await instance.request(siteRequest)
I would argue that the issue here is more the lack of documentation around the init method.
Using Xcode's markdown-like documentation I knocked up a quick example for the init(auth:) method:
/// Public Initialiser for the GetSiteRequest struct.
/// - Parameter auth: Authentication token (JWT) to use, or `nil` if absent
///
/// If instantiated with no arguments, the authenticatiion token will be `nil`. This may not be what you want.
/// To make an authenticated request, include the authentication token:
/// ```let siteRequest = GetSiteRequest(auth: jwt)```
public init(auth: String? = nil) {
self.auth = auth
}
This appears in Xcode's quick-help pane as follows:
I see you have generated API documentation, I assume it will read this kind of documentation and include it in the generated documentation.
FWIW, you can get Xcode to insert boilerplate for these pieces of documentation by typing CMD-Opt-/ when your cursor is on the thing you want to document.
There is no reason the following code should be invalid:
But that code currently produces an error:
Cannot assign to property: 'auth' is a 'let' constant
.We should make all those properties
var
instead oflet
to allow that code to be valid.The text was updated successfully, but these errors were encountered: