forked from apple/swift-openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
175 lines (157 loc) · 5.7 KB
/
Copy pathPackage.swift
File metadata and controls
175 lines (157 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// swift-tools-version:5.8
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftOpenAPIGenerator open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftOpenAPIGenerator project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import PackageDescription
// General Swift-settings for all targets.
var swiftSettings: [SwiftSetting] = []
#if swift(>=5.9)
swiftSettings.append(
// https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md
// Require `any` for existential types.
.enableUpcomingFeature("ExistentialAny")
)
#endif
let package = Package(
name: "swift-openapi-generator",
platforms: [
.macOS(.v10_15),
// The platforms below are not currently supported for running
// the generator itself. We include them here to allow the generator
// to emit a more descriptive compiler error.
.iOS(.v13), .tvOS(.v13), .watchOS(.v6),
],
products: [
.executable(name: "swift-openapi-generator", targets: ["swift-openapi-generator"]),
.plugin(name: "OpenAPIGenerator", targets: ["OpenAPIGenerator"]),
.plugin(name: "OpenAPIGeneratorCommand", targets: ["OpenAPIGeneratorCommand"]),
.library(name: "_OpenAPIGeneratorCore", targets: ["_OpenAPIGeneratorCore"]),
],
dependencies: [
// Generate Swift code
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "508.0.1"
),
// Format Swift code
.package(
url: "https://github.com/apple/swift-format.git",
from: "508.0.1"
),
// General algorithms
.package(
url: "https://github.com/apple/swift-algorithms",
from: "1.0.0"
),
// Read OpenAPI documents
.package(
url: "https://github.com/mattpolzin/OpenAPIKit.git",
exact: "3.0.0-alpha.7"
),
.package(
url: "https://github.com/jpsim/Yams.git",
"4.0.0"..<"6.0.0"
),
// CLI Tool
.package(
url: "https://github.com/apple/swift-argument-parser.git",
from: "1.0.1"
),
// Tests-only: Runtime library linked by generated code
.package(url: "https://github.com/apple/swift-openapi-runtime", .upToNextMinor(from: "0.1.3")),
// Build and preview docs
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
// Generator Core
.target(
name: "_OpenAPIGeneratorCore",
dependencies: [
.product(name: "OpenAPIKit30", package: "OpenAPIKit"),
.product(name: "Algorithms", package: "swift-algorithms"),
.product(name: "Yams", package: "Yams"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftFormat", package: "swift-format"),
.product(name: "SwiftFormatConfiguration", package: "swift-format"),
],
swiftSettings: swiftSettings
),
// Generator Core Tests
.testTarget(
name: "OpenAPIGeneratorCoreTests",
dependencies: [
"_OpenAPIGeneratorCore"
],
swiftSettings: swiftSettings
),
// GeneratorReferenceTests
.testTarget(
name: "OpenAPIGeneratorReferenceTests",
dependencies: [
"_OpenAPIGeneratorCore",
.product(name: "SwiftFormat", package: "swift-format"),
.product(name: "SwiftFormatConfiguration", package: "swift-format"),
],
resources: [
.copy("Resources")
],
swiftSettings: swiftSettings
),
// PetstoreConsumerTests
// Builds and tests the reference code from GeneratorReferenceTests
// to ensure it actually works correctly at runtime.
.testTarget(
name: "PetstoreConsumerTests",
dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")
],
swiftSettings: swiftSettings
),
// Generator CLI
.executableTarget(
name: "swift-openapi-generator",
dependencies: [
"_OpenAPIGeneratorCore",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: swiftSettings
),
// Build Plugin
.plugin(
name: "OpenAPIGenerator",
capability: .buildTool(),
dependencies: [
"swift-openapi-generator"
]
),
// Command Plugin
.plugin(
name: "OpenAPIGeneratorCommand",
capability: .command(
intent: .custom(
verb: "generate-code-from-openapi",
description: "Generate Swift code from an OpenAPI document."
),
permissions: [
.writeToPackageDirectory(
reason: "To write the generated Swift files back into the source directory of the package."
)
]
),
dependencies: [
"swift-openapi-generator"
]
),
]
)