Skip to content

Conversation

@thesandlord
Copy link
Contributor

@thesandlord thesandlord commented Jan 5, 2026

Description

Refs: Slack thread from Sandeep Dinesh

Link to Devin run: https://app.devin.ai/sessions/eddb3e06655c47ec89a88b5bced08a4e
Requested by: Sandeep Dinesh (@thesandlord)

Fixes handling of OpenAPI schemas that have discriminator.mapping but no explicit oneOf/anyOf. This pattern is used by some APIs (like Dropbox Sign) where a base schema defines a discriminator with mapping to variant schemas, but doesn't list them in a oneOf.

Previously, such schemas were incorrectly converted as plain objects. Now they are properly converted as discriminated unions.

Changes Made

  • Added tryConvertDiscriminatorMappingSchema() method in SchemaConverter.ts (for --from-openapi direct path) that:
    • Detects schemas with discriminator.mapping but no oneOf/anyOf
    • Synthesizes a oneOf from the mapping values
    • Delegates to OneOfSchemaConverter for proper discriminated union conversion
  • Added handling in convertSchemas.ts (for OpenAPI→Fern conversion path) that:
    • Detects the same discriminator.mapping pattern
    • Calls convertDiscriminatedOneOf which uses the mapping internally to build union subtypes
  • Added test fixture discriminator-base-class demonstrating this pattern
  • Bumped CLI version to 3.33.0

Updates since last revision

  • Rebased on latest main
  • Removed smoke test API changes (per user request)
  • Added version bump to 3.33.0 in versions.yml

Testing

  • Unit tests added/updated (new test fixture with snapshots)
  • Manual testing completed (lint checks pass)
  • Verified fix works on Dropbox Sign docs preview (discriminated union now renders with "Hide 10 variants" UI)

Human Review Checklist

  • Verify the fix handles edge cases where discriminator.mapping exists but the schema should remain an object
  • Confirm both code paths (SchemaConverter.ts and convertSchemas.ts) produce consistent results
  • Note: The openapi-ir-parser path calls convertDiscriminatedOneOf directly without synthesizing oneOf first - verify this is correct since convertDiscriminatedOneOf uses discriminator.mapping internally (line 51-74 of convertDiscriminatedOneOf.ts)

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot changed the title fix: handle discriminator mapping without oneOf in OpenAPI->IR direct path fix(openapi): handle discriminator mapping without oneOf in OpenAPI->IR direct path Jan 5, 2026
@devin-ai-integration devin-ai-integration bot changed the title fix(openapi): handle discriminator mapping without oneOf in OpenAPI->IR direct path fix(openapi): handle discriminator mapping without oneOf in both conversion paths Jan 5, 2026
devin-ai-integration bot and others added 2 commits January 5, 2026 23:45
… path

Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
…ersion path

Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1767644144-fix-discriminator-mapping-union branch 2 times, most recently from 958cbd9 to b481e03 Compare January 5, 2026 23:56
@thesandlord
Copy link
Contributor Author

image

Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
@thesandlord thesandlord enabled auto-merge (squash) January 6, 2026 00:29
@thesandlord thesandlord merged commit 9d35c09 into main Jan 6, 2026
102 checks passed
@thesandlord thesandlord deleted the devin/1767644144-fix-discriminator-mapping-union branch January 6, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants