Chapter 7 - routes.swift - Type Acronym has no member parameter

I was testing the examples of the book. Unfortunately this route gives me the above mentioned error:

router.get("api","acronyms",Acronym.parameter){ req -> Future<Acronym> in
    return try

Here my model, nearly identical as in the book:
import Vapor
import FluentMySQL

final class Acronym: Codable{
var id: Int?
var short: String
var long: String

init(short:String, long:String){
static let idKey: IDKey = \.id

extension Acronym:MySQLModel {}
extension Acronym:Migration {}
extension Acronym:Content{}

Is there another way to get the Model by Id. Is this an typo in the book or an old implementation or I have an error in some part of the code.

You havenโ€™t added the extension to make Acronym conform to Parameter. If you add

extension Acronym: Parameter {}

It should work

Thank you for your fast response. That was it, I have overseen this line in the Book. I was in the opinion that all objects that implements the protocol Model automatically are conform to Parameterizable. Thank you a lot !!!

1 Like