[Text Analytics] Split swagger transforms into general vs JS-specific (#22298)

* [Text Analytics] Split swagger transforms into general vs JS-specific

* address feedback
This commit is contained in:
Deyaaeldeen Almahallawi 2022-09-14 17:39:34 -07:00 коммит произвёл GitHub
Родитель f4f5dc4b75
Коммит a8543fc22a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 220 добавлений и 395 удалений

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

@ -21,7 +21,10 @@ import {
GeneratedClientOptionalParams,
AnalyzeActionUnion,
AnalyzeOptionalParams,
AnalyzeResponse
AnalyzeResponse,
AnalyzeTextJobsInput,
AnalyzeBatchOptionalParams,
AnalyzeBatchResponse
} from "./models";
/** @internal */
@ -136,6 +139,22 @@ export class GeneratedClient extends coreClient.ServiceClient {
return this.sendOperationRequest({ body, options }, analyzeOperationSpec);
}
/**
* Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed
* as a long-running operation.
* @param body Collection of documents to analyze and one or more tasks to execute.
* @param options The options parameters.
*/
analyzeBatch(
body: AnalyzeTextJobsInput,
options?: AnalyzeBatchOptionalParams
): Promise<AnalyzeBatchResponse> {
return this.sendOperationRequest(
{ body, options },
analyzeBatchOperationSpec
);
}
analyzeText: AnalyzeText;
}
// Operation Specifications
@ -159,3 +178,21 @@ const analyzeOperationSpec: coreClient.OperationSpec = {
mediaType: "json",
serializer
};
const analyzeBatchOperationSpec: coreClient.OperationSpec = {
path: "/analyze-text/jobs",
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.GeneratedClientAnalyzeBatchHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
requestBody: Parameters.body1,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint],
headerParameters: [Parameters.contentType, Parameters.accept],
mediaType: "json",
serializer
};

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

@ -278,6 +278,7 @@ export interface ClassificationCategory {
confidenceScore: number;
}
/** A type representing a reference for the healthcare entity into a specific entity catalog. */
export interface HealthcareEntity {
/** Entity text as appears in the request. */
text: string;
@ -559,11 +560,11 @@ export interface ActionPrebuilt extends ActionCommon {
modelVersion?: string;
}
/** Parameters object for a text analysis task using custom models. */
/** Configuration common to all actions that use custom models. */
export interface ActionCustom extends ActionCommon {
/** This field indicates the project name for the model. */
/** The project name for the model to be used by the action. */
projectName: string;
/** This field indicates the deployment name for the model. */
/** The deployment name for the model to be used by the action. */
deploymentName: string;
}
@ -777,7 +778,7 @@ export interface KeyPhraseExtractionAction extends ActionPrebuilt {}
/** Options for a Pii entity recognition action. */
export interface PiiEntityRecognitionAction extends ActionPrebuilt {
/**
* Filters entities to ones only included in the specified domain (e.g., if set to `Phi`, only entities in the Protected Healthcare Information domain will be returned). For a list of possible domains, see {@link PiiDomain}.
* Filters entities to ones only included in the specified domain (e.g., if set to `Phi`, only entities in the Protected Healthcare Information domain will be returned). For a list of possible domains, see {@link KnownPiiEntityDomain}.
*
* See {@link https://aka.ms/tanerpii the service documentation} for more information.
*/
@ -855,8 +856,8 @@ export interface PiiResultDocumentsItem extends PiiEntitiesDocumentResult {}
export interface KeyPhraseResultDocumentsItem
extends KeyPhrasesDocumentResult {}
/** Defines headers for AnalyzeText_submitJob operation. */
export interface AnalyzeTextSubmitJobHeaders {
/** Defines headers for GeneratedClient_analyzeBatch operation. */
export interface GeneratedClientAnalyzeBatchHeaders {
operationLocation?: string;
}
@ -1972,11 +1973,11 @@ export interface AnalyzeOptionalParams extends coreClient.OperationOptions {
export type AnalyzeResponse = AnalyzeTextTaskResultUnion;
/** Optional parameters. */
export interface AnalyzeTextSubmitJobOptionalParams
export interface AnalyzeBatchOptionalParams
extends coreClient.OperationOptions {}
/** Contains response data for the submitJob operation. */
export type AnalyzeTextSubmitJobResponse = AnalyzeTextSubmitJobHeaders;
/** Contains response data for the analyzeBatch operation. */
export type AnalyzeBatchResponse = GeneratedClientAnalyzeBatchHeaders;
/** Optional parameters. */
export interface AnalyzeTextJobStatusOptionalParams

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

@ -2813,10 +2813,10 @@ export const KeyPhraseResultDocumentsItem: coreClient.CompositeMapper = {
}
};
export const AnalyzeTextSubmitJobHeaders: coreClient.CompositeMapper = {
export const GeneratedClientAnalyzeBatchHeaders: coreClient.CompositeMapper = {
type: {
name: "Composite",
className: "AnalyzeTextSubmitJobHeaders",
className: "GeneratedClientAnalyzeBatchHeaders",
modelProperties: {
operationLocation: {
serializedName: "operation-location",

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

@ -12,9 +12,6 @@ import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { GeneratedClient } from "../generatedClient";
import {
AnalyzeTextJobsInput,
AnalyzeTextSubmitJobOptionalParams,
AnalyzeTextSubmitJobResponse,
AnalyzeTextJobStatusOptionalParams,
AnalyzeTextJobStatusResponse,
AnalyzeTextCancelJobOptionalParams,
@ -33,22 +30,6 @@ export class AnalyzeTextImpl implements AnalyzeText {
this.client = client;
}
/**
* Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed
* as a long-running operation.
* @param body Collection of documents to analyze and one or more tasks to execute.
* @param options The options parameters.
*/
submitJob(
body: AnalyzeTextJobsInput,
options?: AnalyzeTextSubmitJobOptionalParams
): Promise<AnalyzeTextSubmitJobResponse> {
return this.client.sendOperationRequest(
{ body, options },
submitJobOperationSpec
);
}
/**
* Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are
* succeeded, the job will transition to the succeeded state and results will be available for each
@ -84,24 +65,6 @@ export class AnalyzeTextImpl implements AnalyzeText {
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const submitJobOperationSpec: coreClient.OperationSpec = {
path: "/analyze-text/jobs",
httpMethod: "POST",
responses: {
202: {
headersMapper: Mappers.AnalyzeTextSubmitJobHeaders
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
requestBody: Parameters.body1,
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.endpoint],
headerParameters: [Parameters.contentType, Parameters.accept],
mediaType: "json",
serializer
};
const jobStatusOperationSpec: coreClient.OperationSpec = {
path: "/analyze-text/jobs/{jobId}",
httpMethod: "GET",

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

@ -7,9 +7,6 @@
*/
import {
AnalyzeTextJobsInput,
AnalyzeTextSubmitJobOptionalParams,
AnalyzeTextSubmitJobResponse,
AnalyzeTextJobStatusOptionalParams,
AnalyzeTextJobStatusResponse,
AnalyzeTextCancelJobOptionalParams,
@ -18,16 +15,6 @@ import {
/** Interface representing a AnalyzeText. */
export interface AnalyzeText {
/**
* Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed
* as a long-running operation.
* @param body Collection of documents to analyze and one or more tasks to execute.
* @param options The options parameters.
*/
submitJob(
body: AnalyzeTextJobsInput,
options?: AnalyzeTextSubmitJobOptionalParams
): Promise<AnalyzeTextSubmitJobResponse>;
/**
* Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are
* succeeded, the job will transition to the succeeded state and results will be available for each

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

@ -159,7 +159,7 @@ export function createAnalyzeBatchLro(settings: {
throwError(
getRawResponse(
(paramOptions) =>
client.analyzeText.submitJob(
client.analyzeBatch(
{
tasks,
analysisInput: {

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

@ -25,357 +25,209 @@ typescript: true
See the [AutoRest samples](https://github.com/Azure/autorest/tree/master/Samples/3b-custom-transformations)
for more about how we're customizing things.
### Rename analyze-text to Analyze and analyze-test/jobs to AnalyzeBatch
## General customizations
```yaml
directive:
- from: swagger-document
where: $["paths"]["/:analyze-text"]["post"]
- where-operation: AnalyzeText
transform: $.operationId = "Analyze";
- from: swagger-document
where: $["paths"]["/:analyze-text/jobs"]["post"]
- where-operation: AnalyzeText_SubmitJob
transform: $.operationId = "AnalyzeBatch";
```
### Rename JobState
```yaml
directive:
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.createdDateTime["x-ms-client-name"] = "createdOn";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.expirationDateTime["x-ms-client-name"] = "expiresOn";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.jobId["x-ms-client-name"] = "id";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.lastUpdatedDateTime["x-ms-client-name"] = "modifiedOn";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.status["x-ms-enum"].name = "OperationStatus";
```
### Task renames
```yaml
directive:
- from: swagger-document
where: $.definitions.AnalyzeTextTask
- rename-model:
from: AnalyzeTextTask
to: AnalyzeAction
- rename-model:
from: AnalyzeTextLROTask
to: AnalyzeBatchAction
- where-model: TaskParameters
transform:
$["x-ms-client-name"] = "AnalyzeAction";
- from: swagger-document
where: $.definitions.AnalyzeTextLROTask
transform:
$["x-ms-client-name"] = "AnalyzeBatchAction";
- from: swagger-document
where: $.definitions.TaskParameters
transform:
$.properties.loggingOptOut["x-ms-client-name"] = "disableServiceLogs";
$.description = "Configuration common to all actions.";
$.properties.loggingOptOut.description = "If set to true, you opt-out of having your text input logged for troubleshooting. By default, Cognitive Language Service logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true, disables in logging and may limit our ability to remediate issues that occur.\n\nDefault is false.";
$.properties.loggingOptOut["x-ms-client-name"] = "disableServiceLogs";
$["x-ms-client-name"] = "ActionCommon";
$.description = "Configuration common to all actions."
- from: swagger-document
where: $.definitions.PreBuiltTaskParameters.properties.modelVersion
transform:
$.description = "The version of the model to be used by the action.";
- from: swagger-document
where: $.definitions.PreBuiltTaskParameters
- rename-model:
from: PreBuiltTaskParameters
to: ActionPrebuilt
- where-model: ActionPrebuilt
transform:
$.properties.modelVersion.description = "The version of the model to be used by the action.";
$.description = "Configuration common to all actions that use prebuilt models.";
$["x-ms-client-name"] = "ActionPrebuilt";
- from: swagger-document
where: $.definitions.CustomTaskParameters
transform:
$["x-ms-client-name"] = "ActionCustom";
- from: swagger-document
where: $.definitions.ActionCustom
- rename-model:
from: CustomTaskParameters
to: ActionCustom
- where-model: ActionCustom
transform:
$.description = "Configuration common to all actions that use custom models.";
$.properties.projectName.description = "The project name for the model to be used by the action.";
$.properties.deploymentName.description = "The deployment name for the model to be used by the action.";
- from: swagger-document
where: $.definitions.EntityLinkingTaskParameters
- rename-model:
from: EntityLinkingTaskParameters
to: EntityLinkingAction
- where-model: EntityLinkingAction
transform:
$["x-ms-client-name"] = "EntityLinkingAction";
$.description = "Options for an entity linking action.";
- from: swagger-document
where: $.definitions.EntitiesTaskParameters
- rename-model:
from: EntitiesTaskParameters
to: EntityRecognitionAction
- where-model: EntityRecognitionAction
transform:
$["x-ms-client-name"] = "EntityRecognitionAction";
$.description = "Options for an entity recognition action.";
- from: swagger-document
where: $.definitions.SentimentAnalysisTaskParameters
- rename-model:
from: SentimentAnalysisTaskParameters
to: SentimentAnalysisAction
- where-model: SentimentAnalysisAction
transform:
$["x-ms-client-name"] = "SentimentAnalysisAction";
$.description = "Options for a sentiment analysis action.";
$.properties.opinionMining.description = "Enables performing opinion mining on the input documents, a more granular analysis around the aspects of a product or service (also known as aspect-based sentiment analysis). If set to true, {@link SentenceSentiment.opinions} will contain the results of this analysis. See {@link https://docs.microsoft.com/azure/cognitive-services/language-service/sentiment-opinion-mining/overview#opinion-mining the service documentation} for more information.";
$.properties.opinionMining["x-ms-client-name"] = "includeOpinionMining";
$.description = "Options for a sentiment analysis action.";
- from: swagger-document
where: $.definitions.KeyPhraseTaskParameters
- rename-model:
from: KeyPhraseTaskParameters
to: KeyPhraseExtractionAction
- where-model: KeyPhraseExtractionAction
transform:
$["x-ms-client-name"] = "KeyPhraseExtractionAction";
$.description = "Options for a key phrase recognition action.";
- from: swagger-document
where: $.definitions.PiiTaskParameters
- rename-model:
from: PiiTaskParameters
to: PiiEntityRecognitionAction
- where-model: PiiEntityRecognitionAction
transform:
$["x-ms-client-name"] = "PiiEntityRecognitionAction";
$.properties.domain.description = "Filters entities to ones only included in the specified domain (e.g., if set to `Phi`, only entities in the Protected Healthcare Information domain will be returned). For a list of possible domains, see {@link PiiDomain}.\n\nSee {@link https://aka.ms/tanerpii the service documentation} for more information.";
$.properties.domain["x-ms-client-name"] = "domainFilter";
$.description = "Options for a Pii entity recognition action.";
$.properties.domain.description = "Filters entities to ones only included in the specified domain (e.g., if set to `Phi`, only entities in the Protected Healthcare Information domain will be returned). For a list of possible domains, see {@link KnownPiiEntityDomain}.\n\nSee {@link https://aka.ms/tanerpii the service documentation} for more information.";
$.properties.piiCategories.description = "Filters entities to ones only included in the specified array of categories. For a list of possible categories, see {@link KnownPiiCategory}";
$.properties.domain["x-ms-client-name"] = "domainFilter";
$.properties.piiCategories["x-ms-client-name"] = "categoriesFilter";
$.description = "Options for a Pii entity recognition action."
- from: swagger-document
where: $.definitions.LanguageDetectionTaskParameters
- rename-model:
from: LanguageDetectionTaskParameters
to: LanguageDetectionAction
- where-model: LanguageDetectionAction
transform:
$["x-ms-client-name"] = "LanguageDetectionAction";
$.description = "Options for a language detection action.";
- from: swagger-document
where: $.definitions.HealthcareTaskParameters
- rename-model:
from: HealthcareTaskParameters
to: HealthcareAction
- rename-model:
from: ExtractiveSummarizationTaskParameters
to: ExtractiveSummarizationAction
- where-model: ExtractiveSummarizationAction
transform:
$["x-ms-client-name"] = "HealthcareAction";
- from: swagger-document
where: $.definitions.ExtractiveSummarizationTaskParameters
transform:
$["x-ms-client-name"] = "ExtractiveSummarizationAction";
$.properties.sentenceCount.description = "The max number of sentences to be part of the summary.";
$.properties.sentenceCount["x-ms-client-name"] = "maxSentenceCount";
$.properties.sortBy["x-ms-client-name"] = "orderBy";
- from: swagger-document
where: $.definitions.ExtractiveSummarizationSortingCriteria
- where-model: ExtractiveSummarizationSortingCriteria
transform:
$["x-ms-enum"].name = "ExtractiveSummarizationOrderingCriteria";
- from: swagger-document
where: $.definitions.CustomEntitiesTaskParameters
- rename-model:
from: CustomEntitiesTaskParameters
to: CustomEntityRecognitionAction
- rename-model:
from: CustomSingleLabelClassificationTaskParameters
to: CustomSingleLabelClassificationAction
- where-model: CustomSingleLabelClassificationAction
transform:
$["x-ms-client-name"] = "CustomEntityRecognitionAction";
- from: swagger-document
where: $.definitions.CustomSingleLabelClassificationTaskParameters
transform:
$["x-ms-client-name"] = "CustomSingleLabelClassificationAction";
$.description = "Options for a single-label classification custom action";
- from: swagger-document
where: $.definitions.CustomMultiLabelClassificationTaskParameters
- rename-model:
from: CustomMultiLabelClassificationTaskParameters
to: CustomMultiLabelClassificationAction
- where-model: CustomMultiLabelClassificationAction
transform:
$["x-ms-client-name"] = "CustomMultiLabelClassificationAction";
$.description = "Options for a multi-label classification custom action";
- from: swagger-document
where: $.definitions.TaskIdentifier
- rename-model:
from: TaskIdentifier
to: BatchActionState
- where-model: BatchActionState
transform:
$["x-ms-client-name"] = "BatchActionState";
$.description = "The State of a batched action";
$.properties.taskName.description = "The name of the action";
$.properties.taskName["x-ms-client-name"] = "actionName";
- from: swagger-document
where: $.definitions..properties.stringIndexType
transform: >
$.description = "Specifies the measurement unit used to calculate the offset and length properties. For a list of possible values, see {@link KnownStringIndexType}.\n\nThe default is the JavaScript's default which is \"Utf16CodeUnit\".";
```
### Rename HealthcareEntityLink => EntityDataSource
```yaml
directive:
- from: swagger-document
where: $.definitions.HealthcareEntityLink
- rename-model:
from: HealthcareEntityLink
to: EntityDataSource
- where-model: EntityDataSource
transform:
$["x-ms-client-name"] = "EntityDataSource";
$.description = "A type representing a reference for the healthcare entity into a specific entity catalog.";
$.properties.dataSource["x-ms-client-name"] = "name";
$.properties.id["x-ms-client-name"] = "entityId";
- from: swagger-document
where: $.definitions.HealthcareEntity.properties.links
transform: >
$["x-ms-client-name"] = "dataSources";
```
### Rename name to normalizedText
- where-model: HealthcareEntity
transform:
$.description = "A type representing a reference for the healthcare entity into a specific entity catalog.";
$.properties.links["x-ms-client-name"] = "dataSources";
$.properties.name["x-ms-client-name"] = "normalizedText";
```yaml
directive:
- from: swagger-document
where: $.definitions.HealthcareEntity.properties.name
transform: >
$["x-ms-client-name"] = "normalizedText";
```
### Add Entity to some Healthcare types
```yaml
directive:
- from: swagger-document
where: $.definitions.Assertion
transform: >
$["x-ms-client-name"] = "EntityAssertion";
- from: swagger-document
where: $.definitions.Conditionality
transform: >
$["x-ms-client-name"] = "EntityConditionality";
- from: swagger-document
where: $.definitions.HealthcareAssertion
- rename-model:
from: Assertion
to: EntityAssertion
- rename-model:
from: Conditionality
to: EntityConditionality
- where-model: HealthcareAssertion
transform: >
$.properties.certainty["x-ms-enum"]["name"] = "EntityCertainty";
$.properties.conditionality["x-ms-enum"]["name"] = "EntityConditionality";
$.properties.association["x-ms-enum"]["name"] = "EntityAssociation";
- from: swagger-document
where: $.definitions.Association
transform: >
$["x-ms-client-name"] = "EntityAssociation";
```
- rename-model:
from: Association
to: EntityAssociation
### Pii types renames
```yaml
directive:
- from: swagger-document
where: $.definitions.PiiDomain
- where-model: PiiDomain
transform: $["x-ms-enum"].name = "PiiEntityDomain";
- from: swagger-document
where: $.definitions.PiiCategories
- where-model: PiiCategories
transform: $.items["x-ms-enum"].name = "PiiEntityCategory";
```
### Rename class => classification
- where-model: SingleClassificationDocumentResult
transform: $.properties.class["x-ms-client-name"] = "classification";
- where-model: MultiClassificationDocumentResult
transform: $.properties.class["x-ms-client-name"] = "classifications";
- rename-model:
from: ClassificationResult
to: ClassificationCategory
- where-model: ClassificationCategory
transform: $.description = "A classification result from a custom classify document single category action";
```yaml
directive:
- from: swagger-document
where: $.definitions.SingleClassificationDocumentResult.properties.class
transform:
$["x-ms-client-name"] = "classification";
- from: swagger-document
where: $.definitions.MultiClassificationDocumentResult.properties.class
transform:
$["x-ms-client-name"] = "classifications";
- from: swagger-document
where: $.definitions.ClassificationResult
transform:
$["x-ms-client-name"] = "ClassificationCategory";
$.description = "A classification result from a custom classify document single category action";
```
### Set Utf16CodeUnit as the default for StringIndexType because this is what JavaScript uses
```yaml
directive:
- from: swagger-document
where: $.definitions.StringIndexType
transform: $.default = "Utf16CodeUnit";
```
### Rename plurals in DocumentStatistics
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentStatistics.properties.charactersCount
- where-model: DocumentStatistics
transform: >
$["x-ms-client-name"] = "characterCount";
```
$.properties.charactersCount["x-ms-client-name"] = "characterCount";
$.properties.transactionsCount["x-ms-client-name"] = "transactionCount";
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentStatistics.properties.transactionsCount
- where-model: LinkedEntity
transform: $.properties.bingId["x-ms-client-name"] = "bingEntitySearchApiId";
- where-model: RequestStatistics
transform: >
$["x-ms-client-name"] = "transactionCount";
```
$.properties.documentsCount["x-ms-client-name"] = "documentCount";
$.properties.validDocumentsCount["x-ms-client-name"] = "validDocumentCount";
$.properties.erroneousDocumentsCount["x-ms-client-name"] = "erroneousDocumentCount";
$.properties.transactionsCount["x-ms-client-name"] = "transactionCount";
### Rename BingId to bingEntitySearchApiId
```yaml
directive:
- from: swagger-document
where: $.definitions.LinkedEntity.properties.bingId
- where-model: DocumentSentiment
transform: $.properties.sentences["x-ms-client-name"] = "sentenceSentiments";
- rename-model:
from: SentenceAssessment
to: AssessmentSentiment
- where:-model: AssessmentSentiment
transform: >
$["x-ms-client-name"] = "bingEntitySearchApiId";
```
### Rename plurals in RequestStatistics
```yaml
directive:
- from: swagger-document
where: $.definitions.RequestStatistics.properties.documentsCount
transform: >
$["x-ms-client-name"] = "documentCount";
- from: swagger-document
where: $.definitions.RequestStatistics.properties.validDocumentsCount
transform: >
$["x-ms-client-name"] = "validDocumentCount";
- from: swagger-document
where: $.definitions.RequestStatistics.properties.erroneousDocumentsCount
transform: >
$["x-ms-client-name"] = "erroneousDocumentCount";
- from: swagger-document
where: $.definitions.RequestStatistics.properties.transactionsCount
transform: >
$["x-ms-client-name"] = "transactionCount";
```
### sentences => sentenceSentiments
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentSentiment.properties.sentences
transform: >
$["x-ms-client-name"] = "sentenceSentiments";
```
### SentenceAssessment to AssessmentSentiment
```yaml
directive:
- from: swagger-document
where: $.definitions.SentenceAssessment
transform: >
$["x-ms-client-name"] = "AssessmentSentiment";
$.description = "AssessmentSentiment contains the predicted sentiment, confidence scores and other information about an assessment of a target. For example, in the sentence \"The food is good\", the assessment of the target 'food' is 'good'.";
```
### DocumentStatistics => TextDocumentStatistics
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentStatistics
transform: >
$["x-ms-client-name"] = "TextDocumentStatistics";
```
### RequestStatistics => TextDocumentBatchStatistics
```yaml
directive:
- from: swagger-document
where: $.definitions.RequestStatistics
transform: >
$["x-ms-client-name"] = "TextDocumentBatchStatistics";
```
### Rename showStats -> includeStatistics
```yaml
directive:
- rename-model:
from: DocumentStatistics
to: TextDocumentStatistics
- rename-model:
from: RequestStatistics
to: TextDocumentBatchStatistics
- from: swagger-document
where: $.parameters.ShowStats
transform: >
$["x-ms-client-name"] = "includeStatistics";
- from: swagger-document
where: $.definitions[*]
transform: >
if ($.description && $.description.includes("showStats")) {
$.description = $.description.replace("showStats", "includeStatistics");
}
```
### Rename {Document,Sentence,Token}SentimentValue -> Label
```yaml
directive:
- from: swagger-document
where: $.definitions.SentimentDocumentResult.properties.sentiment
transform: >
@ -389,56 +241,31 @@ directive:
transform: >
$["x-ms-enum"].name = "TokenSentimentLabel";
- from: swagger-document
where: $.definitions.SentenceAssessment.properties.sentiment
where: $.definitions.AssessmentSentiment.properties.sentiment
transform: >
$["x-ms-enum"].name = "TokenSentimentLabel";
```
### Rename LinkedEntity id -> dataSourceEntityId
```yaml
directive:
- from: swagger-document
where: $.definitions.LinkedEntity.properties.id
transform: >
$["x-ms-client-name"] = "dataSourceEntityId";
```
### Rename SentimentConfidenceScorePerLabel -> SentimentConfidenceScores
```yaml
directive:
- from: swagger-document
where: $.definitions.SentimentConfidenceScorePerLabel
transform: >
$["x-ms-client-name"] = "SentimentConfidenceScores";
```
### Rename TargetConfidenceScoreLabel -> TargetConfidenceScores
```yaml
directive:
- from: swagger-document
where: $.definitions.TargetConfidenceScoreLabel
transform: >
$["x-ms-client-name"] = "TargetConfidenceScores";
```
### ExtractedSummarySentence to SummarySentence
```yaml
directive:
- from: swagger-document
where: $.definitions.ExtractedSummarySentence
transform: >
$["x-ms-client-name"] = "SummarySentence";
$.description = "A sentence that is part of the extracted summary.";
```
### Change some casing to use camelCase
```yaml
directive:
- from: swagger-document
where: $.definitions.Entity.properties.subcategory
transform: >
@ -447,32 +274,17 @@ directive:
where: $.definitions.HealthcareEntity.properties.subcategory
transform: >
$["x-ms-client-name"] = "subCategory";
```
### WarningCodeValue => WarningCode
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentWarning.properties.code
transform: >
$["x-ms-enum"].name = "WarningCode";
```
### Remove targetRef
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentWarning.properties
transform: >
delete $["targetRef"];
```
### Rename text input objects to avoid "export as"
```yaml
directive:
- from: swagger-document
where: $.definitions
transform: >
@ -495,27 +307,25 @@ directive:
where: $.definitions.LanguageDetectionAnalysisInput.properties.documents.items
transform: >
$["$ref"] = "#/definitions/LanguageDetectionInput";
```
### Disable LRO
```yaml
directive:
- from: swagger-document
where: $["paths"][*]
transform: >
for (var op of Object.values($)) {
if (op["x-ms-long-running-operation"]) {
delete op["x-ms-long-running-operation"];
}
}
```
where: $.definitions.JobState
transform: $.properties.jobId["x-ms-client-name"] = "id";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.status["x-ms-enum"].name = "OperationStatus";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.createdDateTime["x-ms-client-name"] = "createdOn";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.expirationDateTime["x-ms-client-name"] = "expiresOn";
- from: swagger-document
where: $.definitions.JobState
transform: $.properties.lastUpdatedDateTime["x-ms-client-name"] = "modifiedOn";
### Enhance documentation strings for some exported swagger types
# Enhance documentation strings for some exported swagger types
```yaml
directive:
- from: swagger-document
where: $.definitions.DocumentWarning
transform: $.description = "Represents a warning encountered while processing a document."
@ -544,9 +354,36 @@ directive:
where: $.definitions.DetectedLanguage
transform: $.description = "Information about the language of a document as identified by the Language service."
- from: swagger-document
where: $.definitions.SentenceAssessment
where: $.definitions.AssessmentSentiment
transform: $.description = "An object that contains the predicted sentiment, confidence scores and other information about an assessment of a target. For example, in the sentence \"The food is good\", the assessment of the target 'food' is 'good'."
- from: swagger-document
where: $.definitions.HealthcareAssertion
transform: $.description = "An object that describes metadata about the healthcare entity such as whether it is hypothetical or conditional.";
```
## JS customizations
```yaml
directive:
- from: swagger-document
where: $.definitions..properties.stringIndexType
transform: >
$.description = "Specifies the measurement unit used to calculate the offset and length properties. For a list of possible values, see {@link KnownStringIndexType}.\n\nThe default is the JavaScript's default which is \"Utf16CodeUnit\".";
# Set Utf16CodeUnit as the default for StringIndexType because this is what JavaScript uses
- from: swagger-document
where: $.definitions.StringIndexType
transform: $.default = "Utf16CodeUnit";
# Disable LRO
- from: swagger-document
where: $["paths"][*]
transform: >
for (var op of Object.values($)) {
if (op["x-ms-long-running-operation"]) {
delete op["x-ms-long-running-operation"];
}
}
```