fix(cli): preserve variant-inherited keys in discriminated union example validation#16157
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Closes FER-10932
Summary
fern checkwas emitting spuriousExample is missing required property "<key>"errors for discriminated-union examples when the union had inferredbase-propertiesAND the variants also inherited those same property keys via theirextendschain.base-properties— but the variant still required those keys via its ownextends, so the variant validator then flagged them as missing.extends) when building the example handed to variant-level validation. Keys owned exclusively by the union are still filtered as before.Example
Surfaced on an Auth0 spec where
ConnectionResponseContentis a 55-variant discriminated union withinfer-discriminated-union-base-properties: true. The inferredbase-properties(id,name,display_name, …) overlap with what each variant inherits viaextends: ConnectionResponseCommon→CreateConnectionCommon→ConnectionCommon. Before the fix,fern checkemitted 9 false errors; after, it's clean:The minimal repro is captured as a fixture in this PR. Variants
Dog/Catbothextends: AnimalBase(which declaresid,name), and the unionAnimaldeclares the same two keys underbase-properties:Pre-fix, the example above produced false
Example is missing required property "id"/"name"violations; post-fix it validates cleanly. A deliberately-broken example (missingid) still surfaces the violation, confirming the validator isn't going lax.Test plan
valid-example-type/fixtures/union-with-extends-overlap/+ test case asserts only the deliberately-invalid example produces a violation@fern-api/fern-definition-validatortests still passfern checkagainst the original auth0 reproduction goes from 9 errors to 0🤖 Generated with Claude Code