Repository navigation
fix(openapi3): Validate named multipart schema components - #12545
Timothee Guerin (timotheeguerin) wants to merge 3 commits into
Conversation
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the multipart component-key validation fix.
No open issues 🎉
What changed in this PR
This PR fixes component-key validation for named multipart schemas in the OpenAPI 3 emitter, without adding naming options.
Changes:
- Sanitizes invalid multipart component keys before generating matching references.
- Reports collisions with other multipart or regular schemas while allowing reuse of the same multipart model.
- Adds regression tests and a fix changelog entry.
| File | Description |
|---|---|
packages/openapi3/test/multipart.test.ts |
Tests key sanitization, collisions, and repeated model references. |
packages/openapi3/src/openapi.ts |
Validates multipart keys and tracks names to detect schema collisions. |
.chronus/changes/feat-openapi3-component-naming-2026-10-6-11-13-33.md |
Documents the multipart component-key validation fix. |
Review effort: Balanced
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
Review effort: Lite
| let name = | ||
| "name" in body.type && body.type.name !== "" | ||
| ? getOpenAPITypeName(program, body.type, typeNameOptions) | ||
| : undefined; | ||
| if (name !== undefined) { | ||
| name = ensureValidComponentFixedFieldKey(program, body.type, name); | ||
| if (name) { | ||
| const existing = multipartSchemaTypes.get(name); | ||
| if (existing && existing !== body.type) { | ||
| checkDuplicateTypeName(program, body.type, name, root.components!.schemas!); | ||
| } | ||
| multipartSchemaTypes.set(name, body.type); | ||
| } | ||
| } | ||
| if (name) { | ||
| root.components!.schemas![name] = schema; | ||
| } |
| for (const declaration of declarations) { | ||
| const multipartType = multipartSchemaTypes.get(declaration.name); | ||
| if (multipartType) { | ||
| checkDuplicateTypeName(program, multipartType, declaration.name, schemas); | ||
| } |

Named multipart bodies bypass component-key validation and can silently overwrite each other or a regular schema with the same component name.
A multipart model named
Upload/Formnow emitsUpload_Formand a matching$ref, with the existing invalid-key warning. Duplicate component keys produce an error; reusing the same multipart model remains valid.Extracted from #12505 so these existing-behavior fixes can merge before configurable component naming. This PR adds no naming options.