/
reachman
/
Public-api
Обзор
Документация
Войти
/
reachman
/
Public-api
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
scripts/check-openapi.ps1
59 строк
2 KB
Юрий Обухов
Add OpenAPI contract validation
06 июл 2026, 21:32
06 июл 2026, 21:32
1a1ae6f
Код
Авторство
О чём код?
param( [string] $BackendPath ) $ErrorActionPreference = "Stop" function Invoke-CheckedCommand { param( [Parameter(Mandatory = $true)] [string] $FilePath, [Parameter(Mandatory = $true)] [string[]] $Arguments ) Write-Host "> $FilePath $($Arguments -join ' ')" & $FilePath @Arguments if ($LASTEXITCODE -ne 0) { throw "Command failed with exit code ${LASTEXITCODE}: $FilePath $($Arguments -join ' ')" } } $repositoryRoot = Resolve-Path (Join-Path $PSScriptRoot "..") $contractRoot = Join-Path $repositoryRoot "openapi" Push-Location $repositoryRoot try { Invoke-CheckedCommand "dotnet" @("tool", "restore", "--tool-manifest", "dotnet-tools.json") Invoke-CheckedCommand "dotnet" @("tool", "run", "nswag", "run", "nswag.validate.json") if (-not [string]::IsNullOrWhiteSpace($BackendPath)) { $resolvedBackendPath = Resolve-Path $BackendPath Push-Location $resolvedBackendPath try { Invoke-CheckedCommand "dotnet" @("tool", "restore", "--tool-manifest", "dotnet-tools.json") Invoke-CheckedCommand "dotnet" @( "tool", "run", "nswag", "run", "nswag.json", "/variables:OpenApiContractsRoot=$contractRoot" ) Invoke-CheckedCommand "git" @( "diff", "--exit-code", "--", "src/GrenadaIS.Api/Generated/GrenadaApiControllers.g.cs" ) } finally { Pop-Location } } } finally { Pop-Location }