diff --git a/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift b/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift index e72337ee..4760d624 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/CommonTypes/Constants.swift @@ -296,6 +296,9 @@ enum Constants { /// The form style. static let form = "form" + + /// The deepObject style. + static let deepObject = "deepObject" } } diff --git a/Sources/_OpenAPIGeneratorCore/Translator/Parameters/TypedParameter.swift b/Sources/_OpenAPIGeneratorCore/Translator/Parameters/TypedParameter.swift index d84f9d3d..a210ed91 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/Parameters/TypedParameter.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/Parameters/TypedParameter.swift @@ -139,12 +139,14 @@ extension FileTranslator { let location = parameter.location switch location { case .query: - guard case .form = style else { + switch style { + case .form, .deepObject: + break + default: diagnostics.emitUnsupported( "Query params of style \(style.rawValue), explode: \(explode)", foundIn: foundIn ) - return nil } case .header, .path: guard case .simple = style else { @@ -252,6 +254,7 @@ extension OpenAPI.Parameter.SchemaContext.Style { var runtimeName: String { switch self { case .form: return Constants.Components.Parameters.Style.form + case .deepObject: return Constants.Components.Parameters.Style.deepObject default: preconditionFailure("Unsupported style") } } diff --git a/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift b/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift index 52ad3b82..5d88ff8d 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift +++ b/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift @@ -2404,6 +2404,18 @@ final class SnippetBasedReferenceTests: XCTestCase { type: array items: type: string + - name: sort + in: query + required: true + style: deepObject + explode: true + schema: + type: object + properties: + option1: + type: string + option2: + type: string responses: default: description: Response @@ -2414,18 +2426,36 @@ final class SnippetBasedReferenceTests: XCTestCase { public var single: Swift.String? public var manyExploded: [Swift.String]? public var manyUnexploded: [Swift.String]? + public struct sortPayload: Codable, Hashable, Sendable { + public var option1: Swift.String? + public var option2: Swift.String? + public init( + option1: Swift.String? = nil, + option2: Swift.String? = nil + ) { + self.option1 = option1 + self.option2 = option2 + } + public enum CodingKeys: String, CodingKey { + case option1 + case option2 + } + } + public var sort: Operations.get_sol_foo.Input.Query.sortPayload public init( single: Swift.String? = nil, manyExploded: [Swift.String]? = nil, - manyUnexploded: [Swift.String]? = nil + manyUnexploded: [Swift.String]? = nil, + sort: Operations.get_sol_foo.Input.Query.sortPayload ) { self.single = single self.manyExploded = manyExploded self.manyUnexploded = manyUnexploded + self.sort = sort } } public var query: Operations.get_sol_foo.Input.Query - public init(query: Operations.get_sol_foo.Input.Query = .init()) { + public init(query: Operations.get_sol_foo.Input.Query) { self.query = query } } @@ -2462,6 +2492,13 @@ final class SnippetBasedReferenceTests: XCTestCase { name: "manyUnexploded", value: input.query.manyUnexploded ) + try converter.setQueryItemAsURI( + in: &request, + style: .deepObject, + explode: true, + name: "sort", + value: input.query.sort + ) return (request, nil) } """, @@ -2488,6 +2525,13 @@ final class SnippetBasedReferenceTests: XCTestCase { explode: false, name: "manyUnexploded", as: [Swift.String].self + ), + sort: try converter.getRequiredQueryItemAsURI( + in: request.soar_query, + style: .deepObject, + explode: true, + name: "sort", + as: Operations.get_sol_foo.Input.Query.sortPayload.self ) ) return Operations.get_sol_foo.Input(query: query)