[Firebase AI] Add macro support for enums with raw values#15769
[Firebase AI] Add macro support for enums with raw values#15769andrewheard merged 8 commits intoai-structured-outputfrom
Conversation
# Conflicts: # FirebaseAI/Tests/TestApp/Packages/FirebaseAILogicExtended/Sources/FirebaseAILogicMacros/FirebaseGenerableMacro.swift
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
There was a problem hiding this comment.
Code Review
This pull request extends the @FirebaseGenerable macro to support Swift enums with String raw values, which is a great addition. The changes correctly handle the generation of the initializer, JSON schema, and model output for these enums. The accompanying unit and integration tests are thorough and cover the new functionality well. I have a couple of suggestions to improve code maintainability by reducing some code duplication within the macro's implementation.
.../Packages/FirebaseAILogicExtended/Sources/FirebaseAILogicMacros/FirebaseGenerableMacro.swift
Outdated
Show resolved
Hide resolved
.../Packages/FirebaseAILogicExtended/Sources/FirebaseAILogicMacros/FirebaseGenerableMacro.swift
Outdated
Show resolved
Hide resolved
6e4c813 to
1560f89
Compare
There was a problem hiding this comment.
Code Review
This pull request extends the @FirebaseGenerable macro to support Swift enums that have String raw values. The implementation correctly distinguishes between string-backed enums and simple enums, using the appropriate initialization strategy for each. The changes are well-structured and accompanied by comprehensive unit and integration tests, ensuring the new functionality is robust. I have one minor suggestion to simplify a piece of logic in the macro expansion, but overall this is a great addition.
This extends #15768 to add support for Swift enums that have
Stringraw values, e.g.:These now use the
rawValuefor the case name in the generated JSON Schema.#no-changelog