Skip to content

Commit 39ce1b7

Browse files
committed
update create openapi.json and lint openapi doc task
remove swashbuckle-cli because openapi.json created by swashbuckle-cli does not contains OpenAPI servers info. In github task, Waring is also treated as Error on this project. Related to: aliencube#221
1 parent 4c74f01 commit 39ce1b7

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

.github/workflows/azure-dev-build-only.yml

+21-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ permissions:
1616
contents: write
1717
issues: write
1818
pull-requests: write
19-
# checks: write
2019

2120
jobs:
2221
build-test:
@@ -44,11 +43,10 @@ jobs:
4443
dotnet workload update
4544
dotnet workload install aspire
4645
47-
- name: Install SwashBuckle Cli
46+
- name: Install Spectral Cli
4847
shell: bash
4948
run: |
50-
dotnet new tool-manifest
51-
dotnet tool install SwashBuckle.AspNetCore.Cli
49+
curl -L https://raw.github.com/stoplightio/spectral/master/scripts/install.sh | sh
5250
5351
- name: Restore NuGet packages
5452
shell: bash
@@ -61,16 +59,28 @@ jobs:
6159
dotnet build
6260
6361
- name: Create openapi.json
64-
shell: bash
62+
shell: pwsh
6563
run: |
66-
API_VERSION=$(grep -oP 'public const string Version = "\K[^"]+' ./src/AzureOpenAIProxy.ApiApp/Constants.cs)
67-
dotnet swagger tofile --output ./openapi.json ./src/AzureOpenAIProxy.ApiApp/bin/Debug/net8.0/AzureOpenAIProxy.ApiApp.dll $API_VERSION
64+
$fileContent = Get-Content './src/AzureOpenAIProxy.ApiApp/Constants.cs'
65+
$API_VERSION = [regex]::Match($fileContent, 'public const string Version = "([^"]+)"').Groups[1].Value
66+
67+
$PROCESS = Start-Process -FilePath "dotnet" -ArgumentList "run --project src/AzureOpenAIProxy.AppHost" -PassThru
68+
69+
Start-Sleep -Seconds 30
70+
71+
Invoke-WebRequest -Uri "https://localhost:7001/swagger/$API_VERSION/swagger.json" -OutFile "openapi.json"
72+
73+
$PROCESS.Kill()
6874
6975
- name: Lint OpenAPI doc
70-
uses: stoplightio/spectral-action@latest
71-
with:
72-
file_glob: './openapi.json'
73-
repo_token: ${{ secrets.GH_PAT_GRAINED }}
76+
shell: pwsh
77+
run: |
78+
$LINT_RESULT = spectral lint -f json -F warn -D openapi.json
79+
80+
if( $LINT_RESULT.Count -ge 1) {
81+
$LINT_RESULT
82+
exit 1
83+
}
7484
7585
- name: Install playwright
7686
shell: pwsh
@@ -79,7 +89,6 @@ jobs:
7989
$installer = "$($playwright[0].Directory.FullName)/playwright.ps1"
8090
& "$installer" install
8191
82-
8392
- name: Run unit tests
8493
shell: bash
8594
run: |

.github/workflows/azure-dev.yml

+24-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
permissions:
1212
id-token: write
1313
contents: write
14-
# checks: write
1514

1615
jobs:
1716
build-test-deploy:
@@ -57,13 +56,12 @@ jobs:
5756
$appsettings.Azure.KeyVault.VaultUri = "${{ env.AZURE_KEYVAULT_URI }}"
5857
$appsettings.Azure.KeyVault.SecretName = "${{ env.AZURE_KEYVAULT_SECRET_NAME }}"
5958
$appsettings | ConvertTo-Json -Depth 100 | Set-Content -Path "./src/AzureOpenAIProxy.ApiApp/appsettings.json" -Encoding UTF8 -Force
60-
61-
- name: Install SwashBuckle Cli
59+
60+
- name: Install Spectral Cli
6261
shell: bash
6362
run: |
64-
dotnet new tool-manifest
65-
dotnet tool install SwashBuckle.AspNetCore.Cli
66-
63+
curl -L https://raw.github.com/stoplightio/spectral/master/scripts/install.sh | sh
64+
6765
- name: Restore NuGet packages
6866
shell: bash
6967
run: |
@@ -75,17 +73,30 @@ jobs:
7573
dotnet build -c Release
7674
7775
- name: Create openapi.json
78-
shell: bash
76+
shell: pwsh
7977
run: |
80-
API_VERSION=$(grep -oP 'public const string Version = "\K[^"]+' ./src/AzureOpenAIProxy.ApiApp/Constants.cs)
81-
dotnet swagger tofile --output ./openapi.json ./src/AzureOpenAIProxy.ApiApp/bin/Debug/net8.0/AzureOpenAIProxy.ApiApp.dll $API_VERSION
78+
$fileContent = Get-Content './src/AzureOpenAIProxy.ApiApp/Constants.cs'
79+
$API_VERSION = [regex]::Match($fileContent, 'public const string Version = "([^"]+)"').Groups[1].Value
80+
81+
$PROCESS = Start-Process -FilePath "dotnet" -ArgumentList "run --project src/AzureOpenAIProxy.AppHost" -PassThru
82+
83+
Start-Sleep -Seconds 30
84+
85+
Remove-Item -Path "openapi.json" -Force
86+
87+
Invoke-WebRequest -Uri "https://localhost:7001/swagger/$API_VERSION/swagger.json" -OutFile "openapi.json"
88+
89+
$PROCESS.Kill()
8290
8391
- name: Lint OpenAPI doc
84-
uses: stoplightio/spectral-action@latest
85-
with:
86-
file_glob: './openapi.json'
87-
repo_token: ${{ secrets.GH_PAT_GRAINED }}
92+
shell: pwsh
93+
run: |
94+
$LINT_RESULT = spectral lint -f json -F warn -D openapi.json
8895
96+
if( $LINT_RESULT.Count -ge 1) {
97+
$LINT_RESULT
98+
exit 1
99+
}
89100
90101
- name: Test solution
91102

0 commit comments

Comments
 (0)