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

Improve SDK Type Inference in SDK Automation #9603

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wanlwanl
Copy link
Member

@wanlwanl wanlwanl commented Jan 8, 2025

Fix: #9520
Problem: Service team doesn't set isModularClientLibrary explicitly, we can improve user experience by inferencing sdk type automatically
Solution: add the Inference flow below

if (generateByTypeSpec) {
    if (isModularLibrary !== undefined) return options.isModularLibrary ? isModular : isRLC;
    if (flavor === "azure") {
        if (namespace.includes("Management")) { // MPG
            return isModular; // by default
        } else return isRLC; // DPG
    } else { // unbranded
        return isModular; // by default
    }
} else { // generate by autorest
    // original behavior
    if (hasIsRestLevelClientOption) return isRLC;
    return isHLC;
}

@wanlwanl wanlwanl marked this pull request as draft January 8, 2025 08:31
@wanlwanl wanlwanl marked this pull request as ready for review January 9, 2025 05:03
// NOTE: unbranded sdk will generate modular client bt default
if (!isAzureSDK) return SDKType.ModularClient;

const isManagementPlane = new RegExp(/\.Management[\/\\]?$/).test(
Copy link
Member

@MaryGao MaryGao Jan 9, 2025

Choose a reason for hiding this comment

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

I was wondering if we still need this, we already adopted default behavior(but not released yet) in codegen side: Azure/autorest.typescript#2973.

Copy link
Member Author

Choose a reason for hiding this comment

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

If so, we don't need to check it.
However, we have an independent changelog generation tool. GetSDKType() will be used to bump version - need to find api-version type (stable or preview) based on different client type. I'm wondering if codegen side can add 'api-version' into package.json or somewhere else, then I don't need the check of 'management' any more.

Copy link
Member

@MaryGao MaryGao Jan 9, 2025

Choose a reason for hiding this comment

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

Maybe we could directly refer the package name: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.Management/tspconfig.yaml#L39.

Starting with @azure would be Modular and starting with @azure-rest would be RLC.

I'm wondering if codegen side can add 'api-version' into package.json or somewhere else

I may not get your point, the api-version is the package version or spec version? We have an issue to list all service apiVersion in README: Azure/autorest.typescript#2588.

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