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 AddParameterRefs(TSObject operationSpec, string propertyName, IEnumerable <Parameter> requestParameters) { if (requestParameters != null && requestParameters.Any()) { operationSpec.ArrayProperty(propertyName, parameterArray => { foreach (ParameterTS requestParameter in requestParameters) { parameterArray.Value(v => v.Text("Parameters." + requestParameter.MapperName)); } }); } }
private static void GenerateParameters(TSObject operationSpec, string propertyName, IEnumerable <Parameter> parameters, Action <TSObject, Parameter> extraParameterProperties = null) { if (parameters != null && parameters.Any()) { operationSpec.ArrayProperty(propertyName, parameterArray => { foreach (ParameterTS parameter in parameters) { parameterArray.Object(parameterObject => { parameterObject.QuotedStringProperty("parameterName", parameter.Name); extraParameterProperties?.Invoke(parameterObject, parameter); parameterObject.Property("mapper", mapper => ClientModelExtensions.ConstructMapper(mapper, parameter.ModelType, parameter.SerializedName, parameter, false, false, false)); }); } }); } }