Skip to content

feat(generators): expose underlying OpenFeature client on generated clients#236

Open
kriscoleman wants to merge 2 commits into
open-feature:mainfrom
kriscoleman:feat/expose-underlying-client
Open

feat(generators): expose underlying OpenFeature client on generated clients#236
kriscoleman wants to merge 2 commits into
open-feature:mainfrom
kriscoleman:feat/expose-underlying-client

Conversation

@kriscoleman
Copy link
Copy Markdown
Collaborator

Summary

  • Exposes the underlying OpenFeature SDK client on all generated clients, allowing users to perform ad-hoc flag evaluations beyond what is defined in their manifest
  • Each generator exposes the client in an idiomatic way for its language/framework:
    • Go: Exported Client package-level variable
    • Node.js: readonly client: Client property on GeneratedClient interface
    • Java: getOpenFeatureClient() method on GeneratedClient interface
    • C#: public IFeatureClient Client property on GeneratedClient
    • React: Re-exports useOpenFeatureClient hook from @openfeature/react-sdk
    • Angular: client getter on GeneratedFeatureFlagService returning the underlying FeatureFlagService
    • Python: Already publicly accessible via self.client (no change needed)
    • NestJS: Inherits client property from Node.js GeneratedClient (no change needed)

Test plan

  • All existing golden file tests pass
  • Go, Node.js, and C# integration tests updated to verify client accessibility
  • Verify generated Go code compiles with generated.Client access
  • Verify generated Node.js code works with client.client for ad-hoc evaluations
  • Verify generated Java code compiles with getOpenFeatureClient() method
  • Verify generated C# code compiles with Client property access
  • Verify React re-export of useOpenFeatureClient works in a React app
  • Verify Angular client getter works in an Angular app
  • Verify Python self.client continues to work as expected
  • Verify NestJS inherits client property correctly

Copy link
Copy Markdown
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 updates the code generation templates for Angular, C#, Go, Java, Node.js, and React to expose the underlying OpenFeature client, enabling ad-hoc flag evaluations. Review feedback identifies potential naming collisions in the Go and Node.js generators where the generic name 'client' might conflict with user-defined flags. It is recommended to use more specific identifiers, such as 'OpenFeatureClient' or 'openFeatureClient', to avoid compilation errors and ensure the generated code remains robust regardless of the flag manifest content.

Comment thread internal/generators/golang/golang.tmpl
Comment thread internal/generators/golang/golang.tmpl
Comment thread internal/generators/golang/golang.tmpl
Comment thread test/go-integration/test.go
Comment thread internal/generators/nodejs/nodejs.tmpl
Comment thread internal/generators/nodejs/nodejs.tmpl
Comment thread test/nodejs-integration/test.ts
…lients

Allow users to access the underlying OpenFeature SDK client for ad-hoc
flag evaluations beyond what is defined in the manifest.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
@kriscoleman kriscoleman force-pushed the feat/expose-underlying-client branch from ad09654 to 87b6d22 Compare May 12, 2026 13:34
@kriscoleman kriscoleman requested a review from beeme1mr May 12, 2026 14:07
@kriscoleman
Copy link
Copy Markdown
Collaborator Author

let's drop last commit and keep with client, keep it a reserved word. We might be able to warn people if a flag matches. The real client should win out in a collision.

we discussed making it optional but the conditionals would get a bit messy

…ion warning

Flag keys that transform to a reserved generator symbol (Client in Go,
client in Node.js) are excluded from the generated output and a warning
is emitted at generation time. Documents the reserved symbols per
generator in the generators README.
@kriscoleman kriscoleman force-pushed the feat/expose-underlying-client branch from 87b6d22 to cac1f24 Compare May 12, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant