Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sample generation for several mgmt plane RPs #1289

Merged
merged 19 commits into from
Feb 17, 2022

Conversation

qiaozha
Copy link
Member

@qiaozha qiaozha commented Jan 25, 2022

This PR is trying to fix several issues for mgmt plane RPs.

  1. We are not handle number/boolean type constant or single value number/boolean enum correctly.
  2. In sample generation, if we don't add type cast logic, it will complain about imcompatible issue,
  3. In sample generation, iwe don't add the logic for reserved words in the parameter, For example type => typeParam, default => defaultParam

@joheredi
Copy link
Member

Can you please add a description about what's the problem and how are you fixing it? It is very difficult to make sense of a PR without proper description

@qiaozha qiaozha changed the title Fix sample generation for netapp Fix sample generation for several mgmt plane RPs Jan 28, 2022
@qiaozha
Copy link
Member Author

qiaozha commented Jan 28, 2022

@joheredi I have updated the description for this PR. Could you take a look again ?

package.json Outdated Show resolved Hide resolved
Copy link
Member

@joheredi joheredi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer the approval to @sarangan12, from my side, I'd like the unnecessary cast to be removed.

@qiaozha
Copy link
Member Author

qiaozha commented Feb 17, 2022

I think all the comments from @joheredi should have been resolved. Feel free to comment or correct me if it's not. Thanks
@sarangan12 Could you also take a look ? Thanks

@qiaozha qiaozha merged commit 79e4439 into Azure:main Feb 17, 2022
@@ -8,8 +8,10 @@
* x-ms-original-file: {{originalFileLocation}}
*/
import {
{{#if hasBody }}
{{bodySchemaName}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't use these two columns does that mean we could delete them in model and transform.ts?

@@ -15,4 +15,6 @@ export interface SampleDetails {
isTopLevel: boolean,
isPaging: boolean,
originalFileLocation?: string
isAnyTypeBody?: boolean,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice any usage for this column - isAnyTypeBody, does that mean we could delete it?

@@ -18,6 +18,8 @@ import { calculateMethodName } from "../generators/utils/operationsUtils";
import { camelCase } from "@azure-tools/codegen";
import { OperationGroupDetails } from "../models/operationDetails";
import { getPublicMethodName } from '../generators/utils/pagingOperations';
import { BodiedNode } from "ts-morph";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No usage delete this import?

sample.importedTypes?.push(parameterTypeName);
if (methodParameter.exampleValue.schema.type === SchemaType.AnyObject || methodParameter.exampleValue.schema.type === SchemaType.Any) {
sample.bodySchemaName = "Record<string, unknown>"
sample.isAnyTypeBody = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We re-correct the value of bodySchemaName & isAnyTypeBody but we didn't put the latest into importedTypes list or any usage directly, do we need to refine this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants