-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixOpenApi.ps1
21 lines (21 loc) · 1.17 KB
/
fixOpenApi.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$openApiFile = "./dist/@typespec/openapi3/openapi.json"
$docsApiFile = "./docs/openapi.json"
# read output from typespec
$json = Get-Content -Raw -Path $openApiFile | ConvertFrom-Json
# update the info object
$info = $json.info
$xLogo = @{
url = "https://pschaeflein.github.io/graph-community-metadata/graph-community-spclient.png"
backgroundColor = "#FFFFFF"
altText = "Graph.Community SDK for Microsoft SharePoint REST API"
}
if (Get-Member -InputObject $info -Name "x-logo" -MemberType Properties) {}
else { Add-Member -InputObject $info -MemberType NoteProperty -Name "x-logo" -Value $xLogo }
# update the discriminator mapping
$mapping = $json.components.schemas.Principal.discriminator.mapping
if (Get-Member -InputObject $mapping -Name "#SP.Group" -MemberType Properties) {}
else { Add-Member -InputObject $mapping -MemberType NoteProperty -Name "#SP.Group" -Value "#/components/schemas/Group" }
if (Get-Member -InputObject $mapping -Name "#SP.User" -MemberType Properties) {}
else { Add-Member -InputObject $mapping -MemberType NoteProperty -Name "#SP.User" -Value "#/components/schemas/User" }
#write docs file
$json | ConvertTo-Json -Depth 100 | Set-Content -Path $docsApiFile