Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Update splitted operation description if it is create or update (#95)
Browse files Browse the repository at this point in the history
* Update splitted operation description if it is create or update

* fix lint

Co-authored-by: Xiao Chen <[email protected]>
  • Loading branch information
shawncx and msxichen authored Oct 14, 2020
1 parent 1c91fbf commit 293bdc4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/plugins/splitOperation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Host, Session, startSession } from "@azure-tools/autorest-extension-base";
import { CodeModel, Operation, codeModelSchema } from "@azure-tools/codemodel";
import { CodeModel, Operation, codeModelSchema, OperationGroup } from "@azure-tools/codemodel";
import { Helper } from "../helper";
import { CliConst, CliCommonSchema } from "../schema";
import { NodeCliHelper, NodeExtensionHelper } from "../nodeHelper";
Expand Down Expand Up @@ -30,7 +30,8 @@ export class SplitOperation{
splittedOperations.forEach((splittedOperation) => {
// Link splitted operation to src opreation
NodeExtensionHelper.setSplitOperationOriginalOperation(splittedOperation, operation);


this.updateSplitOperationDescription(splittedOperation, group);
splittedGroupOperations.push(splittedOperation);
});

Expand All @@ -42,6 +43,22 @@ export class SplitOperation{
}
}

private updateSplitOperationDescription(operation: Operation, group: OperationGroup): void {
const create = 'Create';
const update = 'Update';
const opCliKey = NodeCliHelper.getCliKey(operation, '').toLowerCase();
const createOrUpdate: string = opCliKey.endsWith('#create') ? create : opCliKey.endsWith('#update') ? update : null;
if (!createOrUpdate) {
return;
}

const groupCliKey = NodeCliHelper.getCliKey(group, '');
const namingConvention: CliCommonSchema.NamingConvention = {
glossary: []
};
operation.language.default.description = createOrUpdate + ' ' + Helper.singularize(namingConvention, groupCliKey);
}

private async modifier(): Promise<void> {
const directives = (await this.session.getValue(CliConst.CLI_DIRECTIVE_KEY, []))
.filter((dir) => dir[NodeCliHelper.SPLIT_OPERATION_NAMES])
Expand Down

0 comments on commit 293bdc4

Please sign in to comment.