in src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/StringEnumTypeVisitor.cs [39:82]
public override void Visit(IAcceptor acceptor, KeyValuePair<string, Type> type, NamingStrategy namingStrategy, params Attribute[] attributes)
{
var name = type.Key;
var instance = acceptor as OpenApiSchemaAcceptor;
if (instance.IsNullOrDefault())
{
return;
}
// Adds enum values to the schema.
var enums = type.Value.ToOpenApiStringCollection();
var schema = new OpenApiSchema()
{
Type = "string",
Format = null,
Enum = enums,
Default = enums.First()
};
// Adds the extra properties.
if (attributes.Any())
{
Attribute attr = attributes.OfType<OpenApiPropertyAttribute>().SingleOrDefault();
if (!attr.IsNullOrDefault())
{
schema.Nullable = this.GetOpenApiPropertyNullable(attr as OpenApiPropertyAttribute);
schema.Default = this.GetOpenApiPropertyDefault<string>(attr as OpenApiPropertyAttribute);
schema.Description = this.GetOpenApiPropertyDescription(attr as OpenApiPropertyAttribute);
schema.Deprecated = this.GetOpenApiPropertyDeprecated(attr as OpenApiPropertyAttribute);
}
attr = attributes.OfType<OpenApiSchemaVisibilityAttribute>().SingleOrDefault();
if (!attr.IsNullOrDefault())
{
var extension = new OpenApiString((attr as OpenApiSchemaVisibilityAttribute).Visibility.ToDisplayName());
schema.Extensions.Add("x-ms-visibility", extension);
}
}
instance.Schemas.Add(name, schema);
}