diff --git a/Package.resolved b/Package.resolved index 2becaea..eac61d0 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swift-cloud/Compute", "state" : { - "revision" : "cc89dba27ade5713a2ac167fc752c4f4fe00439a", - "version" : "2.17.0" + "revision" : "542e212eb2f8eed7740205de30cc57e9e0845cfe", + "version" : "2.18.0" } }, { @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mattpolzin/OpenAPIKit.git", "state" : { - "revision" : "ccdcb64667de86f5ea1138000bc9d4f2155a7086", - "version" : "3.0.0-beta.3" + "revision" : "283454875cc6e5b2801d184d65835b92252d1784", + "version" : "3.1.2" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-algorithms", "state" : { - "revision" : "b14b7f4c528c942f121c8b860b9410b2bf57825e", - "version" : "1.0.0" + "revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42", + "version" : "1.2.0" } }, { @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-argument-parser.git", "state" : { - "revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a", - "version" : "1.2.2" + "revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41", + "version" : "1.3.0" } }, { @@ -50,23 +50,23 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto", "state" : { - "revision" : "33a20e650c33f6d72d822d558333f2085effa3dc", - "version" : "2.5.0" + "revision" : "60f13f60c4d093691934dc6cfdf5f508ada1f894", + "version" : "2.6.0" } }, { - "identity" : "swift-format", + "identity" : "swift-http-types", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-format.git", + "location" : "https://github.com/apple/swift-http-types", "state" : { - "revision" : "fbfe1869527923dd9f9b2edac148baccfce0dce7", - "version" : "508.0.1" + "revision" : "12358d55a3824bd5fed310b999ea8cf83a9a1a65", + "version" : "1.0.3" } }, { "identity" : "swift-numerics", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-numerics", + "location" : "https://github.com/apple/swift-numerics.git", "state" : { "revision" : "0a5bc04095a675662cf24757cc0640aa2204253b", "version" : "1.0.2" @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/novr/swift-openapi-compute", "state" : { - "revision" : "5755e63cc4e4fba8c82fd67a42bfa42b8411a28c", - "version" : "0.0.2" + "revision" : "0716fd4d82aa8db68702fe7130f82c1445e9af0b", + "version" : "0.1.2" } }, { @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-openapi-generator", "state" : { - "revision" : "99e31020c8654d72418f9033468ae496e3d0c21e", - "version" : "0.2.1" + "revision" : "b18becec9d33b8a23d6252b47bb6bf1d45304244", + "version" : "1.2.0" } }, { @@ -95,35 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-openapi-runtime", "state" : { - "revision" : "f0589f6e64fd22a6f9760749f71a1a965b68db23", - "version" : "0.2.1" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax.git", - "state" : { - "revision" : "2c49d66d34dfd6f8130afdba889de77504b58ec0", - "version" : "508.0.1" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "836bc4557b74fe6d2660218d56e3ce96aff76574", - "version" : "1.1.1" - } - }, - { - "identity" : "swift-tools-support-core", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-tools-support-core.git", - "state" : { - "revision" : "93784c59434dbca8e8a9e4b700d0d6d94551da6a", - "version" : "0.5.2" + "revision" : "76951d77a0609599d2dc233e7e40808a74767c6a", + "version" : "1.3.2" } }, { @@ -131,8 +104,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/jpsim/Yams.git", "state" : { - "revision" : "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa", - "version" : "4.0.6" + "revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3", + "version" : "5.0.6" } } ], diff --git a/Package.swift b/Package.swift index 1c6ff9f..da0ae99 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.8 +// swift-tools-version: 5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -11,7 +11,7 @@ let package = Package( // .package(url: /* package url */, from: "1.0.0"), .package( url: "https://github.com/swift-cloud/Compute", - from: "2.17.0" + from: "2.18.0" ), // .package( // url: "https://github.com/johnsundell/ink.git", @@ -21,9 +21,9 @@ let package = Package( url: "https://github.com/yumemi-inc/fake-fortune-telling", from: "0.2.5" ), - .package(url: "https://github.com/apple/swift-openapi-generator", from: "0.2.1"), - .package(url: "https://github.com/apple/swift-openapi-runtime", from: "0.2.1"), - .package(url: "https://github.com/novr/swift-openapi-compute", from: "0.0.1"), + .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.2.0"), + .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.3.2"), + .package(url: "https://github.com/novr/swift-openapi-compute", from: "0.1.2"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/EndPoint/OpenAPI/Server.swift b/Sources/EndPoint/OpenAPI/Server.swift index 96163d8..d36792f 100644 --- a/Sources/EndPoint/OpenAPI/Server.swift +++ b/Sources/EndPoint/OpenAPI/Server.swift @@ -1,10 +1,15 @@ // Generated by swift-openapi-generator, do not modify. @_spi(Generated) import OpenAPIRuntime #if os(Linux) -@preconcurrency import Foundation +@preconcurrency import struct Foundation.URL +@preconcurrency import struct Foundation.Data +@preconcurrency import struct Foundation.Date #else -import Foundation +import struct Foundation.URL +import struct Foundation.Data +import struct Foundation.Date #endif +import HTTPTypes extension APIProtocol { /// Registers each operation handler with the provided transport. /// - Parameters: @@ -13,9 +18,9 @@ extension APIProtocol { /// request handlers. /// - configuration: A set of configuration values for the server. /// - middlewares: A list of middlewares to call before the handler. - public func registerHandlers( + internal func registerHandlers( on transport: any ServerTransport, - serverURL: URL = .defaultOpenAPIServerURL, + serverURL: Foundation.URL = .defaultOpenAPIServerURL, configuration: Configuration = .init(), middlewares: [any ServerMiddleware] = [] ) throws { @@ -26,13 +31,19 @@ extension APIProtocol { middlewares: middlewares ) try transport.register( - { try await server.post_hyphen_my_hyphen_fortune(request: $0, metadata: $1) }, + { + try await server.post_hyphen_my_hyphen_fortune( + request: $0, + body: $1, + metadata: $2 + ) + }, method: .post, - path: server.apiPathComponentsWithServerPrefix(["my_fortune"]), - queryItemNames: [] + path: server.apiPathComponentsWithServerPrefix("/my_fortune") ) } } + fileprivate extension UniversalServer where APIHandler: APIProtocol { /// Get fortune for given person /// @@ -40,13 +51,20 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol { /// /// - Remark: HTTP `POST /my_fortune`. /// - Remark: Generated from `#/paths//my_fortune/post(post-my-fortune)`. - func post_hyphen_my_hyphen_fortune(request: Request, metadata: ServerRequestMetadata) async throws -> Response { + func post_hyphen_my_hyphen_fortune( + request: HTTPTypes.HTTPRequest, + body: OpenAPIRuntime.HTTPBody?, + metadata: OpenAPIRuntime.ServerRequestMetadata + ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) { try await handle( request: request, - with: metadata, + requestBody: body, + metadata: metadata, forOperation: Operations.post_hyphen_my_hyphen_fortune.id, - using: { APIHandler.post_hyphen_my_hyphen_fortune($0) }, - deserializer: { request, metadata in + using: { + APIHandler.post_hyphen_my_hyphen_fortune($0) + }, + deserializer: { request, requestBody, metadata in let headers: Operations.post_hyphen_my_hyphen_fortune.Input.Headers = .init( API_hyphen_Version: try converter.getOptionalHeaderFieldAsURI( in: request.headerFields, @@ -57,36 +75,51 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol { ) let contentType = converter.extractContentTypeIfPresent(in: request.headerFields) let body: Operations.post_hyphen_my_hyphen_fortune.Input.Body - if try contentType == nil - || converter.isMatchingContentType(received: contentType, expectedRaw: "application/json") - { - body = try converter.getRequiredRequestBodyAsJSON( + let chosenContentType = try converter.bestContentType( + received: contentType, + options: [ + "application/json" + ] + ) + switch chosenContentType { + case "application/json": + body = try await converter.getRequiredRequestBodyAsJSON( Components.Schemas.MyFortuneRequest.self, - from: request.body, - transforming: { value in .json(value) } + from: requestBody, + transforming: { value in + .json(value) + } ) - } else { - throw converter.makeUnexpectedContentTypeError(contentType: contentType) + default: + preconditionFailure("bestContentType chose an invalid content type.") } - return Operations.post_hyphen_my_hyphen_fortune.Input(headers: headers, body: body) + return Operations.post_hyphen_my_hyphen_fortune.Input( + headers: headers, + body: body + ) }, serializer: { output, request in switch output { case let .ok(value): suppressUnusedWarning(value) - var response = Response(statusCode: 200) + var response = HTTPTypes.HTTPResponse(soar_statusCode: 200) suppressMutabilityWarning(&response) + let body: OpenAPIRuntime.HTTPBody switch value.body { case let .json(value): - try converter.validateAcceptIfPresent("application/json", in: request.headerFields) - response.body = try converter.setResponseBodyAsJSON( + try converter.validateAcceptIfPresent( + "application/json", + in: request.headerFields + ) + body = try converter.setResponseBodyAsJSON( value, headerFields: &response.headerFields, contentType: "application/json; charset=utf-8" ) } - return response - case let .undocumented(statusCode, _): return .init(statusCode: statusCode) + return (response, body) + case let .undocumented(statusCode, _): + return (.init(soar_statusCode: statusCode), nil) } } ) diff --git a/Sources/EndPoint/OpenAPI/Types.swift b/Sources/EndPoint/OpenAPI/Types.swift index c7d4cd6..4535b28 100644 --- a/Sources/EndPoint/OpenAPI/Types.swift +++ b/Sources/EndPoint/OpenAPI/Types.swift @@ -1,69 +1,99 @@ // Generated by swift-openapi-generator, do not modify. @_spi(Generated) import OpenAPIRuntime #if os(Linux) -@preconcurrency import Foundation +@preconcurrency import struct Foundation.URL +@preconcurrency import struct Foundation.Data +@preconcurrency import struct Foundation.Date #else -import Foundation +import struct Foundation.URL +import struct Foundation.Data +import struct Foundation.Date #endif /// A type that performs HTTP operations defined by the OpenAPI document. -public protocol APIProtocol: Sendable { +internal protocol APIProtocol: Sendable { /// Get fortune for given person /// /// This endpoint returns the fortune of a person based on their name, birthday, and blood type, as well as the current date. /// /// - Remark: HTTP `POST /my_fortune`. /// - Remark: Generated from `#/paths//my_fortune/post(post-my-fortune)`. - func post_hyphen_my_hyphen_fortune(_ input: Operations.post_hyphen_my_hyphen_fortune.Input) async throws - -> Operations.post_hyphen_my_hyphen_fortune.Output + func post_hyphen_my_hyphen_fortune(_ input: Operations.post_hyphen_my_hyphen_fortune.Input) async throws -> Operations.post_hyphen_my_hyphen_fortune.Output } + +/// Convenience overloads for operation inputs. +extension APIProtocol { + /// Get fortune for given person + /// + /// This endpoint returns the fortune of a person based on their name, birthday, and blood type, as well as the current date. + /// + /// - Remark: HTTP `POST /my_fortune`. + /// - Remark: Generated from `#/paths//my_fortune/post(post-my-fortune)`. + internal func post_hyphen_my_hyphen_fortune( + headers: Operations.post_hyphen_my_hyphen_fortune.Input.Headers = .init(), + body: Operations.post_hyphen_my_hyphen_fortune.Input.Body + ) async throws -> Operations.post_hyphen_my_hyphen_fortune.Output { + try await post_hyphen_my_hyphen_fortune(Operations.post_hyphen_my_hyphen_fortune.Input( + headers: headers, + body: body + )) + } +} + /// Server URLs defined in the OpenAPI document. -public enum Servers { - public static func server1() throws -> URL { - try URL(validatingOpenAPIServerURL: "https://yumemi-ios-junior-engineer-codecheck.app.swift.cloud") +internal enum Servers { + internal static func server1() throws -> Foundation.URL { + try Foundation.URL( + validatingOpenAPIServerURL: "https://yumemi-ios-junior-engineer-codecheck.app.swift.cloud", + variables: [] + ) } } + /// Types generated from the components section of the OpenAPI document. -public enum Components { +internal enum Components { /// Types generated from the `#/components/schemas` section of the OpenAPI document. - public enum Schemas { + internal enum Schemas { /// - Remark: Generated from `#/components/schemas/MyFortuneRequest`. - public struct MyFortuneRequest: Codable, Hashable, Sendable { + internal struct MyFortuneRequest: Codable, Hashable, Sendable { /// Target's name. /// /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/name`. - public var name: Swift.String + internal var name: Swift.String /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/birthday`. - public struct birthdayPayload: Codable, Hashable, Sendable { + internal struct birthdayPayload: Codable, Hashable, Sendable { /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/birthday/value1`. - public var value1: Components.Schemas.YearMonthDay + internal var value1: Components.Schemas.YearMonthDay /// Target's birthday. /// /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/birthday/value2`. - public var value2: OpenAPIRuntime.OpenAPIValueContainer + internal var value2: OpenAPIRuntime.OpenAPIValueContainer /// Creates a new `birthdayPayload`. /// /// - Parameters: /// - value1: /// - value2: Target's birthday. - public init(value1: Components.Schemas.YearMonthDay, value2: OpenAPIRuntime.OpenAPIValueContainer) { + internal init( + value1: Components.Schemas.YearMonthDay, + value2: OpenAPIRuntime.OpenAPIValueContainer + ) { self.value1 = value1 self.value2 = value2 } - public init(from decoder: any Decoder) throws { + internal init(from decoder: any Decoder) throws { value1 = try .init(from: decoder) value2 = try .init(from: decoder) } - public func encode(to encoder: any Encoder) throws { + internal func encode(to encoder: any Encoder) throws { try value1.encode(to: encoder) try value2.encode(to: encoder) } } /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/birthday`. - public var birthday: Components.Schemas.MyFortuneRequest.birthdayPayload + internal var birthday: Components.Schemas.MyFortuneRequest.birthdayPayload /// Target's blood type. /// /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/blood_type`. - @frozen public enum blood_typePayload: String, Codable, Hashable, Sendable { + @frozen internal enum blood_typePayload: String, Codable, Hashable, Sendable { case a = "a" case b = "b" case ab = "ab" @@ -72,35 +102,38 @@ public enum Components { /// Target's blood type. /// /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/blood_type`. - public var blood_type: Components.Schemas.MyFortuneRequest.blood_typePayload + internal var blood_type: Components.Schemas.MyFortuneRequest.blood_typePayload /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/today`. - public struct todayPayload: Codable, Hashable, Sendable { + internal struct todayPayload: Codable, Hashable, Sendable { /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/today/value1`. - public var value1: Components.Schemas.YearMonthDay + internal var value1: Components.Schemas.YearMonthDay /// Today's date. /// /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/today/value2`. - public var value2: OpenAPIRuntime.OpenAPIValueContainer + internal var value2: OpenAPIRuntime.OpenAPIValueContainer /// Creates a new `todayPayload`. /// /// - Parameters: /// - value1: /// - value2: Today's date. - public init(value1: Components.Schemas.YearMonthDay, value2: OpenAPIRuntime.OpenAPIValueContainer) { + internal init( + value1: Components.Schemas.YearMonthDay, + value2: OpenAPIRuntime.OpenAPIValueContainer + ) { self.value1 = value1 self.value2 = value2 } - public init(from decoder: any Decoder) throws { + internal init(from decoder: any Decoder) throws { value1 = try .init(from: decoder) value2 = try .init(from: decoder) } - public func encode(to encoder: any Encoder) throws { + internal func encode(to encoder: any Encoder) throws { try value1.encode(to: encoder) try value2.encode(to: encoder) } } /// - Remark: Generated from `#/components/schemas/MyFortuneRequest/today`. - public var today: Components.Schemas.MyFortuneRequest.todayPayload + internal var today: Components.Schemas.MyFortuneRequest.todayPayload /// Creates a new `MyFortuneRequest`. /// /// - Parameters: @@ -108,7 +141,7 @@ public enum Components { /// - birthday: /// - blood_type: Target's blood type. /// - today: - public init( + internal init( name: Swift.String, birthday: Components.Schemas.MyFortuneRequest.birthdayPayload, blood_type: Components.Schemas.MyFortuneRequest.blood_typePayload, @@ -119,7 +152,7 @@ public enum Components { self.blood_type = blood_type self.today = today } - public enum CodingKeys: String, CodingKey { + internal enum CodingKeys: String, CodingKey { case name case birthday case blood_type @@ -127,55 +160,58 @@ public enum Components { } } /// - Remark: Generated from `#/components/schemas/MyFortuneResponse`. - public struct MyFortuneResponse: Codable, Hashable, Sendable { + internal struct MyFortuneResponse: Codable, Hashable, Sendable { /// Result prefecture's name. /// /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/name`. - public var name: Swift.String + internal var name: Swift.String /// Result prefecture's brief instruction. /// /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/brief`. - public var brief: Swift.String + internal var brief: Swift.String /// Result prefecture's capital city. /// /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/capital`. - public var capital: Swift.String + internal var capital: Swift.String /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/citizen_day`. - public struct citizen_dayPayload: Codable, Hashable, Sendable { + internal struct citizen_dayPayload: Codable, Hashable, Sendable { /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/citizen_day/value1`. - public var value1: Components.Schemas.MonthDay + internal var value1: Components.Schemas.MonthDay /// Result prefecture's citizen date (if it has one). /// /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/citizen_day/value2`. - public var value2: OpenAPIRuntime.OpenAPIValueContainer + internal var value2: OpenAPIRuntime.OpenAPIValueContainer /// Creates a new `citizen_dayPayload`. /// /// - Parameters: /// - value1: /// - value2: Result prefecture's citizen date (if it has one). - public init(value1: Components.Schemas.MonthDay, value2: OpenAPIRuntime.OpenAPIValueContainer) { + internal init( + value1: Components.Schemas.MonthDay, + value2: OpenAPIRuntime.OpenAPIValueContainer + ) { self.value1 = value1 self.value2 = value2 } - public init(from decoder: any Decoder) throws { + internal init(from decoder: any Decoder) throws { value1 = try .init(from: decoder) value2 = try .init(from: decoder) } - public func encode(to encoder: any Encoder) throws { + internal func encode(to encoder: any Encoder) throws { try value1.encode(to: encoder) try value2.encode(to: encoder) } } /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/citizen_day`. - public var citizen_day: Components.Schemas.MyFortuneResponse.citizen_dayPayload? + internal var citizen_day: Components.Schemas.MyFortuneResponse.citizen_dayPayload? /// Whether result prefecture has a coast line or not. /// /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/has_coast_line`. - public var has_coast_line: Swift.Bool + internal var has_coast_line: Swift.Bool /// Result prefecture's logo's URL. /// /// - Remark: Generated from `#/components/schemas/MyFortuneResponse/logo_url`. - public var logo_url: Swift.String + internal var logo_url: Swift.String /// Creates a new `MyFortuneResponse`. /// /// - Parameters: @@ -185,7 +221,7 @@ public enum Components { /// - citizen_day: /// - has_coast_line: Whether result prefecture has a coast line or not. /// - logo_url: Result prefecture's logo's URL. - public init( + internal init( name: Swift.String, brief: Swift.String, capital: Swift.String, @@ -200,7 +236,7 @@ public enum Components { self.has_coast_line = has_coast_line self.logo_url = logo_url } - public enum CodingKeys: String, CodingKey { + internal enum CodingKeys: String, CodingKey { case name case brief case capital @@ -210,123 +246,126 @@ public enum Components { } } /// - Remark: Generated from `#/components/schemas/YearMonthDay`. - public struct YearMonthDay: Codable, Hashable, Sendable { + internal struct YearMonthDay: Codable, Hashable, Sendable { /// Year number /// /// - Remark: Generated from `#/components/schemas/YearMonthDay/year`. - public var year: Swift.Int + internal var year: Swift.Int /// Month number /// /// - Remark: Generated from `#/components/schemas/YearMonthDay/month`. - public var month: Swift.Int + internal var month: Swift.Int /// Day number /// /// - Remark: Generated from `#/components/schemas/YearMonthDay/day`. - public var day: Swift.Int + internal var day: Swift.Int /// Creates a new `YearMonthDay`. /// /// - Parameters: /// - year: Year number /// - month: Month number /// - day: Day number - public init(year: Swift.Int, month: Swift.Int, day: Swift.Int) { + internal init( + year: Swift.Int, + month: Swift.Int, + day: Swift.Int + ) { self.year = year self.month = month self.day = day } - public enum CodingKeys: String, CodingKey { + internal enum CodingKeys: String, CodingKey { case year case month case day } } /// - Remark: Generated from `#/components/schemas/MonthDay`. - public struct MonthDay: Codable, Hashable, Sendable { + internal struct MonthDay: Codable, Hashable, Sendable { /// Month number /// /// - Remark: Generated from `#/components/schemas/MonthDay/month`. - public var month: Swift.Int + internal var month: Swift.Int /// Day number /// /// - Remark: Generated from `#/components/schemas/MonthDay/day`. - public var day: Swift.Int + internal var day: Swift.Int /// Creates a new `MonthDay`. /// /// - Parameters: /// - month: Month number /// - day: Day number - public init(month: Swift.Int, day: Swift.Int) { + internal init( + month: Swift.Int, + day: Swift.Int + ) { self.month = month self.day = day } - public enum CodingKeys: String, CodingKey { + internal enum CodingKeys: String, CodingKey { case month case day } } } /// Types generated from the `#/components/parameters` section of the OpenAPI document. - public enum Parameters {} + internal enum Parameters {} /// Types generated from the `#/components/requestBodies` section of the OpenAPI document. - public enum RequestBodies {} + internal enum RequestBodies {} /// Types generated from the `#/components/responses` section of the OpenAPI document. - public enum Responses {} + internal enum Responses {} /// Types generated from the `#/components/headers` section of the OpenAPI document. - public enum Headers {} + internal enum Headers {} } + /// API operations, with input and output types, generated from `#/paths` in the OpenAPI document. -public enum Operations { +internal enum Operations { /// Get fortune for given person /// /// This endpoint returns the fortune of a person based on their name, birthday, and blood type, as well as the current date. /// /// - Remark: HTTP `POST /my_fortune`. /// - Remark: Generated from `#/paths//my_fortune/post(post-my-fortune)`. - public enum post_hyphen_my_hyphen_fortune { - public static let id: String = "post-my-fortune" - public struct Input: Sendable, Hashable { + internal enum post_hyphen_my_hyphen_fortune { + internal static let id: Swift.String = "post-my-fortune" + internal struct Input: Sendable, Hashable { /// - Remark: Generated from `#/paths/my_fortune/POST/header`. - public struct Headers: Sendable, Hashable { + internal struct Headers: Sendable, Hashable { /// - Remark: Generated from `#/paths/my_fortune/POST/header/API-Version`. - @frozen public enum API_hyphen_VersionPayload: String, Codable, Hashable, Sendable { case v1 = "v1" } + @frozen internal enum API_hyphen_VersionPayload: String, Codable, Hashable, Sendable { + case v1 = "v1" + } /// API version you'd like to use in your sending request. Currently only `v1` available. If you don't attach this parameter in your header, system will use the latest API version. /// /// - Remark: Generated from `#/paths/my_fortune/POST/header/API-Version`. - public var API_hyphen_Version: - Operations.post_hyphen_my_hyphen_fortune.Input.Headers.API_hyphen_VersionPayload? - public var accept: - [OpenAPIRuntime.AcceptHeaderContentType< - Operations.post_hyphen_my_hyphen_fortune.AcceptableContentType - >] + internal var API_hyphen_Version: Operations.post_hyphen_my_hyphen_fortune.Input.Headers.API_hyphen_VersionPayload? + internal var accept: [OpenAPIRuntime.AcceptHeaderContentType] /// Creates a new `Headers`. /// /// - Parameters: /// - API_hyphen_Version: API version you'd like to use in your sending request. Currently only `v1` available. If you don't attach this parameter in your header, system will use the latest API version. /// - accept: - public init( - API_hyphen_Version: Operations.post_hyphen_my_hyphen_fortune.Input.Headers - .API_hyphen_VersionPayload? = nil, - accept: [OpenAPIRuntime.AcceptHeaderContentType< - Operations.post_hyphen_my_hyphen_fortune.AcceptableContentType - >] = .defaultValues() + internal init( + API_hyphen_Version: Operations.post_hyphen_my_hyphen_fortune.Input.Headers.API_hyphen_VersionPayload? = nil, + accept: [OpenAPIRuntime.AcceptHeaderContentType] = .defaultValues() ) { self.API_hyphen_Version = API_hyphen_Version self.accept = accept } } - public var headers: Operations.post_hyphen_my_hyphen_fortune.Input.Headers + internal var headers: Operations.post_hyphen_my_hyphen_fortune.Input.Headers /// - Remark: Generated from `#/paths/my_fortune/POST/requestBody`. - @frozen public enum Body: Sendable, Hashable { + @frozen internal enum Body: Sendable, Hashable { /// - Remark: Generated from `#/paths/my_fortune/POST/requestBody/content/application\/json`. case json(Components.Schemas.MyFortuneRequest) } - public var body: Operations.post_hyphen_my_hyphen_fortune.Input.Body + internal var body: Operations.post_hyphen_my_hyphen_fortune.Input.Body /// Creates a new `Input`. /// /// - Parameters: /// - headers: /// - body: - public init( + internal init( headers: Operations.post_hyphen_my_hyphen_fortune.Input.Headers = .init(), body: Operations.post_hyphen_my_hyphen_fortune.Input.Body ) { @@ -334,20 +373,34 @@ public enum Operations { self.body = body } } - @frozen public enum Output: Sendable, Hashable { - public struct Ok: Sendable, Hashable { + @frozen internal enum Output: Sendable, Hashable { + internal struct Ok: Sendable, Hashable { /// - Remark: Generated from `#/paths/my_fortune/POST/responses/200/content`. - @frozen public enum Body: Sendable, Hashable { + @frozen internal enum Body: Sendable, Hashable { /// - Remark: Generated from `#/paths/my_fortune/POST/responses/200/content/application\/json`. case json(Components.Schemas.MyFortuneResponse) + /// The associated value of the enum case if `self` is `.json`. + /// + /// - Throws: An error if `self` is not `.json`. + /// - SeeAlso: `.json`. + internal var json: Components.Schemas.MyFortuneResponse { + get throws { + switch self { + case let .json(body): + return body + } + } + } } /// Received HTTP response body - public var body: Operations.post_hyphen_my_hyphen_fortune.Output.Ok.Body + internal var body: Operations.post_hyphen_my_hyphen_fortune.Output.Ok.Body /// Creates a new `Ok`. /// /// - Parameters: /// - body: Received HTTP response body - public init(body: Operations.post_hyphen_my_hyphen_fortune.Output.Ok.Body) { self.body = body } + internal init(body: Operations.post_hyphen_my_hyphen_fortune.Output.Ok.Body) { + self.body = body + } } /// Success /// @@ -355,27 +408,52 @@ public enum Operations { /// /// HTTP response code: `200 ok`. case ok(Operations.post_hyphen_my_hyphen_fortune.Output.Ok) + /// The associated value of the enum case if `self` is `.ok`. + /// + /// - Throws: An error if `self` is not `.ok`. + /// - SeeAlso: `.ok`. + internal var ok: Operations.post_hyphen_my_hyphen_fortune.Output.Ok { + get throws { + switch self { + case let .ok(response): + return response + default: + try throwUnexpectedResponseStatus( + expectedStatus: "ok", + response: self + ) + } + } + } /// Undocumented response. /// /// A response with a code that is not documented in the OpenAPI document. - case undocumented(statusCode: Int, OpenAPIRuntime.UndocumentedPayload) + case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload) } - @frozen public enum AcceptableContentType: AcceptableProtocol { + @frozen internal enum AcceptableContentType: AcceptableProtocol { case json - case other(String) - public init?(rawValue: String) { + case other(Swift.String) + internal init?(rawValue: Swift.String) { switch rawValue.lowercased() { - case "application/json": self = .json - default: self = .other(rawValue) + case "application/json": + self = .json + default: + self = .other(rawValue) } } - public var rawValue: String { + internal var rawValue: Swift.String { switch self { - case let .other(string): return string - case .json: return "application/json" + case let .other(string): + return string + case .json: + return "application/json" } } - public static var allCases: [Self] { [.json] } + internal static var allCases: [Self] { + [ + .json + ] + } } } }