Repository: firebase/firebase-ios-sdk
File: FirebaseAI/Tests/TestApp/Tests/Integration/GenerativeModelSessionTests.swift (Swift)

Code before:

    @Test(arguments: [InstanceConfig.vertexAI_v1beta_global])
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    func respondGenerable(_ config: InstanceConfig) async throws {
      let model = FirebaseAI.componentInstance(config).generativeModel(
        modelName: ModelNames.gemini2_5_FlashLite,
      )
      let session = GenerativeModelSession(model: model)
      let prompt = "Generate a Ragdoll kitten"

      let response = try await session.respond(to: prompt, generating: CatProfile.self)

      let catProfile = response.content
      #expect(!catProfile.name.isEmpty)
      #expect(catProfile.age >= 1)
      #expect(catProfile.age <= 20)
      #expect(!catProfile.profile.isEmpty)
    }

    @Generable
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    enum Difficulty: String, Codable, CaseIterable {
      case easy
      case medium
      case hard
    }

    @Generable(description: "A recipe for a delicious dish")
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    struct Recipe {
      @Guide(description: "The name of the dish")
      var name: String

      @Guide(description: "The time it takes to prepare the dish in minutes", .range(5 ... 120))
      var preparationTime: Int

      @Guide(description: "Whether the dish is vegetarian")
      var isVegetarian: Bool

      @Guide(description: "The rating of the dish from 1.0 to 5.0", .range(1.0 ... 5.0))
      var rating: Double

      @Guide(description: "A list of ingredients")
      var ingredients: [String]


Review comment (suggestion):
Any reason this needs the `String` rawValue or to conform to `Codable` and `CaseIterable`? If not I'd recommend removing them (only so that Gemini doesn't learn that it needs to add them 😛 ).

```suggestion
    enum Difficulty {
```

Code after:

    @Test(arguments: [InstanceConfig.vertexAI_v1beta_global])
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    func respondGenerable(_ config: InstanceConfig) async throws {
      let model = FirebaseAI.componentInstance(config).generativeModel(
        modelName: ModelNames.gemini2_5_FlashLite,
      )
      let session = GenerativeModelSession(model: model)
      let prompt = "Generate a Ragdoll kitten"

      let response = try await session.respond(to: prompt, generating: CatProfile.self)

      let catProfile = response.content
      #expect(!catProfile.name.isEmpty)
      #expect(catProfile.age >= 1)
      #expect(catProfile.age <= 20)
      #expect(!catProfile.profile.isEmpty)
    }

    @Generable
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    enum Difficulty {
      case easy
      case medium
      case hard
    }

    @Generable
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    enum SuggestedCourse {
      case appetizer
      case main
      case dessert
    }

    @Generable(description: "A recipe for a delicious dish")
    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    struct Recipe {
      @Guide(description: "The name of the dish")
      var name: String

      @Guide(description: "The time it takes to prepare the dish in minutes", .range(5 ... 120))
      var preparationTime: Int