in src/TemplateRefGenerator/Generators/MarkdownGenerator.cs [719:756]
private static string JoinWithBr(IEnumerable<string> values)
=> string.Join(Br, values);
private static string JoinWithBr(params string[] values)
=> JoinWithBr(values as IEnumerable<string>);
private static string GetTypeValue(TypeBase type, int anchorIndex)
{
switch (type)
{
case UnionType unionType when unionType.Elements.Select(x => x.Type).OfType<StringLiteralType>() is {} elements:
return JoinWithBr(elements.Select(GetTypeValue).OrderBy(x => x, StringComparer.OrdinalIgnoreCase));
case StringLiteralType stringLiteral:
return $"'{stringLiteral.Value}'";
case IntegerType intType:
var intConstraints = GetConstraintText(intType);
return $"int{intConstraints}";
case BooleanType:
return "bool";
case AnyType anyType:
return "any";
case StringType stringType:
var stringConstraints = GetConstraintText(stringType);
return $"string{stringConstraints}";
case ObjectType objectType:
var anchorSuffixO = anchorIndex > 0 ? $"-{anchorIndex}" : "";
return MarkdownUtils.GetLink(objectType.Name, MarkdownUtils.GetDocAnchor($"{objectType.Name}{anchorSuffixO}"));
case DiscriminatedObjectType objectType:
var anchorSuffixDo = anchorIndex > 0 ? $"-{anchorIndex}" : "";
return MarkdownUtils.GetLink(objectType.Name, MarkdownUtils.GetDocAnchor($"{objectType.Name}{anchorSuffixDo}"));
case ArrayType arrayType when arrayType.ItemType.Type is UnionType:
return $"String array containing any of:{Br}{GetTypeValue(arrayType.ItemType.Type, anchorIndex)}";
case ArrayType arrayType:
return $"{GetTypeValue(arrayType.ItemType.Type, anchorIndex)}[]";
default:
throw new NotImplementedException($"Type {type.GetType()} not implemented");
}
}