Swagger API - Authentication?

Product: PowerShell Universal
Version: 3.7.9

Hi,

Ive created a new API that looks like this:

#region PSUHeader 
[Documentation()]
class SourceDatabase {
    [string]$SourceDatabase
}
#endregion
New-PSUEndpoint -Url "/api/sql/dbcopy/v1/CopyDbFromProdToTest" -Description "Copies database from prod to test" -Method @('POST') -Endpoint {
<# 
.SYNOPSIS
Copies a database from prod to test

.DESCRIPTION
Copies a database from prod to test

.OUTPUTS
    200:
        Description: This is an output value. 
        Content:
            application/json: SourceDatabase

    400:
        Description: Invalid input
.INPUTS 
    Required: true
    Description: This is an input value.
    Content: 
        application/json: SourceDatabase
#>

param(    
    [Parameter(Mandatory = $true)]    
    [ValidateSet("Jira_Prod", "Bitbucket_prod", ErrorMessage = "Invalid database name")]
    [string]
    $SourceDatabase
)
} -Authentication -Role @('SQLDBCopyUsers') -Tag @('beta')

The swagger documentation looks perfect and works really well, but only if i disable authentication on that endpoint.

I cant seem to locate in the documentation, how to add a “authorize” button on the documentation site - like with https://petstore.swagger.io/

Any ideas?

1 Like