Skip to content

Commit e7693f2

Browse files
committed
update to OpenAPIKit v1.0
1 parent b138be8 commit e7693f2

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ let package = Package(
1616
targets: ["JSONAPIVizGen"])
1717
],
1818
dependencies: [
19-
.package(url: "https://github.com/mattpolzin/Sampleable", .upToNextMajor(from: "2.0.0")),
19+
.package(url: "https://github.com/mattpolzin/Sampleable", from: "2.0.0"),
2020
.package(url: "https://github.com/mattpolzin/JSONAPI", from: "4.0.0-alpha.2"),
21-
.package(url: "https://github.com/mattpolzin/OpenAPIKit", .upToNextMinor(from: "0.30.0")),
22-
.package(url: "https://github.com/mattpolzin/OpenAPIReflection", .upToNextMinor(from: "0.2.0")),
21+
.package(url: "https://github.com/mattpolzin/OpenAPIKit", from: "1.0.0"),
22+
.package(url: "https://github.com/mattpolzin/OpenAPIReflection", .upToNextMinor(from: "0.3.0")),
2323
.package(url: "https://github.com/typelift/SwiftCheck", .upToNextMinor(from: "0.12.0")),
2424
.package(url: "https://github.com/jpsim/SourceKitten", .upToNextMinor(from: "0.26.0")),
2525
.package(name: "NonEmpty", url: "https://github.com/pointfreeco/swift-nonempty", .upToNextMinor(from: "0.2.0")),

Sources/JSONAPISwiftGen/ResourceObjectSwiftGenCollection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct ResourceObjectSwiftGenCollection {
1313
public init(_ doc: OpenAPI.Document, testSuiteConfiguration: TestSuiteConfiguration) throws {
1414
let pathItems = doc.paths
1515

16-
resourceObjectGenerators = OpenAPI.HttpVerb.allCases
16+
resourceObjectGenerators = OpenAPI.HttpMethod.allCases
1717
.flatMap { httpVerb in
1818
return pathItems.flatMap { (path, pathItem) -> [ResourceObjectSwiftGen] in
1919
guard let operation = pathItem.for(httpVerb) else {
@@ -42,10 +42,10 @@ public struct ResourceObjectSwiftGenCollection {
4242

4343
func documents(
4444
from responses: OpenAPI.Response.Map,
45-
for httpVerb: OpenAPI.HttpVerb,
45+
for httpVerb: OpenAPI.HttpMethod,
4646
at path: OpenAPI.Path,
4747
on server: OpenAPI.Server,
48-
given params: [OpenAPI.PathItem.Parameter],
48+
given params: [OpenAPI.Parameter],
4949
testSuiteConfiguration: TestSuiteConfiguration
5050
) -> [OpenAPI.Response.StatusCode: DataDocumentSwiftGen] {
5151
var responseDocuments = [OpenAPI.Response.StatusCode: DataDocumentSwiftGen]()

Sources/JSONAPISwiftGen/Swift Generators/DocumentSwiftGen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public struct DataDocumentSwiftGen: JSONSchemaSwiftGenerator {
167167
// a `oneOf` with resource types within it.
168168
let resources: [ResourceObjectSwiftGen]
169169
switch items {
170-
case .one(of: let resourceTypeSchemas):
170+
case .one(of: let resourceTypeSchemas, _):
171171
resources = try Array(Set(resourceTypeSchemas.map {
172172
try ResourceObjectSwiftGen(structure: $0,
173173
allowPlaceholders: allowPlaceholders)

Sources/JSONAPISwiftGen/Swift Generators/Test Generators/APIRequestTestSwiftGen.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct APIRequestTestSwiftGen: SwiftGenerator {
2424

2525
public init(server: OpenAPI.Server,
2626
pathComponents: OpenAPI.Path,
27-
parameters: [OpenAPI.PathItem.Parameter]) throws {
27+
parameters: [OpenAPI.Parameter]) throws {
2828

2929
let parameterArgs = try parameters
3030
.filter { !$0.context.inQuery } // for now these are handled as a block rather than each as separate args
@@ -139,23 +139,23 @@ public struct APIRequestTestSwiftGen: SwiftGenerator {
139139
.init(value: "URL(string: \"\(hostUrl.absoluteString)/\(pathString)\")!"))
140140
}
141141

142-
private static func parameterSnippet(from parameter: OpenAPI.PathItem.Parameter) throws -> Decl {
142+
private static func parameterSnippet(from parameter: OpenAPI.Parameter) throws -> Decl {
143143
let (parameterName, parameterType) = try argument(for: parameter)
144144

145145
return PropDecl.let(propName: parameterName,
146146
swiftType: parameterType,
147147
.placeholder(name: parameter.name, type: parameterType))
148148
}
149149

150-
static func argument(for parameter: OpenAPI.PathItem.Parameter) throws -> (name: String, type: SwiftTypeRep) {
150+
static func argument(for parameter: OpenAPI.Parameter) throws -> (name: String, type: SwiftTypeRep) {
151151
let parameterName = propertyCased(parameter.name)
152152
let isParamRequired = parameter.required
153153
let parameterType = try type(from: parameter.schemaOrContent)
154154

155155
return (name: parameterName, type: isParamRequired ? parameterType : parameterType.optional)
156156
}
157157

158-
private static func type(from parameterSchemaOrContent: Either<OpenAPI.PathItem.Parameter.Schema, OpenAPI.Content.Map>) throws -> SwiftTypeRep {
158+
private static func type(from parameterSchemaOrContent: Either<OpenAPI.Parameter.SchemaContext, OpenAPI.Content.Map>) throws -> SwiftTypeRep {
159159
switch parameterSchemaOrContent {
160160
case .a(let paramSchema):
161161
guard let schema = paramSchema.schema.b else {

Sources/JSONAPISwiftGen/Swift Generators/Test Generators/OpenAPIExampleRequestTestSwiftGen.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import OpenAPIKit
1010

11-
public extension OpenAPI.PathItem.Parameter {
11+
public extension OpenAPI.Parameter {
1212
/// Map from a Parameter's name to that Parameter's string-encoded value
1313
typealias ValueMap = [String: String]
1414
}
@@ -29,7 +29,7 @@ public struct OpenAPIExampleRequestTestSwiftGen: SwiftFunctionGenerator {
2929
public init(
3030
server: OpenAPI.Server,
3131
pathComponents: OpenAPI.Path,
32-
parameters: [OpenAPI.PathItem.Parameter],
32+
parameters: [OpenAPI.Parameter],
3333
testSuiteConfiguration: TestSuiteConfiguration,
3434
testProperties: TestProperties,
3535
exampleResponseDataPropName: String?,
@@ -147,8 +147,8 @@ public struct OpenAPIExampleRequestTestSwiftGen: SwiftFunctionGenerator {
147147
}
148148

149149
static func headersSnippet(
150-
from parameters: [OpenAPI.PathItem.Parameter],
151-
values: OpenAPI.PathItem.Parameter.ValueMap,
150+
from parameters: [OpenAPI.Parameter],
151+
values: OpenAPI.Parameter.ValueMap,
152152
inTest testName: String,
153153
reportingMissingParameters: Bool
154154
) throws -> Decl {

Sources/JSONAPISwiftGen/Swift Generators/Test Generators/RequestTestProperties.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ extension OpenAPIExampleRequestTestSwiftGen {
1414
public let name: String
1515
public let host: URL
1616
public let skipExample: Bool
17-
public let parameters: OpenAPI.PathItem.Parameter.ValueMap
18-
public let queryParameters: OpenAPI.PathItem.Parameter.ValueMap
17+
public let parameters: OpenAPI.Parameter.ValueMap
18+
public let queryParameters: OpenAPI.Parameter.ValueMap
1919
public let ignoreMissingParameterWarnings: Bool
2020

2121
/// Create properties for an API Test
@@ -40,7 +40,7 @@ extension OpenAPIExampleRequestTestSwiftGen {
4040
.flatMap { $0 as? Bool }
4141
?? false
4242

43-
guard let testParams = testProps["parameters"] as? OpenAPI.PathItem.Parameter.ValueMap else {
43+
guard let testParams = testProps["parameters"] as? OpenAPI.Parameter.ValueMap else {
4444
throw Error.invalidTestParameters(inTest: name)
4545
}
4646
parameters = testParams

Sources/JSONAPISwiftGen/Swift Generators/Test Generators/TestFunctionName.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import OpenAPIKit
3535
public struct TestFunctionName: Equatable, RawRepresentable {
3636

3737
public let path: OpenAPI.Path
38-
public let endpoint: OpenAPI.HttpVerb
38+
public let endpoint: OpenAPI.HttpMethod
3939
public let direction: HttpDirection
4040
public let testName: String
4141

@@ -102,7 +102,7 @@ public struct TestFunctionName: Equatable, RawRepresentable {
102102

103103
self.direction = direction
104104

105-
guard let endpoint = OpenAPI.HttpVerb(rawValue: String(components.removeLast())) else {
105+
guard let endpoint = OpenAPI.HttpMethod(rawValue: String(components.removeLast())) else {
106106
return nil
107107
}
108108

@@ -113,7 +113,7 @@ public struct TestFunctionName: Equatable, RawRepresentable {
113113

114114
public init(
115115
path: OpenAPI.Path,
116-
endpoint: OpenAPI.HttpVerb,
116+
endpoint: OpenAPI.HttpMethod,
117117
direction: HttpDirection,
118118
testName: String
119119
) {

Tests/JSONAPIOpenAPITests/JSONAPIDocumentOpenAPITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class JSONAPIDocumentOpenAPITests: XCTestCase {
265265
XCTAssertTrue(arrayContext.uniqueItems)
266266
XCTAssertEqual(arrayContext.minItems, 0)
267267

268-
guard case let .one(of: includeNodes)? = arrayContext.items else {
268+
guard case let .one(of: includeNodes, _)? = arrayContext.items else {
269269
XCTFail("Expected Included to contain multiple types of items.")
270270
return
271271
}

0 commit comments

Comments
 (0)