You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RoutingKit/TrieRouter.swift:215: Precondition failed: It is not possible to have two routes with the same prefix but different parameter names, even if the trailing path components differ (tried to add route with clubID that collides with eventID).
I'm probably doing something stupid here. I've a parent (Club), children (Event) and grandchildren (Table) - to represent a bridge club. Here's the model:
import Fluent
import Vapor
final class Club: Model, Content {
static let schema = "club"
@ID(key: .id)
var id: UUID?
@Field(key: "name")
var name: String
@Children(for: \.$club)
var events: [Event]
init() { }
init(
id: UUID? = nil,
name: String
) {
self.id = id
self.name = name
}
}
final class Event: Model, Content {
static let schema = "event"
@ID(key: .id)
var id: UUID?
@Parent(key: "club_id")
var club: Club
@Field(key: "date")
var date: Date
@Children(for: \.$event)
var tables: [Table]
init() { }
init(
id: UUID? = nil,
clubID: Club.IDValue,
date: Date
) {
self.id = id
self.$club.id = clubID
self.date = date
}
}
final class Table: Model, Content {
static let schema = "table"
@ID(key: .id)
var id: UUID?
@Parent(key: "event_id")
var event: Event
init() { }
init(
id: UUID? = nil,
eventID: Event.IDValue
) {
self.id = id
self.$event.id = eventID
}
}
Heres my routes.swift:
import Fluent
import Vapor
import CrudRouter
func routes(_ app: Application) throws {
app.crud(register: Club.self) { router in
router.crud(children: \.$events) { router in
router.crud(children: \.$tables)
}
}
for route in app.routes.all {
print(route.description)
}
}
I'm expecting the print out of the app.routes.all to generate something like:
PUT /club/:clubID
DELETE /club/:clubID
POST /club
GET /club
GET /club/:clubID
GET /club/:clubID/event
POST /club/:clubID/event
GET /club/:clubID/event/:eventID
DELETE /club/:clubID/event/:eventID
PUT /club/:clubID/event/:eventID
POST /club/:clubID/event/:eventID/table
DELETE /club/:clubID/event/:eventID/table/:tableID
GET /club/:clubID/event/:eventID/table/:tableID
GET /club/:clubID/event/:eventID/table
PUT /club/:clubID/event/:eventID/table/:tableID
But its actually generating:
PUT /club/:clubID
DELETE /club/:clubID
POST /club
GET /club
GET /club/:clubID
GET /club/:clubID/event
POST /club/:clubID/event
GET /club/:clubID/event/:eventID
DELETE /club/:clubID/event/:eventID
PUT /club/:clubID/event/:eventID
POST /club/:clubID/event/:clubID/table
DELETE /club/:clubID/event/:clubID/table/:tableID
GET /club/:clubID/event/:clubID/table/:tableID
GET /club/:clubID/event/:clubID/table
PUT /club/:clubID/event/:clubID/table/:tableID
Where the last five routes use the clubID for the event resource.
The text was updated successfully, but these errors were encountered:
I'm getting the following run-time error:
RoutingKit/TrieRouter.swift:215: Precondition failed: It is not possible to have two routes with the same prefix but different parameter names, even if the trailing path components differ (tried to add route with clubID that collides with eventID).
I'm probably doing something stupid here. I've a parent (Club), children (Event) and grandchildren (Table) - to represent a bridge club. Here's the model:
Heres my routes.swift:
I'm expecting the print out of the app.routes.all to generate something like:
PUT /club/:clubID
DELETE /club/:clubID
POST /club
GET /club
GET /club/:clubID
GET /club/:clubID/event
POST /club/:clubID/event
GET /club/:clubID/event/:eventID
DELETE /club/:clubID/event/:eventID
PUT /club/:clubID/event/:eventID
POST /club/:clubID/event/:eventID/table
DELETE /club/:clubID/event/:eventID/table/:tableID
GET /club/:clubID/event/:eventID/table/:tableID
GET /club/:clubID/event/:eventID/table
PUT /club/:clubID/event/:eventID/table/:tableID
But its actually generating:
PUT /club/:clubID
DELETE /club/:clubID
POST /club
GET /club
GET /club/:clubID
GET /club/:clubID/event
POST /club/:clubID/event
GET /club/:clubID/event/:eventID
DELETE /club/:clubID/event/:eventID
PUT /club/:clubID/event/:eventID
POST /club/:clubID/event/:clubID/table
DELETE /club/:clubID/event/:clubID/table/:tableID
GET /club/:clubID/event/:clubID/table/:tableID
GET /club/:clubID/event/:clubID/table
PUT /club/:clubID/event/:clubID/table/:tableID
Where the last five routes use the clubID for the event resource.
The text was updated successfully, but these errors were encountered: