Skip to content

Commit 5d33ea9

Browse files
Update integration test to repro issue with AOT codegen on targets with dependencies
1 parent 576e620 commit 5d33ea9

File tree

11 files changed

+456
-0
lines changed

11 files changed

+456
-0
lines changed

IntegrationTest/Package.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,9 @@ let package = Package(
5151
name: "MockTransportServer",
5252
dependencies: ["Server", .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")]
5353
),
54+
// Targets to integration test the command plugin
55+
.target(name: "TypesAOT"),
56+
.target(name: "Empty"),
57+
.target(name: "TypesAOTWithDependency", dependencies: ["Empty"]),
5458
]
5559
)

IntegrationTest/Sources/Empty/Empty.swift

Whitespace-only changes.

IntegrationTest/Sources/TypesAOT/Empty.swift

Whitespace-only changes.
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
// Generated by swift-openapi-generator, do not modify.
2+
@_spi(Generated) import OpenAPIRuntime
3+
#if os(Linux)
4+
@preconcurrency import struct Foundation.URL
5+
@preconcurrency import struct Foundation.Data
6+
@preconcurrency import struct Foundation.Date
7+
#else
8+
import struct Foundation.URL
9+
import struct Foundation.Data
10+
import struct Foundation.Date
11+
#endif
12+
/// A type that performs HTTP operations defined by the OpenAPI document.
13+
package protocol APIProtocol: Sendable {
14+
/// - Remark: HTTP `GET /greet`.
15+
/// - Remark: Generated from `#/paths//greet/get(getGreeting)`.
16+
func getGreeting(_ input: Operations.GetGreeting.Input) async throws -> Operations.GetGreeting.Output
17+
}
18+
19+
/// Convenience overloads for operation inputs.
20+
extension APIProtocol {
21+
/// - Remark: HTTP `GET /greet`.
22+
/// - Remark: Generated from `#/paths//greet/get(getGreeting)`.
23+
package func getGreeting(
24+
query: Operations.GetGreeting.Input.Query = .init(),
25+
headers: Operations.GetGreeting.Input.Headers = .init()
26+
) async throws -> Operations.GetGreeting.Output {
27+
try await getGreeting(Operations.GetGreeting.Input(
28+
query: query,
29+
headers: headers
30+
))
31+
}
32+
}
33+
34+
/// Server URLs defined in the OpenAPI document.
35+
package enum Servers {
36+
/// Example
37+
package enum Server1 {
38+
/// Example
39+
package static func url() throws -> Foundation.URL {
40+
try Foundation.URL(
41+
validatingOpenAPIServerURL: "https://example.com/api",
42+
variables: []
43+
)
44+
}
45+
}
46+
/// Example
47+
@available(*, deprecated, renamed: "Servers.Server1.url")
48+
package static func server1() throws -> Foundation.URL {
49+
try Foundation.URL(
50+
validatingOpenAPIServerURL: "https://example.com/api",
51+
variables: []
52+
)
53+
}
54+
}
55+
56+
/// Types generated from the components section of the OpenAPI document.
57+
package enum Components {
58+
/// Types generated from the `#/components/schemas` section of the OpenAPI document.
59+
package enum Schemas {
60+
/// - Remark: Generated from `#/components/schemas/Greeting`.
61+
package struct Greeting: Codable, Hashable, Sendable {
62+
/// - Remark: Generated from `#/components/schemas/Greeting/message`.
63+
package var message: Swift.String
64+
/// Creates a new `Greeting`.
65+
///
66+
/// - Parameters:
67+
/// - message:
68+
package init(message: Swift.String) {
69+
self.message = message
70+
}
71+
package enum CodingKeys: String, CodingKey {
72+
case message
73+
}
74+
}
75+
}
76+
/// Types generated from the `#/components/parameters` section of the OpenAPI document.
77+
package enum Parameters {}
78+
/// Types generated from the `#/components/requestBodies` section of the OpenAPI document.
79+
package enum RequestBodies {}
80+
/// Types generated from the `#/components/responses` section of the OpenAPI document.
81+
package enum Responses {}
82+
/// Types generated from the `#/components/headers` section of the OpenAPI document.
83+
package enum Headers {}
84+
}
85+
86+
/// API operations, with input and output types, generated from `#/paths` in the OpenAPI document.
87+
package enum Operations {
88+
/// - Remark: HTTP `GET /greet`.
89+
/// - Remark: Generated from `#/paths//greet/get(getGreeting)`.
90+
package enum GetGreeting {
91+
package static let id: Swift.String = "getGreeting"
92+
package struct Input: Sendable, Hashable {
93+
/// - Remark: Generated from `#/paths/greet/GET/query`.
94+
package struct Query: Sendable, Hashable {
95+
/// name
96+
///
97+
/// - Remark: Generated from `#/paths/greet/GET/query/name`.
98+
package var name: Swift.String?
99+
/// Creates a new `Query`.
100+
///
101+
/// - Parameters:
102+
/// - name: name
103+
package init(name: Swift.String? = nil) {
104+
self.name = name
105+
}
106+
}
107+
package var query: Operations.GetGreeting.Input.Query
108+
/// - Remark: Generated from `#/paths/greet/GET/header`.
109+
package struct Headers: Sendable, Hashable {
110+
package var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.GetGreeting.AcceptableContentType>]
111+
/// Creates a new `Headers`.
112+
///
113+
/// - Parameters:
114+
/// - accept:
115+
package init(accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.GetGreeting.AcceptableContentType>] = .defaultValues()) {
116+
self.accept = accept
117+
}
118+
}
119+
package var headers: Operations.GetGreeting.Input.Headers
120+
/// Creates a new `Input`.
121+
///
122+
/// - Parameters:
123+
/// - query:
124+
/// - headers:
125+
package init(
126+
query: Operations.GetGreeting.Input.Query = .init(),
127+
headers: Operations.GetGreeting.Input.Headers = .init()
128+
) {
129+
self.query = query
130+
self.headers = headers
131+
}
132+
}
133+
@frozen package enum Output: Sendable, Hashable {
134+
package struct Ok: Sendable, Hashable {
135+
/// - Remark: Generated from `#/paths/greet/GET/responses/200/content`.
136+
@frozen package enum Body: Sendable, Hashable {
137+
/// - Remark: Generated from `#/paths/greet/GET/responses/200/content/application\/json`.
138+
case json(Components.Schemas.Greeting)
139+
/// The associated value of the enum case if `self` is `.json`.
140+
///
141+
/// - Throws: An error if `self` is not `.json`.
142+
/// - SeeAlso: `.json`.
143+
package var json: Components.Schemas.Greeting {
144+
get throws {
145+
switch self {
146+
case let .json(body):
147+
return body
148+
}
149+
}
150+
}
151+
}
152+
/// Received HTTP response body
153+
package var body: Operations.GetGreeting.Output.Ok.Body
154+
/// Creates a new `Ok`.
155+
///
156+
/// - Parameters:
157+
/// - body: Received HTTP response body
158+
package init(body: Operations.GetGreeting.Output.Ok.Body) {
159+
self.body = body
160+
}
161+
}
162+
/// Returns a greeting
163+
///
164+
/// - Remark: Generated from `#/paths//greet/get(getGreeting)/responses/200`.
165+
///
166+
/// HTTP response code: `200 ok`.
167+
case ok(Operations.GetGreeting.Output.Ok)
168+
/// The associated value of the enum case if `self` is `.ok`.
169+
///
170+
/// - Throws: An error if `self` is not `.ok`.
171+
/// - SeeAlso: `.ok`.
172+
package var ok: Operations.GetGreeting.Output.Ok {
173+
get throws {
174+
switch self {
175+
case let .ok(response):
176+
return response
177+
default:
178+
try throwUnexpectedResponseStatus(
179+
expectedStatus: "ok",
180+
response: self
181+
)
182+
}
183+
}
184+
}
185+
/// Undocumented response.
186+
///
187+
/// A response with a code that is not documented in the OpenAPI document.
188+
case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload)
189+
}
190+
@frozen package enum AcceptableContentType: AcceptableProtocol {
191+
case json
192+
case other(Swift.String)
193+
package init?(rawValue: Swift.String) {
194+
switch rawValue.lowercased() {
195+
case "application/json":
196+
self = .json
197+
default:
198+
self = .other(rawValue)
199+
}
200+
}
201+
package var rawValue: Swift.String {
202+
switch self {
203+
case let .other(string):
204+
return string
205+
case .json:
206+
return "application/json"
207+
}
208+
}
209+
package static var allCases: [Self] {
210+
[
211+
.json
212+
]
213+
}
214+
}
215+
}
216+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
generate:
2+
- types
3+
accessModifier: package
4+
namingStrategy: idiomatic
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../openapi.yaml

IntegrationTest/Sources/TypesAOTWithDependency/Empty.swift

Whitespace-only changes.

0 commit comments

Comments
 (0)