Skip to content

Commit b71ac7b

Browse files
authored
Merge pull request #437 from mattpolzin/add-version-3_1_2-property
Add missing OAS version property
2 parents f609d26 + ee13cfe commit b71ac7b

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

Sources/OpenAPIKit/Document/Document.swift

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -454,30 +454,32 @@ extension OpenAPI.Document {
454454
case v3_1_1
455455
case v3_1_x(x: Int)
456456

457-
public init?(rawValue: String) {
458-
switch rawValue {
459-
case "3.1.0": self = .v3_1_0
460-
case "3.1.1": self = .v3_1_1
461-
default:
462-
let components = rawValue.split(separator: ".")
463-
guard components.count == 3 else {
464-
return nil
465-
}
466-
guard components[0] == "3", components[1] == "1" else {
467-
return nil
468-
}
469-
guard let patchVersion = Int(components[2], radix: 10) else {
470-
return nil
471-
}
472-
// to support newer versions released in the future without a breaking
473-
// change to the enumeration, bump the upper limit here to e.g. 2 or 3
474-
// or 6:
475-
guard patchVersion > 1 && patchVersion <= 2 else {
476-
return nil
477-
}
478-
self = .v3_1_x(x: patchVersion)
479-
}
480-
}
457+
public static let v3_1_2 : Self = .v3_1_x(x: 2)
458+
459+
public init?(rawValue: String) {
460+
switch rawValue {
461+
case "3.1.0": self = .v3_1_0
462+
case "3.1.1": self = .v3_1_1
463+
default:
464+
let components = rawValue.split(separator: ".")
465+
guard components.count == 3 else {
466+
return nil
467+
}
468+
guard components[0] == "3", components[1] == "1" else {
469+
return nil
470+
}
471+
guard let patchVersion = Int(components[2], radix: 10) else {
472+
return nil
473+
}
474+
// to support newer versions released in the future without a breaking
475+
// change to the enumeration, bump the upper limit here to e.g. 2 or 3
476+
// or 6:
477+
guard patchVersion > 1 && patchVersion <= 2 else {
478+
return nil
479+
}
480+
self = .v3_1_x(x: patchVersion)
481+
}
482+
}
481483

482484
public var rawValue: String {
483485
switch self {

0 commit comments

Comments
 (0)