feat(openapi): add enable-numeric-enums setting for OpenAPI specs#11995
Open
fern-support wants to merge 4 commits intomainfrom
Open
feat(openapi): add enable-numeric-enums setting for OpenAPI specs#11995fern-support wants to merge 4 commits intomainfrom
fern-support wants to merge 4 commits intomainfrom
Conversation
Co-Authored-By: blank@buildwithfern.com <blank@buildwithfern.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-enumssetting 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
enable-numeric-enumsoption toOpenAPISettingsSchemain the Fern definitionParseOpenAPIOptionsinterface and defaults in the parserconvertSchemas.tsthat converts integer/number enum values to string representations (e.g.,8000→"8000")BaseOpenAPIWorkspace,OSSWorkspace, andOpenAPIWorkspaceenableNumericEnumstoFIELD_MAPPINGSingetAPIDefinitionSettings.tsto properly wire settings from generators.ymlUpdates Since Last Revision
numeric-enums-enabled: Shows integer enums converted to string enums (e.g.,SampleRatebecomes enum with values"8000","16000","24000")numeric-enums-disabled: Shows integer enums treated as plaininttypesgetAPIDefinitionSettings.tsthat was preventing the setting from being passed throughImportant Limitations
The current implementation converts numeric enum values to strings because the Fern IR only supports string enum values. This means:
"8000"instead of numeric literals8000Testing
To test locally from a separate repo:
pnpm run checkpasses (lint and type checking)numeric-enums-enabledandnumeric-enums-disabled)Human Review Checklist
convertSchemas.tshandles edge cases (null values, defaults, single-value enums)"EightThousand"for value8000- visible in snapshots)