Learn Courses My Dashboard

Decoding Is Not Supported ("DocumentID values can only be decoded with Firestore.Decoder")

I have the following struct:

struct Recipe: Codable {
    @DocumentID var id: String?
    var vegetarian: Bool?
}

And this is how I’m parsing the data from Firestore:

do {
                    let decoder = JSONDecoder()
                    let recipeToDisplay = try decoder.decode(Recipe.self, from: data!)
                    
                    let uuid = UUID().uuidString
                    
                    FirestoreService.createRecipe(
                        documentId:uuid,
                        vegetarian: recipeToDisplay.vegetarian ?? false
                    ) { recipeURL in
                        print("success")
                    }
                }
                catch {
                    print("Error parsing response data: \(error)")
                }

The catch statement is getting called and I’m getting the following error message: decodingIsNotSupported("DocumentID values can only be decoded with Firestore.Decoder").

All the documentation I’ve researched has pointed me towards using JSONDecoder() to parse the data and I can’t find anything on Firestore.Decoder. Is there a different way that I should be parsing the data?