Skip to content

feat(openapi): add enable-numeric-enums setting for OpenAPI specs#11995

Open
fern-support wants to merge 4 commits intomainfrom
devin/1769802225-enable-numeric-enums
Open

feat(openapi): add enable-numeric-enums setting for OpenAPI specs#11995
fern-support wants to merge 4 commits intomainfrom
devin/1769802225-enable-numeric-enums

Conversation

@fern-support
Copy link
Collaborator

@fern-support fern-support commented Jan 30, 2026

Description

Refs: Investigation into supporting integer enums in OpenAPI specs

Link to Devin run: https://app.devin.ai/sessions/1bbc2cf770f246aaa6c2c41de329ed13
Requested by: @fern-support

Adds a new enable-numeric-enums setting behind a feature flag to explore the downstream impact of supporting integer/number enums in OpenAPI specs. Currently, Fern's OpenAPI parser silently converts integer enums (e.g., type: integer, enum: [8000, 16000, 24000]) to plain integer types, losing the enum constraint information.

Changes Made

  • Added enable-numeric-enums option to OpenAPISettingsSchema in the Fern definition
  • Updated ParseOpenAPIOptions interface and defaults in the parser
  • Added numeric enum handling logic in convertSchemas.ts that converts integer/number enum values to string representations (e.g., 8000"8000")
  • Wired the option through BaseOpenAPIWorkspace, OSSWorkspace, and OpenAPIWorkspace
  • Updated configuration loader to parse the new setting from YAML
  • Added enableNumericEnums to FIELD_MAPPINGS in getAPIDefinitionSettings.ts to properly wire settings from generators.yml
  • Added changelog entry for version 3.56.0

Updates Since Last Revision

  • Added fixture tests demonstrating the feature with two config variants:
    • numeric-enums-enabled: Shows integer enums converted to string enums (e.g., SampleRate becomes enum with values "8000", "16000", "24000")
    • numeric-enums-disabled: Shows integer enums treated as plain int types
  • Fixed missing field mapping in getAPIDefinitionSettings.ts that was preventing the setting from being passed through

Important Limitations

The current implementation converts numeric enum values to strings because the Fern IR only supports string enum values. This means:

  • Generated SDKs will have string enums like "8000" instead of numeric literals 8000
  • Full support would require IR changes to add a numeric enum type
  • Generator updates would be needed to emit proper numeric literals

Testing

To test locally from a separate repo:

# Build seed first
pnpm seed:build

# Run against a customer's fern folder
pnpm seed run --generator ts-sdk --path /path/to/fern/folder
  • pnpm run check passes (lint and type checking)
  • Fixture tests added (numeric-enums-enabled and numeric-enums-disabled)
  • Snapshots verify correct behavior for both enabled and disabled states

Human Review Checklist

  • Verify the enum conversion logic in convertSchemas.ts handles edge cases (null values, defaults, single-value enums)
  • Confirm the generated enum names are acceptable (e.g., "EightThousand" for value 8000 - visible in snapshots)
  • Assess whether the string-based approach is acceptable for the use case or if IR changes are required

Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
@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 feat: add enable-numeric-enums setting for OpenAPI specs feat(openapi): add enable-numeric-enums setting for OpenAPI specs Jan 30, 2026
devin-ai-integration bot and others added 3 commits January 30, 2026 20:01
Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
Add two test fixtures to demonstrate the enable-numeric-enums feature:
- numeric-enums-enabled: Shows integer enums converted to string enums
- numeric-enums-disabled: Shows integer enums treated as plain integers

Also add enableNumericEnums to FIELD_MAPPINGS in getAPIDefinitionSettings.ts
to properly wire the setting from generators.yml to the parser.

Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
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.

1 participant