diff --git a/Package.swift b/Package.swift index 63fa38aa..808b7d15 100644 --- a/Package.swift +++ b/Package.swift @@ -14,6 +14,13 @@ //===----------------------------------------------------------------------===// import PackageDescription +// General Swift-settings for all targets. +let swiftSettings: [SwiftSetting] = [ + // https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md + // Require `any` for existential types. + .enableUpcomingFeature("ExistentialAny") +] + let package = Package( name: "swift-openapi-generator", platforms: [ @@ -72,6 +79,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), ], targets: [ + // Generator Core .target( name: "_OpenAPIGeneratorCore", @@ -83,7 +91,8 @@ let package = Package( .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), .product(name: "SwiftFormat", package: "swift-format"), .product(name: "SwiftFormatConfiguration", package: "swift-format"), - ] + ], + swiftSettings: swiftSettings ), // Generator Core Tests @@ -91,7 +100,8 @@ let package = Package( name: "OpenAPIGeneratorCoreTests", dependencies: [ "_OpenAPIGeneratorCore" - ] + ], + swiftSettings: swiftSettings ), // GeneratorReferenceTests @@ -104,7 +114,8 @@ let package = Package( ], resources: [ .copy("Resources") - ] + ], + swiftSettings: swiftSettings ), // PetstoreConsumerTests @@ -114,7 +125,8 @@ let package = Package( name: "PetstoreConsumerTests", dependencies: [ .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime") - ] + ], + swiftSettings: swiftSettings ), // Generator CLI @@ -123,7 +135,8 @@ let package = Package( dependencies: [ "_OpenAPIGeneratorCore", .product(name: "ArgumentParser", package: "swift-argument-parser"), - ] + ], + swiftSettings: swiftSettings ), // Build Plugin diff --git a/Sources/_OpenAPIGeneratorCore/GeneratorPipeline.swift b/Sources/_OpenAPIGeneratorCore/GeneratorPipeline.swift index 108b1b7a..a9caec5e 100644 --- a/Sources/_OpenAPIGeneratorCore/GeneratorPipeline.swift +++ b/Sources/_OpenAPIGeneratorCore/GeneratorPipeline.swift @@ -89,7 +89,7 @@ struct GeneratorPipeline { public func runGenerator( input: InMemoryInputFile, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> InMemoryOutputFile { try makeGeneratorPipeline(config: config, diagnostics: diagnostics).run(input) } @@ -105,12 +105,12 @@ public func runGenerator( /// - Returns: A configured generator pipeline that can be executed with /// ``GeneratorPipeline/run(_:)``. func makeGeneratorPipeline( - parser: ParserProtocol = YamsParser(), - translator: TranslatorProtocol = MultiplexTranslator(), - renderer: RendererProtocol = TextBasedRenderer(), + parser: any ParserProtocol = YamsParser(), + translator: any TranslatorProtocol = MultiplexTranslator(), + renderer: any RendererProtocol = TextBasedRenderer(), formatter: @escaping (InMemoryOutputFile) throws -> InMemoryOutputFile = { try $0.swiftFormatted }, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) -> GeneratorPipeline { return .init( parseOpenAPIFileStage: .init( diff --git a/Sources/_OpenAPIGeneratorCore/Parser/ParserProtocol.swift b/Sources/_OpenAPIGeneratorCore/Parser/ParserProtocol.swift index 45dff913..30df1df8 100644 --- a/Sources/_OpenAPIGeneratorCore/Parser/ParserProtocol.swift +++ b/Sources/_OpenAPIGeneratorCore/Parser/ParserProtocol.swift @@ -27,6 +27,6 @@ protocol ParserProtocol { func parseOpenAPI( _ input: InMemoryInputFile, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> ParsedOpenAPIRepresentation } diff --git a/Sources/_OpenAPIGeneratorCore/Parser/YamsParser.swift b/Sources/_OpenAPIGeneratorCore/Parser/YamsParser.swift index b7ccc238..6398d500 100644 --- a/Sources/_OpenAPIGeneratorCore/Parser/YamsParser.swift +++ b/Sources/_OpenAPIGeneratorCore/Parser/YamsParser.swift @@ -21,7 +21,7 @@ struct YamsParser: ParserProtocol { func parseOpenAPI( _ input: InMemoryInputFile, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> ParsedOpenAPIRepresentation { let decoder = YAMLDecoder() let openapiData = input.contents @@ -86,7 +86,7 @@ struct YamsParser: ParserProtocol { location: .init(filePath: input.absolutePath.path, lineNumber: yamlMark.line - 1) ) } - } else if let openAPIError = context.underlyingError as? OpenAPIError { + } else if let openAPIError = context.underlyingError as? (any OpenAPIError) { throw Diagnostic.error( message: openAPIError.localizedDescription, location: .init(filePath: input.absolutePath.path) diff --git a/Sources/_OpenAPIGeneratorCore/Renderer/RendererProtocol.swift b/Sources/_OpenAPIGeneratorCore/Renderer/RendererProtocol.swift index 54651a46..c76842f9 100644 --- a/Sources/_OpenAPIGeneratorCore/Renderer/RendererProtocol.swift +++ b/Sources/_OpenAPIGeneratorCore/Renderer/RendererProtocol.swift @@ -27,6 +27,6 @@ protocol RendererProtocol { func render( structured code: StructuredSwiftRepresentation, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> InMemoryOutputFile } diff --git a/Sources/_OpenAPIGeneratorCore/Renderer/TextBasedRenderer.swift b/Sources/_OpenAPIGeneratorCore/Renderer/TextBasedRenderer.swift index 4985ebb9..e0da301c 100644 --- a/Sources/_OpenAPIGeneratorCore/Renderer/TextBasedRenderer.swift +++ b/Sources/_OpenAPIGeneratorCore/Renderer/TextBasedRenderer.swift @@ -20,7 +20,7 @@ struct TextBasedRenderer: RendererProtocol { func render( structured: StructuredSwiftRepresentation, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> InMemoryOutputFile { let namedFile = structured.file return InMemoryOutputFile( diff --git a/Sources/_OpenAPIGeneratorCore/Translator/ClientTranslator/ClientTranslator.swift b/Sources/_OpenAPIGeneratorCore/Translator/ClientTranslator/ClientTranslator.swift index 49abd18b..c02eac5d 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/ClientTranslator/ClientTranslator.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/ClientTranslator/ClientTranslator.swift @@ -25,7 +25,7 @@ import OpenAPIKit30 struct ClientFileTranslator: FileTranslator { var config: Config - var diagnostics: DiagnosticCollector + var diagnostics: any DiagnosticCollector var components: OpenAPI.Components func translateFile( @@ -79,7 +79,10 @@ struct ClientFileTranslator: FileTranslator { type: Constants.Configuration.typeName, defaultValue: .dot("init").call([]) ), - .init(label: "transport", type: Constants.Client.Transport.typeName), + .init( + label: "transport", + type: Constants.Client.Transport.typeName + ), .init( label: "middlewares", type: "[\(Constants.Client.Middleware.typeName)]", diff --git a/Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateCodable.swift b/Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateCodable.swift index cba769d4..47247f08 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateCodable.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateCodable.swift @@ -593,7 +593,7 @@ fileprivate extension FileTranslator { accessModifier: config.access, kind: .function(name: "encode"), parameters: [ - .init(label: "to", name: "encoder", type: "Encoder") + .init(label: "to", name: "encoder", type: "any Encoder") ], keywords: [ .throws @@ -610,7 +610,7 @@ fileprivate extension FileTranslator { accessModifier: config.access, kind: .initializer, parameters: [ - .init(label: "from", name: "decoder", type: "Decoder") + .init(label: "from", name: "decoder", type: "any Decoder") ], keywords: [ .throws diff --git a/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift b/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift index 042ac6ff..95b8d097 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift @@ -80,14 +80,14 @@ enum Constants { enum Transport { /// The name of the client transport type. - static let typeName: String = "ClientTransport" + static let typeName: String = "any ClientTransport" } /// Constants related to the client middleware type. enum Middleware { /// The name of the client middleware type. - static let typeName: String = "ClientMiddleware" + static let typeName: String = "any ClientMiddleware" } } @@ -110,14 +110,14 @@ enum Constants { enum Transport { /// The name of the server transport type. - static let typeName: String = "ServerTransport" + static let typeName: String = "any ServerTransport" } /// Constants related to the server middleware type. enum Middleware { /// The name of the server middleware type. - static let typeName: String = "ServerMiddleware" + static let typeName: String = "any ServerMiddleware" } } diff --git a/Sources/_OpenAPIGeneratorCore/Translator/FileTranslator.swift b/Sources/_OpenAPIGeneratorCore/Translator/FileTranslator.swift index e6843e41..c81a71a9 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/FileTranslator.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/FileTranslator.swift @@ -29,7 +29,7 @@ protocol FileTranslator { /// The collector receives diagnostics from the translator, which should /// be surfaced to the user in some way. - var diagnostics: DiagnosticCollector { get } + var diagnostics: any DiagnosticCollector { get } /// The components section of the OpenAPI document is required by the /// translator logic to follow JSON references to schemas, parameters, diff --git a/Sources/_OpenAPIGeneratorCore/Translator/MultiplexTranslator.swift b/Sources/_OpenAPIGeneratorCore/Translator/MultiplexTranslator.swift index f1f0e16e..a617e2c4 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/MultiplexTranslator.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/MultiplexTranslator.swift @@ -19,9 +19,9 @@ struct MultiplexTranslator: TranslatorProtocol { func translate( parsedOpenAPI: ParsedOpenAPIRepresentation, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> StructuredSwiftRepresentation { - let translator: FileTranslator + let translator: any FileTranslator switch config.mode { case .types: translator = TypesFileTranslator( diff --git a/Sources/_OpenAPIGeneratorCore/Translator/ServerTranslator/ServerTranslator.swift b/Sources/_OpenAPIGeneratorCore/Translator/ServerTranslator/ServerTranslator.swift index f1360371..9a87ea3a 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/ServerTranslator/ServerTranslator.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/ServerTranslator/ServerTranslator.swift @@ -23,7 +23,7 @@ import OpenAPIKit30 struct ServerFileTranslator: FileTranslator { var config: Config - var diagnostics: DiagnosticCollector + var diagnostics: any DiagnosticCollector var components: OpenAPI.Components func translateFile( diff --git a/Sources/_OpenAPIGeneratorCore/Translator/TranslatorProtocol.swift b/Sources/_OpenAPIGeneratorCore/Translator/TranslatorProtocol.swift index aab38ba3..d5b8ad17 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/TranslatorProtocol.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/TranslatorProtocol.swift @@ -28,6 +28,6 @@ protocol TranslatorProtocol { func translate( parsedOpenAPI: ParsedOpenAPIRepresentation, config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws -> StructuredSwiftRepresentation } diff --git a/Sources/_OpenAPIGeneratorCore/Translator/TypesTranslator/TypesFileTranslator.swift b/Sources/_OpenAPIGeneratorCore/Translator/TypesTranslator/TypesFileTranslator.swift index 703115b1..68bd32d4 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/TypesTranslator/TypesFileTranslator.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/TypesTranslator/TypesFileTranslator.swift @@ -25,7 +25,7 @@ import OpenAPIKit30 struct TypesFileTranslator: FileTranslator { var config: Config - var diagnostics: DiagnosticCollector + var diagnostics: any DiagnosticCollector var components: OpenAPI.Components func translateFile( diff --git a/Sources/swift-openapi-generator/GenerateOptions+runGenerator.swift b/Sources/swift-openapi-generator/GenerateOptions+runGenerator.swift index 02627486..01314929 100644 --- a/Sources/swift-openapi-generator/GenerateOptions+runGenerator.swift +++ b/Sources/swift-openapi-generator/GenerateOptions+runGenerator.swift @@ -40,7 +40,7 @@ extension _GenerateOptions { additionalImports: resolvedAdditionalImports ) } - let diagnostics: DiagnosticCollector + let diagnostics: any DiagnosticCollector let finalizeDiagnostics: () throws -> Void if let diagnosticsOutputPath { let _diagnostics = _YamlFileDiagnosticsCollector(url: diagnosticsOutputPath) diff --git a/Sources/swift-openapi-generator/runGenerator.swift b/Sources/swift-openapi-generator/runGenerator.swift index 1300f04c..7fc2f56a 100644 --- a/Sources/swift-openapi-generator/runGenerator.swift +++ b/Sources/swift-openapi-generator/runGenerator.swift @@ -31,7 +31,7 @@ extension _Tool { configs: [Config], isPluginInvocation: Bool, outputDirectory: URL, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws { let docData: Data do { @@ -73,7 +73,7 @@ extension _Tool { docData: Data, config: Config, outputFilePath: URL, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) throws { let didChange = try replaceFileContents(at: outputFilePath) { let output = try _OpenAPIGeneratorCore.runGenerator( diff --git a/Tests/OpenAPIGeneratorCoreTests/TestUtilities.swift b/Tests/OpenAPIGeneratorCoreTests/TestUtilities.swift index bc4b5076..a9af2b79 100644 --- a/Tests/OpenAPIGeneratorCoreTests/TestUtilities.swift +++ b/Tests/OpenAPIGeneratorCoreTests/TestUtilities.swift @@ -25,8 +25,8 @@ class Test_Core: XCTestCase { func makeTranslator( components: OpenAPI.Components = .noComponents, - diagnostics: DiagnosticCollector = PrintingDiagnosticCollector() - ) -> FileTranslator { + diagnostics: any DiagnosticCollector = PrintingDiagnosticCollector() + ) -> any FileTranslator { makeTypesTranslator( components: components, diagnostics: diagnostics @@ -35,7 +35,7 @@ class Test_Core: XCTestCase { func makeTypesTranslator( components: OpenAPI.Components = .noComponents, - diagnostics: DiagnosticCollector = PrintingDiagnosticCollector() + diagnostics: any DiagnosticCollector = PrintingDiagnosticCollector() ) -> TypesFileTranslator { TypesFileTranslator( config: .init(mode: .types), diff --git a/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_isSchemaSupported.swift b/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_isSchemaSupported.swift index 10c77b4c..e4bdac4d 100644 --- a/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_isSchemaSupported.swift +++ b/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_isSchemaSupported.swift @@ -17,7 +17,7 @@ import OpenAPIKit30 class Test_isSchemaSupported: XCTestCase { - var translator: FileTranslator { + var translator: any FileTranslator { TypesFileTranslator( config: .init(mode: .types), diagnostics: PrintingDiagnosticCollector(), diff --git a/Tests/OpenAPIGeneratorReferenceTests/ReferenceTest.swift b/Tests/OpenAPIGeneratorReferenceTests/ReferenceTest.swift index 9927dd08..d68c13c0 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/ReferenceTest.swift +++ b/Tests/OpenAPIGeneratorReferenceTests/ReferenceTest.swift @@ -82,7 +82,7 @@ class ReferenceTests: XCTestCase { ) // Run the requested generator invocation - let diagnostics: DiagnosticCollector = strictDiagnosticsCollector + let diagnostics: any DiagnosticCollector = strictDiagnosticsCollector let generatorPipeline = self.makeGeneratorPipeline( config: referenceTest.asConfig, diagnostics: diagnostics @@ -160,13 +160,13 @@ struct StrictDiagnosticsCollector: DiagnosticCollector { extension ReferenceTests { - var strictDiagnosticsCollector: DiagnosticCollector { + var strictDiagnosticsCollector: any DiagnosticCollector { StrictDiagnosticsCollector(test: self) } private func makeGeneratorPipeline( config: Config, - diagnostics: DiagnosticCollector + diagnostics: any DiagnosticCollector ) -> GeneratorPipeline { let parser = YamsParser() diff --git a/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Client.swift b/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Client.swift index eec517b0..d8cd6c51 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Client.swift +++ b/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Client.swift @@ -22,8 +22,8 @@ public struct Client: APIProtocol { public init( serverURL: URL, configuration: Configuration = .init(), - transport: ClientTransport, - middlewares: [ClientMiddleware] = [] + transport: any ClientTransport, + middlewares: [any ClientMiddleware] = [] ) { self.client = .init( serverURL: serverURL, diff --git a/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Server.swift b/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Server.swift index 88155753..65bb9c9c 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Server.swift +++ b/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Server.swift @@ -14,10 +14,10 @@ extension APIProtocol { /// - configuration: A set of configuration values for the server. /// - middlewares: A list of middlewares to call before the handler. public func registerHandlers( - on transport: ServerTransport, + on transport: any ServerTransport, serverURL: URL = .defaultOpenAPIServerURL, configuration: Configuration = .init(), - middlewares: [ServerMiddleware] = [] + middlewares: [any ServerMiddleware] = [] ) throws { let server = UniversalServer( serverURL: serverURL, diff --git a/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Types.swift b/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Types.swift index 27391c43..06c6d291 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Types.swift +++ b/Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Types.swift @@ -177,8 +177,10 @@ public enum Components { /// - Parameters: /// - value1: public init(value1: Components.Schemas.ExtraInfo) { self.value1 = value1 } - public init(from decoder: Decoder) throws { value1 = try .init(from: decoder) } - public func encode(to encoder: Encoder) throws { try value1.encode(to: encoder) } + public init(from decoder: any Decoder) throws { value1 = try .init(from: decoder) } + public func encode(to encoder: any Encoder) throws { + try value1.encode(to: encoder) + } } /// Extra information about the error. /// @@ -268,7 +270,7 @@ public enum Components { /// - foo: public init(foo: Swift.String? = nil) { self.foo = foo } public enum CodingKeys: String, CodingKey { case foo } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) foo = try container.decodeIfPresent(Swift.String.self, forKey: .foo) try decoder.ensureNoAdditionalProperties(knownKeys: ["foo"]) @@ -293,12 +295,12 @@ public enum Components { self.additionalProperties = additionalProperties } public enum CodingKeys: String, CodingKey { case foo } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) foo = try container.decodeIfPresent(Swift.String.self, forKey: .foo) additionalProperties = try decoder.decodeAdditionalProperties(knownKeys: ["foo"]) } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(foo, forKey: .foo) try encoder.encodeAdditionalProperties(additionalProperties) @@ -323,12 +325,12 @@ public enum Components { self.additionalProperties = additionalProperties } public enum CodingKeys: String, CodingKey { case foo } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) foo = try container.decodeIfPresent(Swift.String.self, forKey: .foo) additionalProperties = try decoder.decodeAdditionalProperties(knownKeys: ["foo"]) } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(foo, forKey: .foo) try encoder.encodeAdditionalProperties(additionalProperties) @@ -374,11 +376,11 @@ public enum Components { self.value1 = value1 self.value2 = value2 } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { value1 = try .init(from: decoder) value2 = try .init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { try value1.encode(to: encoder) try value2.encode(to: encoder) } @@ -412,7 +414,7 @@ public enum Components { self.value1 = value1 self.value2 = value2 } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { value1 = try? .init(from: decoder) value2 = try? .init(from: decoder) try DecodingError.verifyAtLeastOneSchemaIsNotNil( @@ -421,7 +423,7 @@ public enum Components { codingPath: decoder.codingPath ) } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { try value1?.encode(to: encoder) try value2?.encode(to: encoder) } @@ -449,7 +451,7 @@ public enum Components { case case4(Components.Schemas.OneOfAny.Case4Payload) /// Parsed a case that was not defined in the OpenAPI document. case undocumented(OpenAPIRuntime.OpenAPIValueContainer) - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { do { self = .case1(try .init(from: decoder)) return @@ -470,7 +472,7 @@ public enum Components { let value = try container.decode(OpenAPIRuntime.OpenAPIValueContainer.self) self = .undocumented(value) } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { switch self { case let .case1(value): try value.encode(to: encoder) case let .case2(value): try value.encode(to: encoder) @@ -540,11 +542,11 @@ public enum Components { self.value1 = value1 self.value2 = value2 } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { value1 = try .init(from: decoder) value2 = try .init(from: decoder) } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { try value1.encode(to: encoder) try value2.encode(to: encoder) } @@ -558,7 +560,7 @@ public enum Components { /// Parsed a case that was not defined in the OpenAPI document. case undocumented(OpenAPIRuntime.OpenAPIObjectContainer) public enum CodingKeys: String, CodingKey { case kind } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let discriminator = try container.decode(String.self, forKey: .kind) switch discriminator { @@ -570,7 +572,7 @@ public enum Components { self = .undocumented(value) } } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { switch self { case let .Walk(value): try value.encode(to: encoder) case let .MessagedExercise(value): try value.encode(to: encoder) @@ -583,7 +585,7 @@ public enum Components { public struct DeprecatedObject: Codable, Equatable, Hashable, Sendable { /// Creates a new `DeprecatedObject`. public init() {} - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { try decoder.ensureNoAdditionalProperties(knownKeys: []) } }