Skip to content

Comments

[Firebase AI] Add macro support for enums with raw values#15769

Merged
andrewheard merged 8 commits intoai-structured-outputfrom
ah/ai-structured-output-string-enums
Jan 27, 2026
Merged

[Firebase AI] Add macro support for enums with raw values#15769
andrewheard merged 8 commits intoai-structured-outputfrom
ah/ai-structured-output-string-enums

Conversation

@andrewheard
Copy link
Contributor

This extends #15768 to add support for Swift enums that have String raw values, e.g.:

@FirebaseGenerable
enum Priority: String {
  case high
  case medium = "med"
  case low
}

These now use the rawValue for the case name in the generated JSON Schema.

#no-changelog

@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@andrewheard andrewheard marked this pull request as ready for review January 27, 2026 19:31
@andrewheard andrewheard requested a review from paulb777 January 27, 2026 19:31
Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@andrewheard andrewheard merged commit b51c279 into ai-structured-output Jan 27, 2026
82 checks passed
@andrewheard andrewheard deleted the ah/ai-structured-output-string-enums branch January 27, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants