Add workflow for PowerShell clients (#21979)

* add workflow for powershell client

* update

* fix container

* import, test

* combine

* use localhost

* update tests

* remove powershell tests from appveyor.yml
This commit is contained in:
William Cheng 2025-09-16 15:24:22 +08:00 committed by GitHub
parent 46de9c8c16
commit 45e4fa1633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 65 additions and 22 deletions

View File

@ -0,0 +1,40 @@
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: Build the client
working-directory: ${{ matrix.sample }}
shell: pwsh
run: |
./Build.ps1
- name: Test
working-directory: ${{ matrix.sample }}
shell: pwsh
run: |
Import-Module -Name './src/PSPetstore'
Invoke-Pester -PassThru

View File

@ -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\

View File

@ -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:

View File

@ -21,3 +21,6 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
#
#
#

View File

@ -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
------------ | ------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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
------------- | ------------- | -------------

View File

@ -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";

View File

@ -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"