Product: PowerShell Universal
Version: 3.8.9
Hello
I wrote a few endpoints that accept a parameters in a JSON body. Some of the endpoints have a parameter that uses a [ValidateSet()] parameter attribute that looks like:
param(
# Specifies the ServiceNow Tenant name to logon to.
[Parameter(Mandatory=$true, HelpMessage="Specifies the ServiceNow Tenant name to logon to.")]
[ValidateNotNullOrEmpty()]
[ValidateSet('dev','test','prod')]
[string]
$TenantName
)
My customers of these endpoints are people comfortable consuming Swagger data.
I have been banging my head against the wall trying to figure out how to document this using classes in the “Endpoint Documentation” section.
I am not super strong in classes/OoO but I think what I want is a class that documents an enum
of strings with my tenant names. I’ve made sure that my endpoint also includes the necessary and matching info in the .OUTPUTS
and .INPUTS
sections
I’ve tried:
enum Names {
Dev
Test
Prod
}
but this generates open API spec/swagger with an empty schema.
I tried various iterations of
enum Names {
Dev
Test
Prod
}
class TenantNames {
[Names[]] $TenantName
}
Is this possible? Am I missing something SO OBVIOUS?
An example of what I am trying to emulate is:
PowerShellUniversal.Folder{
id integer($int64)
path string
nullable: true
type PowerShellUniversal.FolderTypeinteger($int32)
Enum:
Array [ 5 ]
}
The type PowerShellUniversal.FolderTypeinteger($int32)
is exactly what I am trying to emulate
I want a ServiceNowTenantList
type enum with strings
not int32…
I’m thinking to have a class for ServiceNowAuth
that accepts a ServiceNowTenantList
enum as the TenantName
parameter, but I am not sure if I can get there.
Thank you very much. And thank you very much for an awesome product!!!