in src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/DocumentHelper.cs [131:179]
public Dictionary<string, OpenApiSchema> GetOpenApiSchemas(List<MethodInfo> elements, NamingStrategy namingStrategy, VisitorCollection collection)
{
var requests = elements.SelectMany(p => p.GetCustomAttributes<OpenApiRequestBodyAttribute>(inherit: false))
.Select(p => p.BodyType);
var responses = elements.SelectMany(p => p.GetCustomAttributes<OpenApiResponseWithBodyAttribute>(inherit: false))
.Select(p => p.BodyType);
var types = requests.Union(responses)
.Select(p => p.IsOpenApiArray() || p.IsOpenApiDictionary() ? p.GetOpenApiSubType() : p)
.Distinct()
.Where(p => !p.IsSimpleType())
.Where(p => p.IsReferentialType())
.Where(p => !typeof(Array).IsAssignableFrom(p))
.ToList();
var rootSchemas = new Dictionary<string, OpenApiSchema>();
var schemas = new Dictionary<string, OpenApiSchema>();
var acceptorTypes = new Dictionary<string, Type>();
foreach (var type in types)
{
var openApiReferenceId = type.GetOpenApiReferenceId(type.IsOpenApiDictionary(), type.IsOpenApiArray(), namingStrategy);
if (!acceptorTypes.ContainsKey(openApiReferenceId))
{
acceptorTypes.Add(openApiReferenceId, type);
}
}
this._acceptor.Types = acceptorTypes;
this._acceptor.RootSchemas = rootSchemas;
this._acceptor.Schemas = schemas;
this._acceptor.Accept(collection, namingStrategy);
var union = schemas.Concat(rootSchemas.Where(p => !schemas.Keys.Contains(p.Key)))
.Distinct()
.Where(p => p.Key.ToUpperInvariant() != "OBJECT")
.OrderBy(p => p.Key)
.ToDictionary(p => p.Key,
p =>
{
// Title was intentionally added for schema key.
// It's not necessary when it's added to the root schema.
// Therefore, it's removed.
p.Value.Title = null;
return p.Value;
});
return union;
}