fix(openapi3): escape the service title when converting from OpenAPI - #12092
Open
Alexandre Kohler (kwy404) wants to merge 2 commits into
Open
Alexandre Kohler (kwy404) wants to merge 2 commits into
Alexandre Kohler (kwy404) wants to merge 2 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Regression coverage is missing for newline and interpolation-like titles that the fix also addresses.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes OpenAPI-to-TypeSpec conversion by safely encoding service titles.
Changes:
- Uses
stringLiteralfor generated@servicetitles. - Adds regression coverage and a
fixchangelog entry.
| File | Description |
|---|---|
generate-service-info.ts |
Escapes generated service titles. |
service-info.test.ts |
Tests quoted titles. |
.chronus/changes/fix-openapi3-escape-service-title-2026-8-26-20-50-0.md |
Documents the fix. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When converting an OpenAPI document to TypeSpec,
generate-service-info.tswrites the@servicetitle by wrappinginfo.titlein raw double quotes (title: "${name}"). A title that contains a double quote, for exampleThe "Pet" Store, breaks the string: the converter outputs@service(#{ title: "The ", Pet: " Store" }), which loses part of the title and fails to compile withinvalid-argument. Titles with a line break or${also produce invalid TypeSpec today. The@infovalues emitted right below it already go throughstringLiteral.Fix: pass the title through the existing
stringLiteralhelper, which@infoand@serveralready use and which #12050 applies to tag metadata. Titles without special characters produce the same output as before.Test:
service-info.test.tsconverts a document titledThe "Pet" Store, checks that the generated TypeSpec compiles and containstitle: "The \"Pet\" Store". It fails on main with theinvalid-argumentdiagnostic above and passes with the fix. All 409 tests intest/tsp-openapi3pass.