public void GenerateOperationArguments(TSObject operationArguments) { ParameterTransformations transformations = GetParameterTransformations(); // Remember that Parameters contains the parameters of the REST API method, not the // generated method. foreach (Parameter parameter in Parameters) { if (parameter.IsRequired && !parameter.IsConstant && !parameter.IsClientProperty && !operationArguments.ContainsProperty(parameter.Name) && !transformations.IsCreatedFromTransformation(parameter.Name) && parameter.Name != "options") { operationArguments.TextProperty(parameter.Name, parameter.Name); } } operationArguments.TextProperty("options", "options"); }
private static void GenerateRequestParameterPath(TSObject parent, string propertyName, string parameterName, bool parameterInOptions, ParameterTransformations parameterTransformations) { if (!parameterTransformations.IsCreatedFromTransformation(parameterName)) { if (parameterInOptions || parameterTransformations.InputParameterInOptions(parameterName)) { parent.QuotedStringArrayProperty(propertyName, new string[] { "options", parameterName }); } else { parent.QuotedStringProperty(propertyName, parameterName); } } else if (parameterTransformations.IsUnflattenedVariable(parameterName)) { // Unflattening parent.ObjectProperty(propertyName, parameterPathObject => { IDictionary <string, string> unflattenedPropertyMappings = parameterTransformations.GetUnflattenedParameterPropertyMappings(parameterName); foreach (KeyValuePair <string, string> unflattenedPropertyMapping in unflattenedPropertyMappings) { string unflattenedPropertyName = unflattenedPropertyMapping.Key; string inputParameterName = unflattenedPropertyMapping.Value; bool inputParameterInOptions = parameterTransformations.InputParameterInOptions(inputParameterName); GenerateRequestParameterPath(parameterPathObject, unflattenedPropertyName, inputParameterName, inputParameterInOptions, parameterTransformations); } }); } else { // Ungrouping string[] inputParameterPath = parameterTransformations.GetUngroupedParameterPath(parameterName); string inputParameterPathFirstPart = inputParameterPath[0]; bool inputParameterInOptions = parameterTransformations.InputParameterInOptions(inputParameterPathFirstPart); if (inputParameterPath.Length == 1) { GenerateRequestParameterPath(parent, propertyName, inputParameterPath[0], inputParameterInOptions, parameterTransformations); } else { parent.ArrayProperty(propertyName, array => { if (inputParameterInOptions) { array.QuotedString("options"); } foreach (string inputParameterPathPart in inputParameterPath) { array.QuotedString(inputParameterPathPart); } }); } } }
private static void GenerateRequestParameterPath(TSObject parent, Parameter requestParameter, ParameterTransformations parameterTransformations) { GenerateRequestParameterPath(parent, "parameterPath", requestParameter.Name, !requestParameter.IsClientProperty && !requestParameter.IsRequired, parameterTransformations); }
internal static void GenerateRequestParameter(TSObject parameterObject, ParameterTS requestParameter, ParameterTransformations parameterTransformations) { GenerateRequestParameterPath(parameterObject, requestParameter, parameterTransformations); parameterObject.Property("mapper", mapper => ClientModelExtensions.ConstructMapper(mapper, requestParameter.ModelType, requestParameter.SerializedName, requestParameter, false, false, false)); ParameterLocation location = requestParameter.Location; if (location == ParameterLocation.Path || location == ParameterLocation.Query) { AddSkipEncodingProperty(parameterObject, requestParameter); } if (location == ParameterLocation.Query) { if (requestParameter.CollectionFormat != CollectionFormat.None) { parameterObject.TextProperty("collectionFormat", $"msRest.QueryCollectionFormat.{requestParameter.CollectionFormat}"); } } }