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

[http-client-csharp]: Fix explode not being properly set for operation params #5396

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

Conversation

jorgerangel-msft
Copy link
Contributor

@jorgerangel-msft jorgerangel-msft commented Dec 17, 2024

This PR fixes an issue where the explode flag for a operation parameter was not being properly set when uri templates were specified. This is fixed now by passing through the value of explode from TCGC.

There are several follow ups that are still needed to fully support URI templates and path expansion.

fixes: #5134
regen preview for autorest: Azure/azure-sdk-for-net#47775

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Dec 17, 2024
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

Copy link
Member

@ArcturusZhang ArcturusZhang left a comment

Choose a reason for hiding this comment

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

In general, our definition of the parameter is quite cumbersome - all the parameters are sharing the same InputParameter model.
We should follow the definition of TCGC (they have discriminated models for each type of parameters) - @m_nash had the vision that our emitter should just redirect the data from TCGC therefore aligning their models on our side should be the first step.

But changing it is extremely complicated and we do not have to do it in this PR.
If you have further questions on how explode works, I think you could offline chat with @tadelesh

@jorgerangel-msft jorgerangel-msft marked this pull request as ready for review January 9, 2025 23:23
@@ -421,3 +426,7 @@ function normalizeHeaderName(name: string): string {
return name;
}
}

function isExplodedParameter(p: SdkHttpParameter): boolean {
return (p.kind === "path" || p.kind === "query") && p.explode === true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not care about the multi format anymore? I'm curious why we can't just use p.explode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the multi check based on this feedback. The explode property only exists for these interfaces SdkQueryParameter and SdkPathParameter so we still need a check to see if the parameter type implements either to reference that property. At least that is my rusty understanding 😃

@@ -187,6 +187,11 @@ function fromSdkHttpOperationParameter(
const format = p.kind === "header" || p.kind === "query" ? p.collectionFormat : undefined;
const serializedName = p.kind !== "body" ? p.serializedName : p.name;

// TO-DO: In addition to checking if a path parameter is exploded, we should consider capturing the style for
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify what is meant by "style"? Also, can we file an issue for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I'm referring to the delimiter. I've updated the comment accordingly. Here is a chart for reference of what's supported through uri templates. I have also filed #5561 to track this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cadl-Ranch scenario - Explode parameter is always false even when it should be true
4 participants