-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathrun-openapi-validation.ps1
More file actions
44 lines (32 loc) · 1.35 KB
/
run-openapi-validation.ps1
File metadata and controls
44 lines (32 loc) · 1.35 KB
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
38
39
40
41
42
43
44
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.Synopsis
Runs OpenAPIParser tool to validate that latest OpenAPI docs don't break parsing in downstream such as DevX API and kiota
.Description
Validates that the OpenAPI docs are parsable by Microsoft.OpenApi.Readers package
.Example
./scripts/run-openapi-validation.ps1 -repoDirectory C:/github/msgraph-metadata -version "v1.0"
.Example
./scripts/run-openapi-validation.ps1 -repoDirectory $GITHUB_WORKSPACE -version "v1.0"
.Parameter repoDirectory
Full path the the root directory of msgraph-metadata checkout.
.Parameter platformName
Name of the platform to be tested.
#>
param(
[Parameter(Mandatory=$true)][string]$repoDirectory,
[Parameter(Mandatory=$true)][string]$version,
[Parameter(Mandatory=$false)][string]$platformName
)
if([string]::IsNullOrWhiteSpace($platformName))
{
$platformName = "openapi"
}
$hidiResults = dotnet tool list microsoft.openapi.hidi -g --format json | ConvertFrom-json
if ($hidiResults.data.Length -lt 1) {
throw "Hidi tool is not installed. Please install it using the command: dotnet tool install --global Microsoft.OpenApi.Hidi"
}
$yaml = Join-Path $repoDirectory "openapi" $version "$platformName.yaml"
Write-Host "Validating $yaml OpenAPI doc..." -ForegroundColor Green
& hidi validate -d $yaml