Skip to content

Commit d55ce1a

Browse files
feat: adds support for Swift 6 (#6)
1 parent 48cade5 commit d55ce1a

File tree

11 files changed

+188
-93
lines changed

11 files changed

+188
-93
lines changed

.github/workflows/code-quality.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ on:
1010

1111
jobs:
1212
test-ios:
13-
runs-on: macos-14
13+
runs-on: macos-15
1414

1515
steps:
1616
- uses: actions/checkout@v4
1717

1818
- name: Build and test
19-
run: xcodebuild test -scheme JSONSchema -destination 'platform=iOS Simulator,name=iPhone 15 Pro'
19+
run: xcodebuild test -scheme JSONSchema -destination 'platform=iOS Simulator,name=iPhone 16 Pro'
2020

2121
test-macos:
22-
runs-on: macos-14
22+
runs-on: macos-15
2323

2424
steps:
2525
- uses: actions/checkout@v4

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.8
1+
// swift-tools-version: 6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

Sources/JSONSchema/JSONSchema+Array.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for an array type in JSON Schema.
12-
struct ArraySchema: Codable {
12+
struct ArraySchema: Codable, Sendable {
1313
/// The schema for the items in the array. [10.3.1.2](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-00#rfc.section.10.3.1.2)
1414
public let items: JSONSchema?
1515

@@ -44,15 +44,16 @@ public extension JSONSchema {
4444
maxItems: Int? = nil,
4545
uniqueItems: Bool? = nil
4646
) -> JSONSchema {
47-
let schema = JSONSchema(type: .array, description: description)
48-
schema.arraySchema = ArraySchema(
49-
items: items,
50-
prefixItems: prefixItems,
51-
minItems: minItems,
52-
maxItems: maxItems,
53-
uniqueItems: uniqueItems
47+
JSONSchema(
48+
type: .array,
49+
description: description,
50+
arraySchema: ArraySchema(
51+
items: items,
52+
prefixItems: prefixItems,
53+
minItems: minItems,
54+
maxItems: maxItems,
55+
uniqueItems: uniqueItems
56+
)
5457
)
55-
56-
return schema
5758
}
5859
}

Sources/JSONSchema/JSONSchema+Boolean.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for a boolean type in JSON Schema.
12-
struct BooleanSchema: Codable {}
12+
struct BooleanSchema: Codable, Sendable {}
1313

1414
/// Creates a new JSON Schema for a boolean type.
1515
///
1616
/// - Parameter description: An optional description of the boolean schema.
1717
/// - Returns: A new ``JSONSchema`` instance that represents a boolean schema.
1818
static func boolean(description: String? = nil) -> JSONSchema {
19-
let schema = JSONSchema(type: .boolean, description: description)
20-
schema.booleanSchema = BooleanSchema()
21-
22-
return schema
19+
JSONSchema(
20+
type: .boolean,
21+
description: description,
22+
booleanSchema: BooleanSchema()
23+
)
2324
}
2425
}

Sources/JSONSchema/JSONSchema+Enum.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for an enum type in JSON Schema.
12-
struct EnumSchema: Codable, Equatable {
12+
struct EnumSchema: Codable, Equatable, Sendable {
1313
/// The array of possible values for this enum schema.
1414
public let values: [Value]
1515

1616
/// An enum that represents the possible values in an enum schema.
17-
public enum Value: Codable, Equatable {
17+
public enum Value: Codable, Equatable, Sendable {
1818
/// A string value.
1919
case string(String)
2020
/// A number value (represented as a `Double`).
@@ -89,9 +89,12 @@ public extension JSONSchema {
8989
/// - values: An array of possible values for this enum schema.
9090
/// - Returns: A new ``JSONSchema`` instance that represents an enum schema.
9191
static func `enum`(description: String? = nil, values: [EnumSchema.Value]) -> JSONSchema {
92-
let schema = JSONSchema(type: .enum, description: description)
93-
schema.enumSchema = EnumSchema(values: values)
94-
95-
return schema
92+
JSONSchema(
93+
type: .enum,
94+
description: description,
95+
enumSchema: EnumSchema(
96+
values: values
97+
)
98+
)
9699
}
97100
}

Sources/JSONSchema/JSONSchema+Integer.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for an integer type in JSON Schema.
12-
struct IntegerSchema: Codable {
12+
struct IntegerSchema: Codable, Sendable {
1313
/// A value that the integer must be a multiple of. [6.2.1](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.6.2.1)
1414
public let multipleOf: Int?
1515

@@ -44,15 +44,16 @@ public extension JSONSchema {
4444
exclusiveMinimum: Int? = nil,
4545
exclusiveMaximum: Int? = nil
4646
) -> JSONSchema {
47-
let schema = JSONSchema(type: .integer, description: description)
48-
schema.integerSchema = IntegerSchema(
49-
multipleOf: multipleOf,
50-
minimum: minimum,
51-
maximum: maximum,
52-
exclusiveMinimum: exclusiveMinimum,
53-
exclusiveMaximum: exclusiveMaximum
47+
JSONSchema(
48+
type: .integer,
49+
description: description,
50+
integerSchema: IntegerSchema(
51+
multipleOf: multipleOf,
52+
minimum: minimum,
53+
maximum: maximum,
54+
exclusiveMinimum: exclusiveMinimum,
55+
exclusiveMaximum: exclusiveMaximum
56+
)
5457
)
55-
56-
return schema
5758
}
5859
}

Sources/JSONSchema/JSONSchema+Null.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for a null type in JSON Schema.
12-
struct NullSchema: Codable {}
12+
struct NullSchema: Codable, Sendable {}
1313

1414
/// Creates a new JSON Schema for a null type.
1515
///
1616
/// - Parameter description: An optional description of the null schema.
1717
/// - Returns: A new ``JSONSchema`` instance that represents a null schema.
1818
static func null(description: String? = nil) -> JSONSchema {
19-
let schema = JSONSchema(type: .null, description: description)
20-
schema.nullSchema = NullSchema()
21-
22-
return schema
19+
JSONSchema(
20+
type: .null,
21+
description: description,
22+
nullSchema: NullSchema()
23+
)
2324
}
2425
}

Sources/JSONSchema/JSONSchema+Number.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for a number type in JSON Schema.
12-
struct NumberSchema: Codable {
12+
struct NumberSchema: Codable, Sendable {
1313
/// A value that the number must be a multiple of. [6.2.1](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.6.2.1)
1414
public let multipleOf: Double?
1515

@@ -44,15 +44,16 @@ public extension JSONSchema {
4444
exclusiveMinimum: Double? = nil,
4545
exclusiveMaximum: Double? = nil
4646
) -> JSONSchema {
47-
let schema = JSONSchema(type: .number, description: description)
48-
schema.numberSchema = NumberSchema(
49-
multipleOf: multipleOf,
50-
minimum: minimum,
51-
maximum: maximum,
52-
exclusiveMinimum: exclusiveMinimum,
53-
exclusiveMaximum: exclusiveMaximum
47+
JSONSchema(
48+
type: .number,
49+
description: description,
50+
numberSchema: NumberSchema(
51+
multipleOf: multipleOf,
52+
minimum: minimum,
53+
maximum: maximum,
54+
exclusiveMinimum: exclusiveMinimum,
55+
exclusiveMaximum: exclusiveMaximum
56+
)
5457
)
55-
56-
return schema
5758
}
5859
}

Sources/JSONSchema/JSONSchema+Object.swift

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

1010
public extension JSONSchema {
11-
struct ObjectSchema: Codable {
11+
struct ObjectSchema: Codable, Sendable {
1212
/// A dictionary of property names and their corresponding JSON schemas. [10.3.2.1](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-00#rfc.section.10.3.2.1)
1313
public let properties: [String: JSONSchema]?
1414

@@ -28,7 +28,7 @@ public extension JSONSchema {
2828
public let patternProperties: [String: JSONSchema]?
2929

3030
/// An enum that represents the possible values for the ``additionalProperties`` field in an object schema.
31-
public enum AdditionalProperties: Codable {
31+
public enum AdditionalProperties: Codable, Sendable {
3232
/// A boolean value indicating whether additional properties are allowed.
3333
case boolean(Bool)
3434
/// A JSON schema that all additional properties must conform to.
@@ -77,16 +77,17 @@ public extension JSONSchema {
7777
additionalProperties: ObjectSchema.AdditionalProperties? = nil,
7878
patternProperties: [String: JSONSchema]? = nil
7979
) -> JSONSchema {
80-
let schema = JSONSchema(type: .object, description: description)
81-
schema.objectSchema = ObjectSchema(
82-
properties: properties,
83-
required: required,
84-
minProperties: minProperties,
85-
maxProperties: maxProperties,
86-
additionalProperties: additionalProperties,
87-
patternProperties: patternProperties
80+
JSONSchema(
81+
type: .object,
82+
description: description,
83+
objectSchema: ObjectSchema(
84+
properties: properties,
85+
required: required,
86+
minProperties: minProperties,
87+
maxProperties: maxProperties,
88+
additionalProperties: additionalProperties,
89+
patternProperties: patternProperties
90+
)
8891
)
89-
90-
return schema
9192
}
9293
}

Sources/JSONSchema/JSONSchema+String.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
public extension JSONSchema {
1111
/// A structure that represents the schema for a string type in JSON Schema.
12-
struct StringSchema: Codable {
12+
struct StringSchema: Codable, Sendable {
1313
/// The minimum length of the string. [6.3.2](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.6.3.2)
1414
public let minLength: Int?
1515

@@ -34,9 +34,14 @@ public extension JSONSchema {
3434
maxLength: Int? = nil,
3535
pattern: String? = nil
3636
) -> JSONSchema {
37-
let schema = JSONSchema(type: .string, description: description)
38-
schema.stringSchema = StringSchema(minLength: minLength, maxLength: maxLength, pattern: pattern)
39-
40-
return schema
37+
JSONSchema(
38+
type: .string,
39+
description: description,
40+
stringSchema: StringSchema(
41+
minLength: minLength,
42+
maxLength: maxLength,
43+
pattern: pattern
44+
)
45+
)
4146
}
4247
}

0 commit comments

Comments
 (0)