pointfreeco / swift-url-routing

A bidirectional router with more type safety and less fuss.
https://swiftpackageindex.com/pointfreeco/swift-url-routing/main/documentation/urlrouting
MIT License
352 stars 30 forks source link

Nested url for POST AND PUT not working #42

Closed saroar closed 2 years ago

saroar commented 2 years ago

hi I feel it bug so deice to share it as I also create new Discussions

here what I am trying

WORKING FINE

[ INFO ] GET v1/conversations/5fabcd48f4271d1963025d4f/messages/60fad9bdb14a1dc66e77d72a [ INFO ] GET /v1/conversations/5fabcd48f4271d1963025d4f/messages [ INFO ] DELETE /v1/conversations/5fabcd48f4271d1963025d4f/messages

POST url not working

[ INFO ] POST /v1/conversations/5fabcd48f4271d1963025d4f/messages [ INFO ] PUT /v1/conversations/5fabcd48f4271d1963025d4f/messages [ INFO ] error: multiple failures occurred

error: unexpected input
 --> input:1:5-17
1 | /v1/conversations/5fabcd48f4271d1963025d4f/messages
  |     ^^^^^^^^^^^^^ expected "events"
  |     ^^^^^^^^^^^^^ expected "categories"

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "POST"
  | ^ expected "HEAD"
  | ^ expected "GET"
  | ^ expected "HEAD"
  | ^ expected "GET"

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "DELETE"
  | ^ expected "POST"
  | ^ expected "HEAD"
  | ^ expected "GET"

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "HEAD"
  | ^ expected "GET"

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "DELETE"

error: RoutingError()

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "HEAD"
  | ^ expected "GET"

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "DELETE"
  | ^ expected "POST"
  | ^ expected "HEAD"
  | ^ expected "GET"

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "HEAD"
  | ^ expected "GET"

error: RoutingError()

error: unexpected input
 --> input:1:1
1 | PUT
  | ^ expected "DELETE"

error: RoutingError()

error: unexpected input
 --> input:1:5-17
1 | /v1/conversations/5fabcd48f4271d1963025d4f/messages
  |     ^^^^^^^^^^^^^ expected "messages" [request-id: 19C4FE7F-5C86-4BC0-B6F5-051858D81B7E]
saroar commented 2 years ago

I have run test url create is passed

   func testBaseURL() throws {
        var user = UserOutput.withNumber
        user.id = ObjectId("5fabb1ebaa5f5774ccfe48c3")
        user.phoneNumber = "+79218821217"

        let input = MessageItem(
            id: ObjectId("60fad9bdb14a1dc66e77d72a"),
            conversationId: ObjectId("5fabcd48f4271d1963025d4f")!,
            messageBody: "I will ping you soon 🔜 101",
            messageType: .text,
            isRead: true,
            isDelivered: true,
            sender: user
        )

      XCTAssertEqual(
        "http://10.0.1.2:6060/v1/conversations/5fabcd48f4271d1963025d4f/messages",
        URLRequest(
          data:
            try siteRouter
            .baseURL("http://10.0.1.2:6060")
            .print(
                .conversationEngine(
                    .conversations(
                        .conversation(
                            id: "5fabcd48f4271d1963025d4f",
                            route: .messages(
                                .update(route: .update(input: input))
                            )
                        )
                    )
                )
            )
        )?.url?.absoluteString
      )
    }

project path can be found here https://github.com/pointfreeco/swift-url-routing/discussions/41