Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- ASP.NET Core Generate Swagger Json File Helper
- .DESCRIPTION
- ASP.NET Core Webを起動してSwagger Jsonファイルをダウンロードして保存します
- #>
- # Swagger Json ファイルのパス
- $SWAGGER_JSON_PATH = '/swagger/v1/swagger.json'
- # Swagger Json 保存先
- $SWAGGER_JSON_OUTPATH = '../swagger.json'
- # launchSettings.jsonから$applicationUrlを取得
- $projName = [System.IO.Path]::GetFileNameWithoutExtension((Get-ChildItem *.*proj -Name | Select-Object -First 1))
- $launchSettings = Get-Content 'Properties/launchSettings.json' -Encoding UTF8 | ConvertFrom-Json
- $applicationUrl = New-Object System.Uri(@($launchSettings.profiles.psobject.properties | Where { $_.Name -eq $projName })[0].Value.applicationUrl)
- # ASP.NET Core を起動
- Split-Path -Parent $MyInvocation.MyCommand.Path | Set-Location
- $webProcess = Start-Process 'dotnet' 'run' -PassThru
- Start-Sleep -Seconds 10
- # Swagger Json ファイルダウンロード
- $jsonUrl = New-Object System.Uri($applicationUrl, $SWAGGER_JSON_PATH)
- Invoke-WebRequest -Uri $jsonUrl -OutFile $SWAGGER_JSON_OUTPATH
- # ASP.NET Core 停止
- TaskKill /PID $webProcess.Id /T /F
Add Comment
Please, Sign In to add comment