PipeScript icon indicating copy to clipboard operation
PipeScript copied to clipboard

openapi should process an api with more than one server

Open RegEM opened this issue 1 year ago • 0 comments

Connecting to the Stellar Horizon api server, via openapi example 2:

Import-PipeScript {
    function Get-HorizonApi
    {
        [OpenAPI(SchemaURI='https://raw.githubusercontent.com/stellar/stellar-docs/refs/heads/main/openapi/horizon/bundled.yml')]
        param()
    }
}
Get-HorizonApi '/accounts'

Invoke-RestMethod:
Line |
 235 |              $restfulOutput = Invoke-RestMethod @invokeSplat
     |                                                 ~~~~~~~~~~~~
     | Cannot bind parameter 'Uri'. Cannot convert value "https://horizon-testnet.stellar.org https://horizon-futurenet.stellar.org/accounts" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."

bundle.yml references two servers.

servers:
  - url: https://horizon-testnet.stellar.org
    description: The Testnet Network
  - url: https://horizon-futurenet.stellar.org
    description: The Futurenet network

...which both end up in the url (line 43) of the script block

$Uri, $outputTypeName = 'get', 'https://horizon-testnet.stellar.org https://horizon-futurenet.stellar.org', ''
$BaseUri = $Uri

I looked at -QueryParameter, and -PathParameter, but didn't succeed at setting the url. If it's possible, then a note how to direct requests to the desired server would be nice. And the issue title is incorrect. Cheers.

RegEM avatar Jan 20 '25 03:01 RegEM