forked from LacunaSoftware/SignerJavaClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate-ApiCode.ps1
37 lines (22 loc) · 905 Bytes
/
Generate-ApiCode.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
30
31
32
33
34
35
36
37
param([string]$ToolPath)
$ErrorActionPreference = "Stop"
try {
if ([String]::IsNullOrEmpty($ToolPath)) {
Write-Host ("Syntax: {0} [-ToolPath] <swagger-codegen path>" -f $MyInvocation.MyCommand.Name)
exit 1
}
Write-Host ">>> Initializing ..."
$toolJarPath = Resolve-Path ($ToolPath + "\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar")
$tempDir = ("{0}\{1}" -f $env:TEMP, [Guid]::NewGuid())
Write-Host ">>> Generating code ..."
&java -jar $toolJarPath generate -i https://signer-lac.azurewebsites.net/swagger/api/swagger.json -l java -c swagger-codegen-config.json -o $tempDir
Write-Host ">>> Copying classes to project ..."
Copy-Item ("{0}\*" -f $tempDir) . -Recurse -Force
Write-Host ">>> Doing some housekeeping ..."
Remove-Item $tempDir -Recurse -Force
python .\swagger-codegen.py
Write-Host ">>> Done."
} catch {
Write-Error ("Error: " + $_)
exit 2
}