Skip to content

Commit

Permalink
[FormRecognizer] Fix doc issue caused by generated client (#8533)
Browse files Browse the repository at this point in the history
having the same name of 'FormRecognizerClient' by re-generating code with client
name override.
  • Loading branch information
jeremymeng authored May 1, 2020
1 parent ffd6c56 commit 008095b
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import {
} from "./common";
import { CanonicalCode } from "@opentelemetry/api";

import { FormRecognizerClient as GeneratedClient } from "./generated/formRecognizerClient";
import { GeneratedClient } from "./generated/generatedClient";
import {
FormRecognizerClientAnalyzeWithCustomModelResponse as AnalyzeWithCustomModelResponseModel,
FormRecognizerClientAnalyzeLayoutAsyncResponse as AnalyzeLayoutAsyncResponseModel,
FormRecognizerClientAnalyzeReceiptAsyncResponse as AnalyzeReceiptAsyncResponseModel,
GeneratedClientAnalyzeWithCustomModelResponse as AnalyzeWithCustomModelResponseModel,
GeneratedClientAnalyzeLayoutAsyncResponse as AnalyzeLayoutAsyncResponseModel,
GeneratedClientAnalyzeReceiptAsyncResponse as AnalyzeReceiptAsyncResponseModel,
ContentType,
SourcePath
} from "./generated/models";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { SDK_VERSION } from "./constants";
import { logger } from "./logger";
import { createSpan } from "./tracing";
import { CanonicalCode } from "@opentelemetry/api";
import { FormRecognizerClient as GeneratedClient } from "./generated/formRecognizerClient";
import { GeneratedClient } from "./generated/generatedClient";
import {
FormRecognizerClientGetCustomModelsResponse as ListModelsResponseModel,
GeneratedClientGetCustomModelsResponse as ListModelsResponseModel,
Model,
ModelInfo,
FormRecognizerClientTrainCustomModelAsyncResponse
GeneratedClientTrainCustomModelAsyncResponse
} from "./generated/models";
import { TrainPollerClient, BeginTrainingPoller, BeginTrainingPollState } from "./lro/train/poller";
import { PollOperationState, PollerLike } from "@azure/core-lro";
Expand Down Expand Up @@ -439,7 +439,7 @@ async function trainCustomModelInternal(
source: string,
useLabelFile?: boolean,
options?: TrainModelOptions
): Promise<FormRecognizerClientTrainCustomModelAsyncResponse> {
): Promise<GeneratedClientTrainCustomModelAsyncResponse> {
const realOptions = options || {};
const { span, updatedOptions: finalOptions } = createSpan(
"trainCustomModelInternal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import * as coreHttp from "@azure/core-http";
import * as Parameters from "./models/parameters";
import * as Models from "./models";
import * as Mappers from "./models/mappers";
import { FormRecognizerClientContext } from "./formRecognizerClientContext";
import { GeneratedClientContext } from "./generatedClientContext";

class FormRecognizerClient extends FormRecognizerClientContext {
class GeneratedClient extends GeneratedClientContext {
/**
* Initializes a new instance of the FormRecognizerClient class.
* Initializes a new instance of the GeneratedClient class.
* @param credentials Subscription credentials which uniquely identify client subscription.
* @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example:
* https://westus2.api.cognitive.microsoft.com).
Expand All @@ -23,7 +23,7 @@ class FormRecognizerClient extends FormRecognizerClientContext {
constructor(
credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials,
endpoint: string,
options?: Models.FormRecognizerClientOptionalParams
options?: Models.GeneratedClientOptionalParams
) {
super(credentials, endpoint, options);
}
Expand All @@ -43,11 +43,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
trainCustomModelAsync(
trainRequest: Models.TrainRequest,
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientTrainCustomModelAsyncResponse> {
): Promise<Models.GeneratedClientTrainCustomModelAsyncResponse> {
return this.sendOperationRequest(
{ trainRequest, options },
trainCustomModelAsyncOperationSpec
) as Promise<Models.FormRecognizerClientTrainCustomModelAsyncResponse>;
) as Promise<Models.GeneratedClientTrainCustomModelAsyncResponse>;
}

/**
Expand All @@ -57,12 +57,12 @@ class FormRecognizerClient extends FormRecognizerClientContext {
*/
getCustomModel(
modelId: string,
options?: Models.FormRecognizerClientGetCustomModelOptionalParams
): Promise<Models.FormRecognizerClientGetCustomModelResponse> {
options?: Models.GeneratedClientGetCustomModelOptionalParams
): Promise<Models.GeneratedClientGetCustomModelResponse> {
return this.sendOperationRequest(
{ modelId, options },
getCustomModelOperationSpec
) as Promise<Models.FormRecognizerClientGetCustomModelResponse>;
) as Promise<Models.GeneratedClientGetCustomModelResponse>;
}

/**
Expand Down Expand Up @@ -90,8 +90,8 @@ class FormRecognizerClient extends FormRecognizerClientContext {
*/
analyzeWithCustomModel(
modelId: string,
options?: Models.FormRecognizerClientAnalyzeWithCustomModelOptionalParams
): Promise<Models.FormRecognizerClientAnalyzeWithCustomModelResponse> {
options?: Models.GeneratedClientAnalyzeWithCustomModelOptionalParams
): Promise<Models.GeneratedClientAnalyzeWithCustomModelResponse> {
let operationSpec: coreHttp.OperationSpec;
if (
options &&
Expand All @@ -107,7 +107,7 @@ class FormRecognizerClient extends FormRecognizerClientContext {
return this.sendOperationRequest(
{ modelId, options },
operationSpec
) as Promise<Models.FormRecognizerClientAnalyzeWithCustomModelResponse>;
) as Promise<Models.GeneratedClientAnalyzeWithCustomModelResponse>;
}

/**
Expand All @@ -120,11 +120,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
modelId: string,
resultId: string,
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientGetAnalyzeFormResultResponse> {
): Promise<Models.GeneratedClientGetAnalyzeFormResultResponse> {
return this.sendOperationRequest(
{ modelId, resultId, options },
getAnalyzeFormResultOperationSpec
) as Promise<Models.FormRecognizerClientGetAnalyzeFormResultResponse>;
) as Promise<Models.GeneratedClientGetAnalyzeFormResultResponse>;
}

/**
Expand All @@ -135,8 +135,8 @@ class FormRecognizerClient extends FormRecognizerClientContext {
* @param options The options parameters.
*/
analyzeReceiptAsync(
options?: Models.FormRecognizerClientAnalyzeReceiptAsyncOptionalParams
): Promise<Models.FormRecognizerClientAnalyzeReceiptAsyncResponse> {
options?: Models.GeneratedClientAnalyzeReceiptAsyncOptionalParams
): Promise<Models.GeneratedClientAnalyzeReceiptAsyncResponse> {
let operationSpec: coreHttp.OperationSpec;
if (
options &&
Expand All @@ -150,7 +150,7 @@ class FormRecognizerClient extends FormRecognizerClientContext {
operationSpec = analyzeReceiptAsync$jsonOperationSpec;
}
return this.sendOperationRequest({ options }, operationSpec) as Promise<
Models.FormRecognizerClientAnalyzeReceiptAsyncResponse
Models.GeneratedClientAnalyzeReceiptAsyncResponse
>;
}

Expand All @@ -162,11 +162,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
getAnalyzeReceiptResult(
resultId: string,
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientGetAnalyzeReceiptResultResponse> {
): Promise<Models.GeneratedClientGetAnalyzeReceiptResultResponse> {
return this.sendOperationRequest(
{ resultId, options },
getAnalyzeReceiptResultOperationSpec
) as Promise<Models.FormRecognizerClientGetAnalyzeReceiptResultResponse>;
) as Promise<Models.GeneratedClientGetAnalyzeReceiptResultResponse>;
}

/**
Expand All @@ -177,8 +177,8 @@ class FormRecognizerClient extends FormRecognizerClientContext {
* @param options The options parameters.
*/
analyzeLayoutAsync(
options?: Models.FormRecognizerClientAnalyzeLayoutAsyncOptionalParams
): Promise<Models.FormRecognizerClientAnalyzeLayoutAsyncResponse> {
options?: Models.GeneratedClientAnalyzeLayoutAsyncOptionalParams
): Promise<Models.GeneratedClientAnalyzeLayoutAsyncResponse> {
let operationSpec: coreHttp.OperationSpec;
if (
options &&
Expand All @@ -192,7 +192,7 @@ class FormRecognizerClient extends FormRecognizerClientContext {
operationSpec = analyzeLayoutAsync$jsonOperationSpec;
}
return this.sendOperationRequest({ options }, operationSpec) as Promise<
Models.FormRecognizerClientAnalyzeLayoutAsyncResponse
Models.GeneratedClientAnalyzeLayoutAsyncResponse
>;
}

Expand All @@ -204,11 +204,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
getAnalyzeLayoutResult(
resultId: string,
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientGetAnalyzeLayoutResultResponse> {
): Promise<Models.GeneratedClientGetAnalyzeLayoutResultResponse> {
return this.sendOperationRequest(
{ resultId, options },
getAnalyzeLayoutResultOperationSpec
) as Promise<Models.FormRecognizerClientGetAnalyzeLayoutResultResponse>;
) as Promise<Models.GeneratedClientGetAnalyzeLayoutResultResponse>;
}

/**
Expand All @@ -217,11 +217,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
*/
listCustomModels(
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientListCustomModelsResponse> {
): Promise<Models.GeneratedClientListCustomModelsResponse> {
return this.sendOperationRequest(
{ options },
listCustomModelsOperationSpec
) as Promise<Models.FormRecognizerClientListCustomModelsResponse>;
) as Promise<Models.GeneratedClientListCustomModelsResponse>;
}

/**
Expand All @@ -230,11 +230,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
*/
getCustomModels(
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientGetCustomModelsResponse> {
): Promise<Models.GeneratedClientGetCustomModelsResponse> {
return this.sendOperationRequest(
{ options },
getCustomModelsOperationSpec
) as Promise<Models.FormRecognizerClientGetCustomModelsResponse>;
) as Promise<Models.GeneratedClientGetCustomModelsResponse>;
}

/**
Expand All @@ -245,11 +245,11 @@ class FormRecognizerClient extends FormRecognizerClientContext {
listCustomModelsNext(
nextLink: string,
options?: coreHttp.OperationOptions
): Promise<Models.FormRecognizerClientListCustomModelsNextResponse> {
): Promise<Models.GeneratedClientListCustomModelsNextResponse> {
return this.sendOperationRequest(
{ nextLink, options },
listCustomModelsNextOperationSpec
) as Promise<Models.FormRecognizerClientListCustomModelsNextResponse>;
) as Promise<Models.GeneratedClientListCustomModelsNextResponse>;
}
}
// Operation Specifications
Expand All @@ -261,7 +261,7 @@ const trainCustomModelAsyncOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
201: {
headersMapper: Mappers.FormRecognizerClientTrainCustomModelAsyncHeaders
headersMapper: Mappers.GeneratedClientTrainCustomModelAsyncHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand Down Expand Up @@ -303,7 +303,7 @@ const analyzeWithCustomModel$binaryOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.FormRecognizerClientAnalyzeWithCustomModelHeaders
headersMapper: Mappers.GeneratedClientAnalyzeWithCustomModelHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand All @@ -320,7 +320,7 @@ const analyzeWithCustomModel$jsonOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.FormRecognizerClientAnalyzeWithCustomModelHeaders
headersMapper: Mappers.GeneratedClientAnalyzeWithCustomModelHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand Down Expand Up @@ -350,7 +350,7 @@ const analyzeReceiptAsync$binaryOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.FormRecognizerClientAnalyzeReceiptAsyncHeaders
headersMapper: Mappers.GeneratedClientAnalyzeReceiptAsyncHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand All @@ -367,7 +367,7 @@ const analyzeReceiptAsync$jsonOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.FormRecognizerClientAnalyzeReceiptAsyncHeaders
headersMapper: Mappers.GeneratedClientAnalyzeReceiptAsyncHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand Down Expand Up @@ -397,7 +397,7 @@ const analyzeLayoutAsync$binaryOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.FormRecognizerClientAnalyzeLayoutAsyncHeaders
headersMapper: Mappers.GeneratedClientAnalyzeLayoutAsyncHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand All @@ -413,7 +413,7 @@ const analyzeLayoutAsync$jsonOperationSpec: coreHttp.OperationSpec = {
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.FormRecognizerClientAnalyzeLayoutAsyncHeaders
headersMapper: Mappers.GeneratedClientAnalyzeLayoutAsyncHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
Expand Down Expand Up @@ -486,8 +486,8 @@ const listCustomModelsNextOperationSpec: coreHttp.OperationSpec = {
// Operation Specifications

export {
FormRecognizerClient,
FormRecognizerClientContext,
Models as FormRecognizerModels,
Mappers as FormRecognizerMappers
GeneratedClient,
GeneratedClientContext,
Models as GeneratedModels,
Mappers as GeneratedMappers
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import * as Models from "./models";
const packageName = "@azure/ai-form-recognizer";
const packageVersion = "1.0.0-preview.2";

export class FormRecognizerClientContext extends coreHttp.ServiceClient {
export class GeneratedClientContext extends coreHttp.ServiceClient {
endpoint: string;

/**
* Initializes a new instance of the FormRecognizerClientContext class.
* Initializes a new instance of the GeneratedClientContext class.
* @param credentials Subscription credentials which uniquely identify client subscription.
* @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example:
* https://westus2.api.cognitive.microsoft.com).
Expand All @@ -25,7 +25,7 @@ export class FormRecognizerClientContext extends coreHttp.ServiceClient {
constructor(
credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials,
endpoint: string,
options?: Models.FormRecognizerClientOptionalParams
options?: Models.GeneratedClientOptionalParams
) {
if (credentials === undefined) {
throw new Error("'credentials' cannot be null");
Expand Down
Loading

0 comments on commit 008095b

Please sign in to comment.