Skip to content

Allow @typespec/openapi3 to receive more than one file-type.#9890

Merged
timotheeguerin merged 6 commits intomainfrom
glecaros/file-types
Mar 4, 2026
Merged

Allow @typespec/openapi3 to receive more than one file-type.#9890
timotheeguerin merged 6 commits intomainfrom
glecaros/file-types

Conversation

@glecaros
Copy link
Copy Markdown
Member

@glecaros glecaros commented Mar 3, 2026

This pull request enhances the OpenAPI emitter to support generating output files in multiple formats (YAML and JSON) simultaneously, rather than just one. It introduces the ability to specify an array of file types and updates the output file naming logic to accommodate this new feature. Comprehensive tests have been added to verify the correct behavior for various scenarios.

Multi-format output support

  • The file-type option in OpenAPI3EmitterOptions can now be a single value or an array, allowing emission of both YAML and JSON files in one run. The schema and documentation were updated accordingly. [1] [2] [3]

  • The output file name logic now uses the {file-type} variable when multiple formats are specified, ensuring distinct filenames for each format. The default value and documentation for output-file were updated to reflect this. [1] [2]

Emitter logic updates

  • The emitter now iterates over all specified file types, generating the appropriate output for each service and version. The logic for resolving output file names and serializing documents was updated to handle multiple formats. [1] [2]

  • The resolved emitter options and related interfaces were updated to use fileTypes: FileType[] instead of a single fileType.

Testing

  • New tests were added to verify multi-format output, custom output file naming, and correct handling for multiple services and versioned services. These tests ensure that both YAML and JSON files are emitted as expected in all scenarios.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/openapi3@9890
npm i https://pkg.pr.new/@typespec/playground@9890

commit: 543a3cb

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 2026

All changed packages have been documented.

  • @typespec/openapi3
  • @typespec/playground
Show changes

@typespec/openapi3 - feature ✏️

file-type can now receive an array to allow emitting both json and yaml output in the same run.

@typespec/playground - feature ✏️

Add support for oneOf option schemas.

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Mar 3, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@microsoft-github-policy-service microsoft-github-policy-service Bot added the meta:website TypeSpec.io updates label Mar 3, 2026
@timotheeguerin timotheeguerin added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit b9560ea Mar 4, 2026
29 checks passed
@timotheeguerin timotheeguerin deleted the glecaros/file-types branch March 4, 2026 14:27
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 meta:website TypeSpec.io updates ui:playground

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants