Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: Unable to use {service-name} interpolation for filenames with openapi3-emitter when only one service is defined #6182

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

wanlwanl
Copy link
Member

Fix: #5866

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 27, 2025

All changed packages have been documented.

  • @typespec/openapi3
Show changes

@typespec/openapi3 - breaking ✏️

Using {service-name} in tspconfig.yaml will always interpolate the current service name. {service-name-if-multiple} can be used to get the previous behavior

@wanlwanl wanlwanl enabled auto-merge February 27, 2025 11:47

Choose a reason for hiding this comment

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

PR Overview

This PR fixes the bug where using the {service-name} interpolation for filenames with the openapi3-emitter fails when only one service is defined. The changes split the interpolation into two variables ("service-name" and "service-name-if-multiple") and update the output file patterns, documentation, and tests accordingly.

  • Created a changelog file documenting the fix.
  • Updated emitter configuration and interpolation logic in the source code.
  • Modified tests and documentation to reflect the new interpolation behavior.

Reviewed Changes

File Description
.chronus/changes/wanl-service-name-2025-1-27-19-40-32.md Changelog entry for the bug fix.
packages/openapi3/test/test-host.ts Updated YAML parsing import and introduced new EmitterOptions usage.
packages/openapi3/src/openapi.ts Adjusted output file interpolation with separate keys for service names.
packages/openapi3/test/works-for.ts Extended test helpers to include new emitOpenApi API and interpolation.
website/src/content/docs/docs/emitters/openapi3/reference/emitter.md Revised documentation for the output file interpolation keys.
packages/openapi3/test/emit-openapi.test.ts Added tests to validate expected file naming with single and multiple services.
packages/openapi3/src/lib.ts Updated emitter option schema and documentation to reflect new defaults.

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

packages/openapi3/src/openapi.ts:203

  • Ensure that the change in the default output file template using {service-name-if-multiple} is intentional and clearly documented so that users understand the intended substitution behavior for single versus multiple services.
resolvedOptions["output-file"] ?? `openapi.{service-name-if-multiple}.{version}.${fileType}`;

packages/openapi3/test/emit-openapi.test.ts:109

  • For the test case using the {service-name-if-multiple} pattern with one service, the expected output becomes just 'yaml', which might indicate that no service name is interpolated. Please verify that this behavior is intentional and consistent with the overall design.
expectedOutputFiles: [resolveVirtualPath("yaml")],
auto-merge was automatically disabled February 27, 2025 11:50

Head branch was pushed to by a user without write access

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 27, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link
Member

@timotheeguerin timotheeguerin Feb 28, 2025

Choose a reason for hiding this comment

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

can you verify if the azure spec repo need to change here, I do see quite a lot using {service-name} right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants