Skip to content

feat(openapi3): Configure namespace qualification in component names - #12505

Draft
Timothee Guerin (timotheeguerin) wants to merge 3 commits into
microsoft:mainfrom
timotheeguerin:feat/openapi3-component-naming
Draft

Timothee Guerin (timotheeguerin) wants to merge 3 commits into
microsoft:mainfrom
timotheeguerin:feat/openapi3-component-naming

Conversation

@timotheeguerin

@timotheeguerin Timothee Guerin (timotheeguerin) commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

OpenAPI component names currently inherit service-relative TypeSpec namespaces, with no emitter option to omit those prefixes or change their separators. @friendlyName requires per-type overrides and also affects other emitters.

options:
  "@typespec/openapi3":
    component-name-strategy: name-only

Models.User_Profile becomes User_Profile. Use { kind: fqn, separator: "_" } for Models_User_Profile, or an empty separator to concatenate namespace segments.

The strategy applies to schemas, named multipart schemas, and reusable parameter keys and references, without changing HTTP names or operation IDs. Default naming remains unchanged for valid inputs. Duplicate component names produce errors; named multipart schema keys now receive the same validation and collision checks under every strategy.

Alphanumeric sanitization is deferred to a follow-up; characters within identifiers and friendly names remain unchanged.

Related to #12479

@microsoft-github-policy-service microsoft-github-policy-service Bot added meta:website TypeSpec.io updates emitter:openapi3 Issues for @typespec/openapi3 emitter labels Nov 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/openapi@12505
npm i https://pkg.pr.new/@typespec/openapi3@12505

commit: c62dec4

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/openapi
  • ✅ @typespec/openapi3
Show changes

@typespec/openapi3 - feature ✏️

Add component-name-strategy to control namespace qualification and segment separators for OpenAPI schema and reusable parameter keys. Existing defaults are unchanged.,> ,> yaml,> options:,> "@typespec/openapi3":,> component-name-strategy: name-only,> ,> ,> Use name-only to omit namespaces, or configure { kind: fqn, separator: "_" } to change segment separators. Characters within identifiers and friendly names remain unchanged. Collisions after namespace changes are errors.

@typespec/openapi - internal ✏️

Share duplicate schema and parameter component key diagnostics while preserving existing parameter error messages.

@typespec/openapi3 - fix ✏️

Validate named multipart schema component keys and report duplicate keys consistently, including with the default naming strategy.

@timotheeguerin Timothee Guerin (timotheeguerin) changed the title feat(openapi3): Support configurable component naming feat(openapi3): Configure namespace qualification in component names Nov 5, 2026
@azure-sdk-automation

azure-sdk-automation Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The distinct-multipart-type collision guard lacks a diagnostic test, leaving silent schema overwrites undetected if the guard is removed.

1 open issue
What changed in this PR

Adds configurable component naming to the OpenAPI 3 emitter, allowing namespace prefixes to be omitted or joined with custom separators while preserving existing defaults.

Changes:

  • Applies component-name-strategy to schemas, named multipart bodies, and reusable parameter keys and references.
  • Adds collision checks and tests for naming behavior, reference consistency, and service isolation.
  • Documents configuration options and their limits; identifier sanitization remains out of scope.
File Description
website/​src/​content/​docs/​docs/​emitters/​openapi3/​reference/​emitter.md Documents the new emitter option.
website/​src/​content/​docs/​docs/​emitters/​openapi3/​openapi.md Explains naming behavior, examples, and collision handling.
packages/​openapi3/​test/​parameters.test.ts Tests reusable parameter naming and collisions.
packages/​openapi3/​test/​multipart.test.ts Tests multipart naming, reuse, and schema collisions.
packages/​openapi3/​test/​get-openapi.test.ts Tests independent naming across services through the object API.
packages/​openapi3/​test/​component.test.ts Covers naming strategies, defaults, and reference preservation.
packages/​openapi3/​src/​schema-emitter.ts Applies configured naming across schema kinds.
packages/​openapi3/​src/​openapi.ts Resolves options and integrates parameter and multipart naming.
packages/​openapi3/​src/​lib.ts Defines the option’s types and validation schema.
packages/​openapi3/​src/​component-naming.ts Centralizes namespace qualification and separator handling.
packages/​openapi3/​README.md Adds option reference documentation.
.chronus/​changes/​feat-openapi3-component-naming-2026-10-4-18-35-26.md Records the feature with a configuration example.

Review effort: Balanced

Comment thread packages/openapi3/src/openapi.ts Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:openapi3 Issues for @typespec/openapi3 emitter lib:openapi meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants