ghostclass
ghostclass

Reputation: 45

AutoRest - How to parameterise the hostname

I have what feels like a fairly basic requirement when using the AutoRest utility.

My OpenAPI spec has a "servers" property with the like so:

 "servers": [
{
  "url": "https://{{tenant}}.api.{{domain}}.com"
}],

The classes generated result in static hostname references as follows:

// generate request object
            var _url = new global::System.Uri($"https://{{tenant}}.api.{{domain}}.com{pathAndQuery}");

I want to use the generated lib across many environments/tenants and don't want to generate a specific set of libs per tenant.

Before I go too far down a rabbit hole, I figured I would ask here how best to achieve a parameterised hostname rather than hardcoded into the generated functions. What I would settle for is a param 'url' by default on each API call generated. I figure nearly everyone must do this with autorest so I am sure I am just missing something simple.

Any help appreciated.

Upvotes: 1

Views: 64

Answers (0)

Related Questions