/// <summary> /// Provides the property documentation string along with default value if any. /// </summary> /// <param name="property">Parameter to be documented</param> /// <returns>Parameter documentation string along with default value if any /// in correct jsdoc notation</returns> public static string GetPropertyDocumentationString(Property property) { if (property == null) { throw new ArgumentNullException("property"); } string docString = ":param "; docString += ModelTemplateModel.GetPropertyDocumentationType(property); docString += " " + property.Name + ":"; string documentation = property.Documentation; if (!string.IsNullOrWhiteSpace(property.DefaultValue)) { if (documentation != null && !documentation.EndsWith(".", StringComparison.OrdinalIgnoreCase)) { documentation += "."; } documentation += " Default value: " + property.DefaultValue + " ."; } if (!string.IsNullOrWhiteSpace(documentation)) { docString += " " + documentation; } return(docString); }
public ModelTemplateModel(CompositeType source, ServiceClient serviceClient) { if (!string.IsNullOrEmpty(source.PolymorphicDiscriminator)) { if (!source.Properties.Any(p => p.Name == source.PolymorphicDiscriminator)) { var polymorphicProperty = new Property { IsRequired = true, Name = source.PolymorphicDiscriminator, SerializedName = source.PolymorphicDiscriminator, Documentation = "Polymorphic Discriminator", Type = new PrimaryType(KnownPrimaryType.String) { Name = "str" } }; source.Properties.Add(polymorphicProperty); } } this.LoadFrom(source); ServiceClient = serviceClient; if (ServiceClient.ErrorTypes.Contains(source)) { _isException = true; } if (source.BaseModelType != null) { _parent = new ModelTemplateModel(source.BaseModelType, serviceClient); } foreach (var property in ComposedProperties) { if (string.IsNullOrWhiteSpace(property.DefaultValue)) { property.DefaultValue = PythonConstants.None; } } if (this.IsPolymorphic) { foreach (var modelType in ServiceClient.ModelTypes) { if (modelType.BaseModelType == source) { _subModelTypes.Add(modelType); } } } }