Skip to content

Fix PowerShell script encoding, regex specificity, and version validation#1482

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/sub-pr-1481
Draft

Fix PowerShell script encoding, regex specificity, and version validation#1482
Copilot wants to merge 2 commits into
masterfrom
copilot/sub-pr-1481

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

Addresses code review feedback on the OpenAPI Generator update automation script to fix encoding issues, prevent unintended hash replacements, and improve version format validation.

Changes

  • Encoding fixes: All Set-Content calls now specify -Encoding UTF8 and remove -NoNewline to prevent UTF-16 rewrites on Windows PowerShell 5.1 and preserve trailing newlines

  • Regex specificity: Hash replacements in Resource.Designer.cs now use (?s)(OpenApiGenerator_MD5.*?Looks up a localized string similar to )[0-9a-f]{32}(\.) to scope replacements to the correct resource blocks and avoid overwriting SwaggerCodegenCli/LegacyOpenApiGenerator hashes

  • Version validation: Added format validation (3-part semver), numeric component checks, and warnings for multi-digit minor/patch versions that may break enum naming assumptions

# Before: Silent encoding changes, broad regex, no validation
Set-Content $file $content -NoNewline
$content -replace '(Looks up.*?)[0-9a-f]{32}(\.)', "`${1}$MD5`${2}"

# After: Explicit UTF-8, scoped regex, validated input
Set-Content $file $content -Encoding UTF8
$content -replace '(?s)(OpenApiGenerator_MD5.*?Looks up.*?)[0-9a-f]{32}(\.)', "`${1}$MD5`${2}"
if ($newMinor.Length -gt 2) { Write-Warning "Multi-digit version..." }

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add UTF-8 encoding to all Set-Content calls to prevent encoding issues
- Remove -NoNewline flag to preserve line endings
- Make hash regex replacements specific to OpenApiGenerator resources
- Add version format validation for multi-digit components

Co-authored-by: christianhelle <710400+christianhelle@users.noreply.github.com>
Copilot AI changed the title [WIP] Update OpenAPI Generator to version 7.20.0 Fix PowerShell script encoding, regex specificity, and version validation Feb 16, 2026
Copilot AI requested a review from christianhelle February 16, 2026 13:17
Base automatically changed from openapi-generator-v7.20.0 to master February 16, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants