Closed hrebynakha closed 2 months ago
I just tried with Name Value
PSVersion 5.1.22621.3880 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.3880 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
and works fine.
You are using the Windows 11 October 2023 patch https://support.microsoft.com/en-us/topic/october-31-2023-kb5031455-os-builds-22621-2506-and-22631-2506-preview-6513c5ec-c5a2-4aaf-97f5-44c13d29e0d4 Looks like it's a bug in this specific version of PowerShell, not a Pode one.
You cannot define $Version as [int] otherwise 3.1 is not accepted. What we can do is to change it to string. I've a branch open to fix any OpenAPI issues. I'm going to add the workaround to the branch
Describe the Bug
Bug in different powershell version, decimal value validation not works fine.
Steps To Reproduce
Steps to reproduce the behavior: In this component file: Pode/blob/develop/src/Public/OAComponents.ps1
function Test-PodeOAVersion
When try it use like this: Test-PodeOAVersion -Version 3.1 got error: Test-PodeOAVersion : Cannot validate argument on parameter 'Version'. The argument "3,1" does not belong to the set "3.1,3" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
function Test-PodeOAVersion [Parameter(Mandatory = $true)] [ValidateSet( 3.1 , 3.0 )] [decimal] $Version,
Version validation shoud be changed to [int] value .
Platform
Additional Context
This issue works only using this Powershell version (may be grate version also , i don't test ): $PSVersionTable
Name Value
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
For example on this powershell version it works fine
$PSVersionTable
Name Value
PSVersion 5.1.14393.6343
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.6343
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1