-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCreateWebApiClientApi3.ps1
29 lines (25 loc) · 1013 Bytes
/
CreateWebApiClientApi3.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
cd $PSScriptRoot
#Make sure CodeGen.json is saved in format ANSI or UTF-8 without BOM, since ASP.NET Core 2.0 Web API will fail to deserialize POST Body that contains BOM.
$path = "$PSScriptRoot\CoreWebApi3\bin\Debug\netcoreapp3.0"
$procArgs = @{
FilePath = "dotnet.exe"
ArgumentList = "$path\CoreWebApi3.dll"
WorkingDirectory = $path
PassThru = $true
}
$process = Start-Process @procArgs
$restArgs = @{
Uri = 'http://localhost:5000/api/codegen'
Method = 'Post'
InFile = "$PSScriptRoot\CoreWebApi\CodeGen.json"
ContentType = 'application/json'
}
Invoke-RestMethod @restArgs
#Step 3: Compile generated TS codes to JS if App is coded in JS.
$procTscArgs = @{
FilePath = "node"
ArgumentList = "`"C:\Program Files (x86)\Microsoft SDKs\TypeScript\3.2\tsc.js`" $PSScriptRoot\axios\src\clientapi\WebApiCoreAxiosClientAuto.ts -d"
PassThru = $true
}
$processTsc = Start-Process @procTscArgs
Stop-Process $process