Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Generator] Add support of deepObject style in query params #538

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let package = Package(
// Tests-only: Runtime library linked by generated code, and also
// helps keep the runtime library new enough to work with the generated
// code.
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.5.0"),
.package(url: "https://github.com/apple/swift-http-types", from: "1.0.2"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ extension FileTranslator {
switch location {
case .query:
switch style {
case .form, .deepObject:
case .form:
break
case .deepObject where explode:
break
default:
try diagnostics.emitUnsupported(
Expand Down
4 changes: 2 additions & 2 deletions Tests/PetstoreConsumerTests/Test_Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class Test_Client: XCTestCase {
XCTAssertEqual(operationID, "listPets")
XCTAssertEqual(
request.path,
"/pets?limit=24&habitat=water&feeds=herbivore&feeds=carnivore&since=2023-01-18T10%3A04%3A11Z"
"/pets?limit=24&habitat=water&feeds=herbivore&feeds=carnivore&sort%5Bid%5D=ascending&sort%5Bname%5D=descending&since=2023-01-18T10%3A04%3A11Z"
)
XCTAssertEqual(baseURL.absoluteString, "/api")
XCTAssertEqual(request.method, .get)
Expand All @@ -66,7 +66,7 @@ final class Test_Client: XCTestCase {
}
let response = try await client.listPets(
.init(
query: .init(limit: 24, habitat: .water, feeds: [.herbivore, .carnivore], since: .test),
query: .init(limit: 24, habitat: .water, feeds: [.herbivore, .carnivore], sort: .init(id: "ascending", name: "descending"), since: .test),
headers: .init(My_hyphen_Request_hyphen_UUID: "abcd-1234")
)
)
Expand Down
3 changes: 2 additions & 1 deletion Tests/PetstoreConsumerTests/Test_Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class Test_Server: XCTestCase {
XCTAssertEqual(input.query.habitat, .water)
XCTAssertEqual(input.query.since, .test)
XCTAssertEqual(input.query.feeds, [.carnivore, .herbivore])
XCTAssertEqual(input.query.sort, .init(id: "ascending", name: "descending"))
kstefanou52 marked this conversation as resolved.
Show resolved Hide resolved
XCTAssertEqual(input.headers.My_hyphen_Request_hyphen_UUID, "abcd-1234")
return .ok(
.init(
Expand All @@ -43,7 +44,7 @@ final class Test_Server: XCTestCase {
})
let (response, responseBody) = try await server.listPets(
.init(
soar_path: "/api/pets?limit=24&habitat=water&feeds=carnivore&feeds=herbivore&since=\(Date.testString)",
soar_path: "/api/pets?sort%5Bid%5D=ascending&sort%5Bname%5D=descending",
method: .get,
headerFields: [.init("My-Request-UUID")!: "abcd-1234"]
),
Expand Down