From 58468a5723a55c975f6f31e8c77d8c34b8d54fc0 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:17:37 +0800 Subject: [PATCH 1/8] add workflow for powershell client --- .github/workflows/samples-powershell.yaml | 32 +++++++++++++++++++ .../powershell/.openapi-generator-ignore | 3 ++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/samples-powershell.yaml diff --git a/.github/workflows/samples-powershell.yaml b/.github/workflows/samples-powershell.yaml new file mode 100644 index 000000000000..8dd2554ea164 --- /dev/null +++ b/.github/workflows/samples-powershell.yaml @@ -0,0 +1,32 @@ +name: Samples PowerShell + +on: + push: + paths: + - samples/client/petstore/powershell/** + pull_request: + paths: + - samples/client/petstore/powershell/** +jobs: + build: + runs-on: ubuntu-latest + name: Test Powershell Clients + strategy: + matrix: + sample: + - samples/client/petstore/powershell/ + services: + petstore-api: + image: swaggerapi/petstore + ports: + - 80:8080 + env: + SWAGGER_HOST: http://petstore.swagger.io + SWAGGER_BASE_PATH: /v2 + steps: + - uses: actions/checkout@v5 + - name: Run tests + working-directory: ${{ matrix.sample }} + shell: pwsh + run: | + CIRunTest.ps1 diff --git a/samples/client/petstore/powershell/.openapi-generator-ignore b/samples/client/petstore/powershell/.openapi-generator-ignore index 7484ee590a38..c5b04829c20a 100644 --- a/samples/client/petstore/powershell/.openapi-generator-ignore +++ b/samples/client/petstore/powershell/.openapi-generator-ignore @@ -21,3 +21,6 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md +# +# +# From 64e64f73c3e5ac0d9ca0211b961845b7d085cbdd Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:20:54 +0800 Subject: [PATCH 2/8] update --- .github/workflows/samples-powershell.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/samples-powershell.yaml b/.github/workflows/samples-powershell.yaml index 8dd2554ea164..ee75adcd95cb 100644 --- a/.github/workflows/samples-powershell.yaml +++ b/.github/workflows/samples-powershell.yaml @@ -9,7 +9,7 @@ on: - samples/client/petstore/powershell/** jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest name: Test Powershell Clients strategy: matrix: @@ -25,8 +25,9 @@ jobs: SWAGGER_BASE_PATH: /v2 steps: - uses: actions/checkout@v5 - - name: Run tests + - name: Build the client working-directory: ${{ matrix.sample }} shell: pwsh run: | - CIRunTest.ps1 + Build.ps1 + From ab8c5c1ca39c9459464735faad579e4361002ca5 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:23:24 +0800 Subject: [PATCH 3/8] fix container --- .github/workflows/samples-powershell.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/samples-powershell.yaml b/.github/workflows/samples-powershell.yaml index ee75adcd95cb..508b55a3b534 100644 --- a/.github/workflows/samples-powershell.yaml +++ b/.github/workflows/samples-powershell.yaml @@ -9,7 +9,7 @@ on: - samples/client/petstore/powershell/** jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest name: Test Powershell Clients strategy: matrix: @@ -29,5 +29,5 @@ jobs: working-directory: ${{ matrix.sample }} shell: pwsh run: | - Build.ps1 + ./Build.ps1 From 8a57a4b28d1804564a46b868c5193334d6f48694 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:27:19 +0800 Subject: [PATCH 4/8] import, test --- .github/workflows/samples-powershell.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/samples-powershell.yaml b/.github/workflows/samples-powershell.yaml index 508b55a3b534..ff5c92ae2f5b 100644 --- a/.github/workflows/samples-powershell.yaml +++ b/.github/workflows/samples-powershell.yaml @@ -30,4 +30,15 @@ jobs: shell: pwsh run: | ./Build.ps1 + - name: Import + working-directory: ${{ matrix.sample }} + shell: pwsh + run: | + Import-Module -Name './src/PSPetstore' + - name: Test + working-directory: ${{ matrix.sample }} + shell: pwsh + run: | + Invoke-Pester -PassThru + From e991c219bd5760ff87c1c01094e9e03580d1f873 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:31:45 +0800 Subject: [PATCH 5/8] combine --- .github/workflows/samples-powershell.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/samples-powershell.yaml b/.github/workflows/samples-powershell.yaml index ff5c92ae2f5b..208cf69332f0 100644 --- a/.github/workflows/samples-powershell.yaml +++ b/.github/workflows/samples-powershell.yaml @@ -30,15 +30,11 @@ jobs: shell: pwsh run: | ./Build.ps1 - - name: Import - working-directory: ${{ matrix.sample }} - shell: pwsh - run: | - Import-Module -Name './src/PSPetstore' - name: Test working-directory: ${{ matrix.sample }} shell: pwsh run: | + Import-Module -Name './src/PSPetstore' Invoke-Pester -PassThru From c01693b934513dab9e7ab9b4aff95dedc16b8e33 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:45:20 +0800 Subject: [PATCH 6/8] use localhost --- ...ke-endpoints-models-for-testing-with-http-signature.yaml | 2 ++ samples/client/petstore/powershell/README.md | 2 +- samples/client/petstore/powershell/docs/PSAnotherFakeApi.md | 2 +- samples/client/petstore/powershell/docs/PSDefaultApi.md | 2 +- samples/client/petstore/powershell/docs/PSFakeApi.md | 2 +- .../petstore/powershell/docs/PSFakeClassnameTags123Api.md | 2 +- samples/client/petstore/powershell/docs/PSPetApi.md | 2 +- samples/client/petstore/powershell/docs/PSStoreApi.md | 2 +- samples/client/petstore/powershell/docs/PSUserApi.md | 2 +- .../powershell/src/PSPetstore/Client/PSConfiguration.ps1 | 6 +++++- 10 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 4fb684961ea4..52ec6279e0c1 100644 --- a/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -31,6 +31,7 @@ paths: $ref: '#/components/schemas/Foo' /pet: servers: + - url: 'http://localhost/v2' - url: 'http://petstore.swagger.io/v2' - url: 'http://path-server-test.petstore.local/v2' post: @@ -1170,6 +1171,7 @@ paths: schema: $ref: '#/components/schemas/ArrayOfEnums' servers: + - url: 'http://localhost/v2' - url: 'http://{server}.swagger.io:{port}/v2' description: petstore server variables: diff --git a/samples/client/petstore/powershell/README.md b/samples/client/petstore/powershell/README.md index 66eb863c9d0b..5aa81e0cea3e 100644 --- a/samples/client/petstore/powershell/README.md +++ b/samples/client/petstore/powershell/README.md @@ -52,7 +52,7 @@ For troubleshooting, please run `$DebugPreference = 'Continue'` to turn on debug ## Documentation for API Endpoints -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSAnotherFakeApi.md b/samples/client/petstore/powershell/docs/PSAnotherFakeApi.md index 7f10645464f6..c4b85e51217a 100644 --- a/samples/client/petstore/powershell/docs/PSAnotherFakeApi.md +++ b/samples/client/petstore/powershell/docs/PSAnotherFakeApi.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSAnotherFakeApi -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSDefaultApi.md b/samples/client/petstore/powershell/docs/PSDefaultApi.md index a75b9c9b0c1c..af1bad168ccb 100644 --- a/samples/client/petstore/powershell/docs/PSDefaultApi.md +++ b/samples/client/petstore/powershell/docs/PSDefaultApi.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSDefaultApi -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSFakeApi.md b/samples/client/petstore/powershell/docs/PSFakeApi.md index 2fbbcd7e7436..6aa3b3a35320 100644 --- a/samples/client/petstore/powershell/docs/PSFakeApi.md +++ b/samples/client/petstore/powershell/docs/PSFakeApi.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSFakeApi -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md b/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md index 02bfd8628a25..6583d204fadb 100644 --- a/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md +++ b/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSFakeClassnameTags123Api -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSPetApi.md b/samples/client/petstore/powershell/docs/PSPetApi.md index 48d7f783ce4c..829166f75653 100644 --- a/samples/client/petstore/powershell/docs/PSPetApi.md +++ b/samples/client/petstore/powershell/docs/PSPetApi.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSPetApi -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSStoreApi.md b/samples/client/petstore/powershell/docs/PSStoreApi.md index 2ff14209a049..24eaa6a083d1 100644 --- a/samples/client/petstore/powershell/docs/PSStoreApi.md +++ b/samples/client/petstore/powershell/docs/PSStoreApi.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSStoreApi -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/docs/PSUserApi.md b/samples/client/petstore/powershell/docs/PSUserApi.md index d1f99ed9d40c..1e8a3a54154c 100644 --- a/samples/client/petstore/powershell/docs/PSUserApi.md +++ b/samples/client/petstore/powershell/docs/PSUserApi.md @@ -1,6 +1,6 @@ # PSPetstore.PSPetstore\Api.PSUserApi -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 index 043b2f9e8464..43daeb442c5b 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 @@ -23,7 +23,7 @@ function Get-PSConfiguration { $Configuration = $Script:Configuration if ([string]::IsNullOrEmpty($Configuration["BaseUrl"])) { - $Configuration["BaseUrl"] = "http://petstore.swagger.io:80/v2"; + $Configuration["BaseUrl"] = "http://localhost/v2"; } if (!$Configuration.containsKey("Username")) { @@ -311,6 +311,10 @@ System.Collections.Hashtable[] #> function Get-PSHostSetting { return ,@( + @{ + "Url" = "http://localhost/v2"; + "Description" = "No description provided"; + }, @{ "Url" = "http://{server}.swagger.io:{port}/v2"; "Description" = "petstore server"; From 84566dbce36ae66c7a0b343014c40ea88a038891 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:49:16 +0800 Subject: [PATCH 7/8] update tests --- .../petstore/powershell/tests/Petstore.Tests.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/client/petstore/powershell/tests/Petstore.Tests.ps1 b/samples/client/petstore/powershell/tests/Petstore.Tests.ps1 index 6e64665dd659..6a1c24336564 100644 --- a/samples/client/petstore/powershell/tests/Petstore.Tests.ps1 +++ b/samples/client/petstore/powershell/tests/Petstore.Tests.ps1 @@ -140,19 +140,19 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $HS = Get-PSHostSetting - $HS[0]["Url"] | Should -Be "http://{server}.swagger.io:{port}/v2" - $HS[0]["Description"] | Should -Be "petstore server" - $HS[0]["Variables"]["server"]["Description"] | Should -Be "No description provided" - $HS[0]["Variables"]["server"]["DefaultValue"] | Should -Be "petstore" - $HS[0]["Variables"]["server"]["EnumValues"] | Should -Be @("petstore", + $HS[1]["Url"] | Should -Be "http://{server}.swagger.io:{port}/v2" + $HS[1]["Description"] | Should -Be "petstore server" + $HS[1]["Variables"]["server"]["Description"] | Should -Be "No description provided" + $HS[1]["Variables"]["server"]["DefaultValue"] | Should -Be "petstore" + $HS[1]["Variables"]["server"]["EnumValues"] | Should -Be @("petstore", "qa-petstore", "dev-petstore") } It "Get-PSUrlFromHostSetting tests" { - Get-PSUrlFromHostSetting -Index 0 | Should -Be "http://petstore.swagger.io:80/v2" - Get-PSUrlFromHostSetting -Index 0 -Variables @{ "port" = "8080" } | Should -Be "http://petstore.swagger.io:8080/v2" + Get-PSUrlFromHostSetting -Index 1 | Should -Be "http://petstore.swagger.io:80/v2" + Get-PSUrlFromHostSetting -Index 1 -Variables @{ "port" = "8080" } | Should -Be "http://petstore.swagger.io:8080/v2" #Get-PSUrlFromHostSetting -Index 2 | Should -Throw -ExceptionType ([RuntimeException]) #Get-PSUrlFromHostSetting -Index 2 -ErrorAction Stop | Should -Throw "RuntimeException: Invalid index 2 when selecting the host. Must -Be less than 2" #Get-PSUrlFromHostSetting -Index 0 -Variables @{ "port" = "1234" } -ErrorAction Stop | Should -Throw "RuntimeException: The variable 'port' in the host URL has invalid value 1234. Must -Be 80,8080" From bf59ba93a1016efb92acdc0ebda4ad10e8c2358d Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 16 Sep 2025 14:51:11 +0800 Subject: [PATCH 8/8] remove powershell tests from appveyor.yml --- appveyor.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3c6471ae7a77..08ee15a80409 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,6 @@ install: - cmd: docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore - ps: Start-Sleep -s 120 - ps: $PSVersionTable.PSVersion - - ps: Install-Module -Name Pester -Force -Scope CurrentUser -SkipPublisherCheck build_script: - dotnet --info # build C# aspnetcore 5.0 server @@ -108,11 +107,6 @@ test_script: # - .\bin\windows\run-all-petstore.cmd # generate all petstore clients (openapi3) # - .\bin\openapi3\windows\run-all-petstore.cmd - - # test ps petstore - - ps: | - cd samples\client\petstore\powershell\ - .\CIRunTest.ps1 cache: - C:\maven\ - C:\gradle\