• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 29018885975

09 Jul 2026 12:40PM UTC coverage: 77.87% (-5.2%) from 83.062%
29018885975

Pull #1099

github

web-flow
Merge 2bab4f734 into 27f31bfb7
Pull Request #1099: feat(storage): OpenAPI codegen tool + generated Storage HTTP client

428 of 1233 new or added lines in 18 files covered. (34.71%)

6 existing lines in 2 files now uncovered.

8322 of 10687 relevant lines covered (77.87%)

33.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.42
/Sources/HTTPRuntime/HTTPRequest.swift
1
//
2
//  HTTPRequest.swift
3
//  HTTPRuntime
4
//
5
//  Created by Guilherme Souza on 08/07/26.
6
//
7
package import Foundation
8

9
/// The body of an outgoing request.
10
///
11
/// `.file` is the key to streaming large uploads without loading them into
12
/// memory: `URLSession` streams the file from disk. `.multipart` assembles a
13
/// `multipart/form-data` body onto a temporary file and then uploads that file,
14
/// so even large multipart parts never materialize fully in memory.
15
package enum HTTPBody: Sendable {
16
  case data(Data)
17
  case file(URL)
18
  case multipart(MultipartFormData)
19
}
20

21
/// A fully-resolved HTTP request: absolute URL, headers, and body.
22
package struct HTTPRequest: Sendable {
23
  package var method: HTTPMethod
24
  package var url: URL
25
  package var headers: [String: String]
26
  package var body: HTTPBody?
27

28
  package init(
29
    method: HTTPMethod,
30
    url: URL,
31
    headers: [String: String] = [:],
32
    body: HTTPBody? = nil
33
  ) {
6✔
34
    self.method = method
6✔
35
    self.url = url
6✔
36
    self.headers = headers
6✔
37
    self.body = body
6✔
38
  }
6✔
39
}
40

41
/// Assembles an `HTTPRequest` from a base URL, a path template already filled
42
/// with path parameters, repeated query items, and headers.
43
///
44
/// Generated code drives this builder; it never constructs `URLComponents`
45
/// directly. Query values use repeated-key encoding (`?k=a&k=b`) to match the
46
/// Smithy/OpenAPI list conventions in the specs.
47
package struct HTTPRequestBuilder: Sendable {
48
  private let method: HTTPMethod
49
  private let baseURL: URL
50
  private let path: String
51
  private var queryItems: [URLQueryItem] = []
6✔
52
  private var headers: [String: String] = [:]
6✔
53
  private var body: HTTPBody? = nil
6✔
54

55
  package init(method: HTTPMethod, baseURL: URL, path: String) {
6✔
56
    self.method = method
6✔
57
    self.baseURL = baseURL
6✔
58
    self.path = path
6✔
59
  }
6✔
60

61
  package mutating func addQuery(_ name: String, _ value: String?) {
5✔
62
    guard let value else { return }
5✔
NEW
63
    queryItems.append(URLQueryItem(name: name, value: value))
×
NEW
64
  }
×
65

NEW
66
  package mutating func addQuery(_ name: String, _ values: [String]?) {
×
NEW
67
    guard let values else { return }
×
NEW
68
    for value in values {
×
NEW
69
      queryItems.append(URLQueryItem(name: name, value: value))
×
NEW
70
    }
×
NEW
71
  }
×
72

NEW
73
  package mutating func setHeader(_ name: String, _ value: String?) {
×
NEW
74
    guard let value else { return }
×
NEW
75
    headers[name] = value
×
NEW
76
  }
×
77

NEW
78
  package mutating func setBody(_ body: HTTPBody?) {
×
NEW
79
    self.body = body
×
NEW
80
  }
×
81

82
  package func build() throws -> HTTPRequest {
6✔
83
    // Compose by string so slashes inside greedy path params ({path+}) are
6✔
84
    // preserved. Generated code percent-encodes individual label values.
6✔
85
    var base = baseURL.absoluteString
6✔
86
    if base.hasSuffix("/") { base.removeLast() }
6✔
87
    let prefixedPath = path.hasPrefix("/") ? path : "/" + path
6✔
88
    guard var components = URLComponents(string: base + prefixedPath) else {
6✔
NEW
89
      throw HTTPError.invalidURL(base: baseURL, path: path)
×
90
    }
6✔
91
    if !queryItems.isEmpty {
6✔
NEW
92
      components.queryItems = queryItems
×
NEW
93
    }
×
94
    guard let url = components.url else {
6✔
NEW
95
      throw HTTPError.invalidURL(base: baseURL, path: path)
×
96
    }
6✔
97
    return HTTPRequest(method: method, url: url, headers: headers, body: body)
6✔
98
  }
6✔
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc