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

Issue with api pattern #16

Closed
hoangtaiki opened this issue Nov 7, 2019 · 3 comments
Closed

Issue with api pattern #16

hoangtaiki opened this issue Nov 7, 2019 · 3 comments

Comments

@hoangtaiki
Copy link
Contributor

hoangtaiki commented Nov 7, 2019

Server returns incorrect response when I define two GET request with nearly same pattern.

  1. GET doctor_profile
    API path: /doctors/{id}/
  2. GET doctor_feedbacks
    API path: /doctors/{id}/feedbacks

Problem: Call GET doctor_feedbacks but server return response for doctor_profile ( If you change adding order of two request server will works well)

Code to reproduce

let firstResponseString = "Doctor profile"
let secondResponseString = "Doctor feedback"

// Doctor profile
server.get("/doctors/{id}/") { request in
    return .ok(firstResponseString)
}

// Doctor feedbacks
server.get("/doctors/{id}/feedbacks") { request in
    return .ok(secondResponseString)
}

// Test for GET request
let ex1 = expectation(description: "test")
client.request("/doctors/{id}/feedbacks", method: .get)
    .responseString { r in
        XCTAssertEqual(r.value, secondResponseString)
        ex1.fulfill()
}
waitForExpectations()
@OrkhanAlikhanov
Copy link
Member

OrkhanAlikhanov commented Nov 7, 2019

If you swap the order it should work

Edit: ah you've mentioned it. Not sure if this should be fixed or kept. Will investigate

@hoangtaiki
Copy link
Contributor Author

Yes. I read your code and I understand the reason.

@OrkhanAlikhanov
Copy link
Member

Released a fix at v2.2.1

Thank you for reporting, your test case was helpful as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants