Esempio n. 1
0
 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);
                 }
             });
         }
     }
 }
Esempio n. 2
0
        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");
        }