fix(cli): convert invalid Swagger 2.0 specs in lenient mode - #17514
fix(cli): convert invalid Swagger 2.0 specs in lenient mode#17514devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 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: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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 |
Description
Linear ticket: Refs
convertOpenAPIV2ToV3calls swagger2openapi with no options, so any Swagger 2.0 document that trips a patchable error fails to convert.OpenAPILoadercatches that failure atdebuglevel and returnsundefined, so the spec is silently dropped from the docs/SDK build with no user-visible reason.Real case: Autodesk's ACC Admin Swagger files declare
type: ['null', string]on several properties (invalid in both Swagger 2.0 and OpenAPI 3.0). swagger2openapi throws(Patchable) schema type must not be an array, and all three specs vanish. Passingpatch: trueconverts them cleanly, mapping the type array tonullable: true.Rather than making lenient conversion the default, this keeps strict conversion as the primary path and falls back once:
The thrown error still reports the strict message, which is the informative one.
convertObjdeep-clones its input (cclone), so the retry sees the original document, not a partially converted one.Changes Made
convertOpenAPIV2ToV3retries once with{ patch: true }when strict conversion fails, and warns when the fallback succeeds so the leniency isn't invisible.options?: { context?: TaskContext }parameter for that warning, passed from theOpenAPILoadercall site. The parameter is optional, so theoss-validatorcall sites (which have noTaskContext) are unchanged.Testing
convertOpenAPIV2ToV3.test.ts: valid v2 document converts to 3.0.x; a document withtype: ['null', 'string']converts via the fallback totype: "string"/nullable: trueand emits the warning; an unconvertible document still throwsCliError.pnpm --filter @fern-api/lazy-fern-workspace test(100 tests, 12 files, all passing, including the existingloadOpenAPIsuite),pnpm turbo run compile --filter='@fern-api/lazy-fern-workspace...'(29 tasks successful), andbiome checkclean on the touched files.No seed fixture was added:
test-definitions/has no Swagger 2.0 (swagger: "2.0") fixture precedent to follow, and this change is in the workspace loader rather than inapi-importers/openapi.Link to Devin session: https://app.devin.ai/sessions/607a35683f974cda9bb45321b9372852