Skip to content

Commit

Permalink
Merge pull request #353 from mattpolzin/modern-if-let
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin authored Dec 10, 2023
2 parents 7b59773 + 5c9fd86 commit 74d7001
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ extension OpenAPI.Example: LocallyDereferenceable {
dereferencedFromComponentNamed name: String?
) throws -> OpenAPI.Example{
var vendorExtensions = self.vendorExtensions
if let name = name {
if let name {
vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Header/DereferencedHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public struct DereferencedHeader: Equatable {
}

var header = header
if let name = name {
if let name {
header.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Link.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ extension OpenAPI.Link: LocallyDereferenceable {
dereferencedFromComponentNamed name: String?
) throws -> OpenAPI.Link {
var vendorExtensions = self.vendorExtensions
if let name = name {
if let name {
vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Parameter/DereferencedParameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct DereferencedParameter: Equatable {
}

var parameter = parameter
if let name = name {
if let name {
parameter.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Path Item/DereferencedPathItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public struct DereferencedPathItem: Equatable {
self.trace = try pathItem.trace.map { try DereferencedOperation($0, resolvingIn: components, following: references) }

var pathItem = pathItem
if let name = name {
if let name {
pathItem.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Request/DereferencedRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct DereferencedRequest: Equatable {
}

var request = request
if let name = name {
if let name {
request.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Response/DereferencedResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct DereferencedResponse: Equatable {
}

var response = response
if let name = name {
if let name {
response.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIKit/Schema Object/DereferencedJSONSchema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ extension JSONSchema: LocallyDereferenceable {
) throws -> DereferencedJSONSchema {
func addComponentNameExtension<T>(to context: CoreContext<T>) -> CoreContext<T> {
var extensions = context.vendorExtensions
if let name = name {
if let name {
extensions[OpenAPI.Components.componentNameExtension] = .init(name)
}
return context.with(vendorExtensions: extensions)
Expand All @@ -479,7 +479,7 @@ extension JSONSchema: LocallyDereferenceable {
// TODO: consider which other core context properties to override here as with description ^

var extensions = dereferenced.vendorExtensions
if let name = name {
if let name {
extensions[OpenAPI.Components.componentNameExtension] = .init(name)
}
dereferenced = dereferenced.with(vendorExtensions: vendorExtensions)
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIKit/Schema Object/JSONSchema+Combining.swift
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ extension JSONSchema.CoreContext {
extension JSONSchema.IntegerContext {
internal func validatedContext() throws -> JSONSchema.IntegerContext {
let validatedMinimum: Bound?
if let minimum = minimum {
if let minimum {
guard minimum.value >= 0 else {
throw JSONSchemaResolutionError(.inconsistency("Integer minimum (\(minimum.value) cannot be below 0"))
}
Expand All @@ -633,7 +633,7 @@ extension JSONSchema.IntegerContext {
extension JSONSchema.NumericContext {
internal func validatedContext() throws -> JSONSchema.NumericContext {
let validatedMinimum: Bound?
if let minimum = minimum {
if let minimum {
guard minimum.value >= 0 else {
throw JSONSchemaResolutionError(.inconsistency("Number minimum (\(minimum.value) cannot be below 0"))
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Schema Object/JSONSchema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ extension JSONSchema: Decodable {
// TODO: support multiple types instead of just grabbing the first one (see TODO immediately above as well)
let typeHint = typeHints.first

if let typeHint = typeHint {
if let typeHint {
let keysFromElsewhere = keysFrom.filter({ $0 != typeHint.group })
if !keysFromElsewhere.isEmpty {
_warnings.append(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Security/SecurityScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ extension OpenAPI.SecurityScheme: LocallyDereferenceable {
dereferencedFromComponentNamed name: String?
) throws -> OpenAPI.SecurityScheme {
var ret = self
if let name = name {
if let name {
ret.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}
return ret
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ extension OpenAPI.Example: LocallyDereferenceable {
dereferencedFromComponentNamed name: String?
) throws -> OpenAPI.Example{
var vendorExtensions = self.vendorExtensions
if let name = name {
if let name {
vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Header/DereferencedHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public struct DereferencedHeader: Equatable {
}

var header = header
if let name = name {
if let name {
header.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Link.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ extension OpenAPI.Link: LocallyDereferenceable {
dereferencedFromComponentNamed name: String?
) throws -> OpenAPI.Link {
var vendorExtensions = self.vendorExtensions
if let name = name {
if let name {
vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Parameter/DereferencedParameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct DereferencedParameter: Equatable {
}

var parameter = parameter
if let name = name {
if let name {
parameter.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Path Item/DereferencedPathItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public struct DereferencedPathItem: Equatable {
self.trace = try pathItem.trace.map { try DereferencedOperation($0, resolvingIn: components, following: references) }

var pathItem = pathItem
if let name = name {
if let name {
pathItem.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Request/DereferencedRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct DereferencedRequest: Equatable {
}

var request = request
if let name = name {
if let name {
request.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Response/DereferencedResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct DereferencedResponse: Equatable {
}

var response = response
if let name = name {
if let name {
response.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIKit30/Schema Object/JSONSchema+Combining.swift
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ extension JSONSchema.CoreContext {
extension JSONSchema.IntegerContext {
internal func validatedContext() throws -> JSONSchema.IntegerContext {
let validatedMinimum: Bound?
if let minimum = minimum {
if let minimum {
guard minimum.value >= 0 else {
throw JSONSchemaResolutionError(.inconsistency("Integer minimum (\(minimum.value) cannot be below 0"))
}
Expand All @@ -603,7 +603,7 @@ extension JSONSchema.IntegerContext {
extension JSONSchema.NumericContext {
internal func validatedContext() throws -> JSONSchema.NumericContext {
let validatedMinimum: Bound?
if let minimum = minimum {
if let minimum {
guard minimum.value >= 0 else {
throw JSONSchemaResolutionError(.inconsistency("Number minimum (\(minimum.value) cannot be below 0"))
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Schema Object/JSONSchema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ extension JSONSchema: Decodable {
)
}

if let typeHint = typeHint {
if let typeHint {
let keysFromElsewhere = keysFrom.filter({ $0 != typeHint.group })
if !keysFromElsewhere.isEmpty {
_warnings.append(
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit30/Security/SecurityScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ extension OpenAPI.SecurityScheme: LocallyDereferenceable {
dereferencedFromComponentNamed name: String?
) throws -> OpenAPI.SecurityScheme {
var ret = self
if let name = name {
if let name {
ret.vendorExtensions[OpenAPI.Components.componentNameExtension] = .init(name)
}
return ret
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenAPIKitCompat/Compat30To31.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ extension OpenAPIKit30.OpenAPI.Parameter.SchemaContext: To31 {
let newExamples = examples?.mapValues(eitherRefTo31)
switch schema {
case .a(let ref):
if let newExamples = newExamples {
if let newExamples {
return OpenAPIKit.OpenAPI.Parameter.SchemaContext(
schemaReference: .init(ref.to31()),
style: style,
Expand All @@ -190,7 +190,7 @@ extension OpenAPIKit30.OpenAPI.Parameter.SchemaContext: To31 {
)
}
case .b(let schema):
if let newExamples = newExamples {
if let newExamples {
return OpenAPIKit.OpenAPI.Parameter.SchemaContext(
schema.to31(),
style: style,
Expand Down

0 comments on commit 74d7001

Please sign in to comment.