-
Notifications
You must be signed in to change notification settings - Fork 169
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(dpg): protocol/convenience method parameters should order by default value #2769
Conversation
…ult value - fix the sequence of parameters not sorted by default value (e.g. optional parameters should be at the end) - fix a method access privilege - regen samples & tests fix Azure#2766
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The bug happens in Probably we should add another parameter to the private void AddUriOrPathParameters(string uriPart, IReadOnlyDictionary<string, InputParameter> requestParameters, bool addRequiredParameters)
{
foreach ((ReadOnlySpan<char> span, bool isLiteral) in StringExtensions.GetPathParts(uriPart))
{
if (isLiteral)
{
continue;
}
var text = span.ToString();
if (requestParameters.TryGetValue(text, out var requestParameter))
{
var isRequired = requestParameter.IsRequired && requestParameter.DefaultValue == null;
if (addRequiredParameters == isRequired)
{
AddParameter(text, requestParameter);
}
}
else
{
ErrorHelpers.ThrowError($"\n\nError while processing request '{uriPart}'\n\n '{text}' in URI is missing a matching definition in the path parameters collection{ErrorHelpers.UpdateSwaggerOrFile}");
}
}
} and then used in AddWaitForCompletion();
AddUriOrPathParameters(Operation.Uri, pathParameters, true);
AddUriOrPathParameters(Operation.Path, pathParameters, true);
AddQueryOrHeaderParameters(requiredRequestParameters);
AddBody(bodyParameter, contentTypeRequestParameter);
AddUriOrPathParameters(Operation.Uri, pathParameters, false);
AddUriOrPathParameters(Operation.Path, pathParameters, false);
AddQueryOrHeaderParameters(optionalRequestParameters);
AddRequestConditionHeaders(requestConditionHeaders, requestConditionRequestParameter, requestConditionSerializationFormat);
AddRequestContext();
The order itself is defined here: #1765 (comment) One last comment is about the test project. Every separate test project increases build time and makes it harder to find correct test. If there is existing test project that handles similar cases, please add new case there instead of creating new test. |
@m-nash: Would you please take a look at the feedback from Alex and offer your thoughts? |
Let me revive this PR which meant to codify this Azure/azure-sdk#4385. We have had agreement on this ordering in the past but its very loosely documented in many different places |
@AlexanderSher Thank you very much! I've composed another PR to resolve this issue, according to your suggestion: #2779 |
fix #2766
Description
Add your description here!
Checklist
To ensure a quick review and merge, please ensure:
Ready to Land?