Make OperationSpec.baseUrl an optional property for moving OperationSpecs into module/file scope

This commit is contained in:
Dan Schulte 2018-06-26 13:47:00 -07:00
Родитель 5547c64b45
Коммит d422cf7e63
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -22,9 +22,10 @@ export interface OperationSpec {
/**
* The URL that was provided in the service's specification. This will still have all of the URL
* template variables in it.
* template variables in it. If this is not provided when the OperationSpec is created, then it
* will be populated by a "baseUri" property on the ServiceClient.
*/
baseUrl: string;
baseUrl?: string;
/**
* The fixed path for this operation's URL. This will still have all of the URL template variables

Просмотреть файл

@ -177,6 +177,13 @@ export class ServiceClient {
let result: Promise<HttpOperationResponse>;
try {
if (operationSpec.baseUrl == undefined) {
operationSpec.baseUrl = (this as any).baseUri;
if (!operationSpec.baseUrl) {
throw new Error("If operationSpec.baseUrl is not specified, then the ServiceClient must have a baseUri string property that contains the base URL to use.");
}
}
httpRequest.method = operationSpec.httpMethod;
httpRequest.operationSpec = operationSpec;