feat(cli): add validation fields to ContainerType in IR#12144
Closed
feat(cli): add validation fields to ContainerType in IR#12144
Conversation
- Add ContainerTypeValidation base-property to ContainerType union - Add ListValidationRules, MapValidationRules, SetValidationRules types - Add validation field to MapType - Fix TS SDK generator to support base-properties in union builders - Update all converters and parsers to pass validation (defaulting to undefined) - Flow validation from IR to FDR converter Co-Authored-By: Sarah Bawabe <sarah@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:
|
…tainerType base property Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
…pshots with validation field Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
… snapshot, include merge changes Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
- ArraySchemaConverter: extract minItems, maxItems, uniqueItems from array schemas - MapSchemaConverter: extract minProperties, maxProperties from map schemas - SchemaConverter: pass parent schema validation to MapSchemaConverter - FDR converter already reads validation from ContainerType (no changes needed) - Updated min-max-values snapshots with actual validation values Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
…napshot Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
…shots) Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@buildwithfern.com>
Co-Authored-By: Sarah Bawabe <sarah@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 #12106
Adds an optional
ContainerTypeValidationbase property to theContainerTypediscriminated union in the IR, with plumbing to flow validation from OpenAPI → IR → FDR. Builds on thebase-propertiesapproach from #12106 and includes a fix to the TS SDK generator to supportbase-propertieson discriminated unions. Validation values (minItems,maxItems,uniqueItemsfor arrays;minProperties,maxPropertiesfor maps) are now extracted from OpenAPI schemas and propagated through the full pipeline.Link to Devin run: https://app.devin.ai/sessions/83c7515ef32b494daec35f9429127e68
Requested by: @sbawabe
Changes Made
IR type definitions (
types.yml)base-properties: validation: optional<ContainerTypeValidation>toContainerTypeunionContainerTypeValidationdiscriminated union withlist,map,setvariantsListValidationRules(minItems, maxItems, uniqueItems),MapValidationRules(minItems, maxItems),SetValidationRules(minItems, maxItems)MapTypedoes not have its ownvalidationfield — map validation is handled exclusively throughContainerTypeValidation.mapto avoid a type conflict whereContainerType.Mapextends bothMapTypeand_BaseTS SDK generator fix (
GeneratedUnionImpl.ts,AbstractParsedSingleUnionType.ts)throwinaddBuilderProperties()that blocked unions with base-propertiesgetBasePropertyAssignmentsForBuilder()to generatepropertyName: undefinedassignments for all base properties in builder factory functionsOpenAPI → IR validation extraction
ArraySchemaConverter: extractsminItems,maxItems,uniqueItemsfrom OpenAPI array schemas and createsContainerTypeValidation.list(...)on the resultingContainerTypeMapSchemaConverter: acceptsminProperties/maxPropertiesfrom the parent schema via new constructor args; createsContainerTypeValidation.map(...)when presentSchemaConverter: passesthis.schema.minProperties/this.schema.maxPropertiestoMapSchemaConverterFDR converter (
convertTypeShape.ts)container.validationand passesminItems/maxItemsto FDR list, map, and set typesCall-site updates (importers, IR generator, type resolver)
OneOfSchemaConverter,CreateTypeReferenceFromFernType,parseInlineType,TypeResolver— these continue to use factory defaults (validation: undefined) since they don't have access to OpenAPI validation constraintsSnapshot updates (~105 files)
"validation": nullon allContainerTypeobjectsmin-max-values-ir.snapandmin-max-values-fdr.snapwith actual validation values (e.g.,minItems: 1, maxItems: 10)Changelog
Updates since last revision
origin/mainmultiple times to resolve conflicts ingenerators/typescript/sdk/versions.yml,packages/cli/cli/versions.yml, andpackages/cli/ete-tests/.../dependencies.test.ts.snapHuman Review Checklist
ContainerType.list(...)/ContainerType.map(...)to setvalidation. This works but is fragile if factory functions ever return frozen objects.MapValidationRulesusesminItems/maxItemsinternally, but OpenAPI usesminProperties/maxProperties. The converter mapsminProperties → minItems, and FDR converter maps backminItems → minProperties. Verify this round-trip is intentional.ContainerTypeValidation.set(...)from OpenAPI (OpenAPI doesn't have native set validation). The FDR converter reads it if present, but nothing populates it."id": "db78b62a"→"id": "6339919d"). This is expected since the new validation field affects hash computation, but worth verifying.Testing
pnpm run checkpasses (lint + typecheck)pnpm --filter @fern-api/ir-generator-tests test:update— all 311 tests passpnpm --filter @fern-api/register test -- --update— snapshots updated with actual validation valueslint,depcheck,compile,biome,test,Validate versions.yml files)test-ete— failing due to CI infrastructure timeout ("Build CLI (dev) has timed out after 5 minutes"), not related to code changes