My Project is a Web API Application with .NET Framework 4.5.2
SwaggerConfig.cs
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace MyAPI
{
public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyAPI");
c.CustomProvider((defaultProvider) => new ODataSwaggerProvider(defaultProvider, c, GlobalConfiguration.Configuration).Configure(odataConfig =>
{
odataConfig.IncludeNavigationProperties();
}));
})
.EnableSwaggerUi();
}
}
}
Response api/swagger/docs/v1:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Falha na precondição: currentProperty != null</ExceptionMessage>
<ExceptionType>
System.Diagnostics.Contracts.__ContractsRuntime+ContractException
</ExceptionType>
<StackTrace>
em System.Diagnostics.Contracts.__ContractsRuntime.TriggerFailure(ContractFailureKind kind, String msg, String userMessage, String conditionTxt, Exception inner) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\EnsureUniqueOperationIdsFilter.cs:linha 0 em System.Diagnostics.Contracts.__ContractsRuntime.ReportFailure(ContractFailureKind kind, String msg, String conditionTxt, Exception inner) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\EnsureUniqueOperationIdsFilter.cs:linha 0 em System.Diagnostics.Contracts.__ContractsRuntime.Requires(Boolean condition, String msg, String conditionTxt) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\EnsureUniqueOperationIdsFilter.cs:linha 0 em Swashbuckle.OData.SchemaRegistryExtensions.GetEdmPropertyName(MemberInfo currentProperty, IEdmStructuredType edmType) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\SchemaRegistryExtensions.cs:linha 156 em Swashbuckle.OData.SchemaRegistryExtensions.ApplyEdmModelPropertyNamesToSchema(SchemaRegistry registry, IEdmModel edmModel, Type type) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\SchemaRegistryExtensions.cs:linha 143 em Swashbuckle.OData.SchemaRegistryExtensions.GetOrRegisterParameterType(SchemaRegistry registry, IEdmModel edmModel, HttpParameterDescriptor parameterDescriptor) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\SchemaRegistryExtensions.cs:linha 33 em Swashbuckle.OData.ODataSwaggerProvider.CreateParameter(SwaggerApiParameterDescription paramDesc, Boolean inPath, SchemaRegistry schemaRegistry, IEdmModel edmModel) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 283 em Swashbuckle.OData.ODataSwaggerProvider.<>c__DisplayClass8_0.<CreateOperation>b__0(ApiParameterDescription paramDesc) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 201 em System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() em System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) em System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) em Swashbuckle.OData.ODataSwaggerProvider.CreateOperation(ApiDescription apiDescription, SchemaRegistry schemaRegistry) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 196 em Swashbuckle.OData.ODataSwaggerProvider.CreatePathItem(IEnumerable`1 apiDescriptions, SchemaRegistry schemaRegistry) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 170 em Swashbuckle.OData.ODataSwaggerProvider.<>c__DisplayClass5_0.<GenerateSwagger>b__3(IGrouping`2 group) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 83 em System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) em System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector) em Swashbuckle.OData.ODataSwaggerProvider.GenerateSwagger(String rootUrl, String apiVersion) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 79 em Swashbuckle.OData.ODataSwaggerProvider.GetSwagger(String rootUrl, String apiVersion) na C:\Users\rbeauchamp\Documents\GitHub\Swashbuckle.OData\Swashbuckle.OData\ODataSwaggerProvider.cs:linha 56 em Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) em System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) em System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) em System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) em System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0.MoveNext() --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada --- em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) em System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()
</StackTrace>
</Error>
My Project is a Web API Application with .NET Framework 4.5.2
SwaggerConfig.cs
Response api/swagger/docs/v1:
Any idea to solve this problem?