25 lines
940 B
C#
25 lines
940 B
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using Microsoft.AspNet.Mvc.ApplicationModels;
|
|
|
|
namespace ApiExplorerWebSite
|
|
{
|
|
// Enables ApiExplorer for controllers that haven't explicitly configured it.
|
|
// This is part of the test that validates that ApiExplorer can be configured via
|
|
// convention
|
|
public class ApiExplorerVisibilityEnabledConvention : IApplicationModelConvention
|
|
{
|
|
public void Apply(ApplicationModel application)
|
|
{
|
|
foreach (var controller in application.Controllers)
|
|
{
|
|
if (controller.ApiExplorer.IsVisible == null)
|
|
{
|
|
controller.ApiExplorer.IsVisible = true;
|
|
controller.ApiExplorer.GroupName = controller.ControllerName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |