public override void Remove(Parameter item) { base.Remove(item); // find a Property in OptionsParameterModelType with the same name and remove it. OptionsParameterModelType.Remove(prop => prop.Name == item.Name); }
/// <summary> /// Format the value of a sequence given the modeled element format. Note that only sequences of strings are supported /// </summary> /// <param name="parameter">The parameter to format</param> /// <returns>return the separator</returns> public static string NeedsFormattedSeparator(Parameter parameter) { if (parameter == null) { throw new ArgumentNullException("parameter"); } SequenceType sequence = parameter.ModelType as SequenceType; if (sequence == null) { return null; } PrimaryType primaryType = sequence.ElementType as PrimaryType; EnumType enumType = sequence.ElementType as EnumType; if (enumType != null) { primaryType = New<PrimaryType>(KnownPrimaryType.String); } if (primaryType != null && primaryType.KnownPrimaryType != KnownPrimaryType.String) { throw new InvalidOperationException( string.Format(CultureInfo.InvariantCulture, "Cannot generate a formatted sequence from a " + "non-string array parameter {0}", parameter)); } return parameter.CollectionFormat.GetSeparator(); }
private static Property CreateParameterGroupProperty(Parameter parameter) { Property groupProperty = New<Property>(new { IsReadOnly = false, //Since these properties are used as parameters they are never read only Name = parameter.Name, IsRequired = parameter.IsRequired, DefaultValue = parameter.DefaultValue, //Constraints = parameter.Constraints, Omit these since we don't want to perform parameter validation Documentation = parameter.Documentation, ModelType = parameter.ModelType, SerializedName = default(string) //Parameter is never serialized directly }); // Copy over extensions foreach (var key in parameter.Extensions.Keys) { groupProperty.Extensions[key] = parameter.Extensions[key]; } return groupProperty; }
public override Parameter Add(Parameter item) { var parameter = base.Add(item) as ParameterJs; if (parameter.IsLocal && !parameter.IsRequired) { OptionsParameterModelType.Add(New<Core.Model.Property>(new { IsReadOnly = false, Name = parameter.Name, IsRequired = parameter.IsRequired, DefaultValue = parameter.DefaultValue, Documentation = parameter.Documentation, ModelType = parameter.ModelType, SerializedName = parameter.SerializedName, Constraints = parameter.Constraints, // optionalProperty.Constraints.AddRange(parameter.Constraints); Extensions = parameter.Extensions // optionalProperty.Extensions.AddRange(parameter.Extensions); })); } return parameter; }
private static string GetParameterGroupName(string methodGroupName, string methodName, Parameter parameter) { if (parameter.Extensions.ContainsKey(SwaggerExtensions.ParameterGroupExtension)) { JContainer extensionObject = parameter.Extensions[SwaggerExtensions.ParameterGroupExtension] as JContainer; if (extensionObject != null) { string specifiedGroupName = extensionObject.Value<string>("name"); string parameterGroupName; if (specifiedGroupName == null) { string postfix = extensionObject.Value<string>("postfix") ?? "Parameters"; parameterGroupName = methodGroupName + "-" + methodName + "-" + postfix; } else { parameterGroupName = specifiedGroupName; } return parameterGroupName; } } return null; }
public virtual void Remove(Parameter item) { _parameters.Remove(item); }
public virtual Parameter Insert(Parameter item) { if( !_parameters.Contains(item)) { // disambiguation is performed when the item's parent reference is changed item.Method = this; _parameters.Insert(0, item); } return item; }
partial void BeforeAdd(Parameter item);
/// <summary> /// Provides the parameter documentation string. /// </summary> /// <param name="parameter">Parameter to be documented</param> /// <returns>Parameter documentation string correct notation</returns> public static string GetParameterDocumentationString(Parameter parameter) { if (parameter == null) { throw new ArgumentNullException("parameter"); } string docString = ":param "; docString += parameter.Name + ":"; if (!string.IsNullOrWhiteSpace(parameter.Documentation)) { docString += " " + parameter.Documentation; } return docString; }
private string BuildSerializeDataCall(Parameter parameter, string functionName) { string divChar = ClientModelExtensions.NeedsFormattedSeparator(parameter); string divParameter = string.Empty; string parameterName = (MethodGroup as MethodGroupPy)?.ConstantProperties?.FirstOrDefault(each => each.Name.RawValue == parameter.Name.RawValue && each.DefaultValue.RawValue == parameter.DefaultValue.RawValue)?.Name.Else(parameter.Name) ?? parameter.Name; if (!string.IsNullOrEmpty(divChar)) { divParameter = string.Format(CultureInfo.InvariantCulture, ", div='{0}'", divChar); } //TODO: This creates a very long line - break it up over multiple lines. return string.Format(CultureInfo.InvariantCulture, "self._serialize.{0}(\"{1}\", {1}, '{2}'{3}{4}{5})", functionName, parameterName, parameter.ModelType.ToPythonRuntimeTypeString(), parameter.SkipUrlEncoding() ? ", skip_quote=True" : string.Empty, divParameter, BuildValidationParameters(parameter.Constraints)); }
public static string GetParameterDocumentationType(Parameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } string typeName = "object"; if (parameter.ModelType is PrimaryTypeJs) { typeName = parameter.ModelType.Name; } else if (parameter.ModelType is Core.Model.SequenceType) { typeName = "array"; } else if (parameter.ModelType is EnumType) { typeName = "string"; } return typeName.ToLower(CultureInfo.InvariantCulture); }
/// <summary> /// Provides the parameter name in the correct jsdoc notation depending on /// whether it is required or optional /// </summary> /// <param name="parameter">Parameter to be documented</param> /// <returns>Parameter name in the correct jsdoc notation</returns> public static string GetParameterDocumentationName(Parameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } if (parameter.IsRequired) { return parameter.Name; } else { return string.Format(CultureInfo.InvariantCulture, "[{0}]", parameter.Name); } }