Closed MichalCar closed 7 years ago
The call Stack: System.Web.OData.dll!System.Web.OData.Routing.ODataActionSelector.SelectAction(System.Web.Http.Controllers.HttpControllerContext controllerContext) Unknown Swashbuckle.OData.dll!Swashbuckle.OData.Descriptions.HttpRequestMessageExtensions.GetHttpActionDescriptorForODataController(System.Net.Http.HttpRequestMessage request, System.Web.Http.HttpConfiguration httpConfig, System.Web.Http.Controllers.HttpControllerDescriptor controllerDescriptor) Unknown Swashbuckle.OData.dll!Swashbuckle.OData.Descriptions.HttpRequestMessageExtensions.GetHttpActionDescriptor(System.Net.Http.HttpRequestMessage request, System.Web.Http.HttpConfiguration httpConfig) Unknown Swashbuckle.OData.dll!Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.GetActionDescriptors(System.Net.Http.HttpMethod httpMethod, Swashbuckle.Swagger.Operation potentialOperation, Swashbuckle.OData.Descriptions.SwaggerRoute potentialSwaggerRoute, System.Web.Http.HttpConfiguration httpConfig) Unknown Swashbuckle.OData.dll!Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.GetActionDescriptors(Swashbuckle.OData.Descriptions.SwaggerRoute potentialSwaggerRoute, System.Web.Http.HttpConfiguration httpConfig) Unknown
The same is happening to me. I think the problem is the route for the regular swagger doc.
If you have problems with the routes, try to call the swagger configuration previous to the OData configuration. This way, the swagger route will precede the rest of the Api routes and it won't get the http:\localhost:xxx/swagger route as an Api route.
closing: looks like there's a solution to this.
500 : {"$id":"1","Message":"An error has occurred.","ExceptionMessage":"Precondition failed: currentProperty != null","ExceptionType":"System.Diagnostics.Contracts.ContractsRuntime+ContractException","StackTrace":" at System.Diagnostics.Contracts.ContractsRuntime.TriggerFailure(ContractFailureKind kind, String msg, String userMessage, String conditionTxt, Exception inner)\r\n at System.Diagnostics.Contracts.ContractsRuntime.ReportFailure(ContractFailureKind kind, String msg, String conditionTxt, Exception inner)\r\n at System.Diagnostics.Contracts.ContractsRuntime.Requires(Boolean condition, String msg, String conditionTxt)\r\n at Swashbuckle.OData.SchemaRegistryExtensions.GetEdmPropertyName(MemberInfo currentProperty, IEdmStructuredType edmType)\r\n at Swashbuckle.OData.SchemaRegistryExtensions.ApplyEdmModelPropertyNamesToSchema(SchemaRegistry registry, IEdmModel edmModel, Type type)\r\n at Swashbuckle.OData.SchemaRegistryExtensions.GetOrRegisterResponseType(SchemaRegistry registry, IEdmModel edmModel, Type type)\r\n at Swashbuckle.OData.ODataSwaggerProvider.CreateOperation(ApiDescription apiDescription, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.OData.ODataSwaggerProvider.CreatePathItem(IEnumerabled 0.MoveNext()"} http://localhost:59418/swagger/docs/v1
1 apiDescriptions, SchemaRegistry schemaRegistry)\r\n at Swashbuckle.OData.ODataSwaggerProvider.<>c__DisplayClass4_0.<GetSwagger>b__3(IGrouping
2 group)\r\n at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func
2 keySelector, Func2 elementSelector, IEqualityComparer
1 comparer)\r\n at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func
2 keySelector, Func2 elementSelector)\r\n at Swashbuckle.OData.ODataSwaggerProvider.GetSwagger(String rootUrl, String apiVersion)\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at ThirdPartyWebAPI.ApiKeyVerificationChannel.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in c:\SM\NG\Trunk\Odata4\SM_NG_VH_DEV\WebAPIServerV2\ThirdPartyWebAPI\Common\ApiKeyVerificationChannel.cs:line 55\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at ThirdPartyWebAPI.Common.CorsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in c:\SM\NG\Trunk\Odata4\SM_NG_VH_DEV\WebAPIServerV2\ThirdPartyWebAPI\Common\CorsHandler.cs:line 70\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Tracing.Tracers.RequestMessageHandlerTracer.<>n__FabricatedMethod6(HttpRequestMessage , CancellationToken )\r\n at System.Web.Http.Tracing.Tracers.RequestMessageHandlerTracer.<>c__DisplayClass4.<SendAsync>b__1()\r\n at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEndAsync[TResult](ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action
1 beginTrace, Func1 execute, Action
2 endTrace, Action`1 errorTrace)\r\n at System.Web.Http.Tracing.Tracers.RequestMessageHandlerTracer.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.HttpServer.<>nFabricatedMethod9(HttpRequestMessage , CancellationToken )\r\n at System.Web.Http.HttpServer.This is my Swagger config file:
using System.Web.Http; using WebActivatorEx; using ThirdPartyWebAPI; using Swashbuckle.Application; using Swashbuckle.OData; using System; using System.IO; using System.Reflection; using ThirdPartyWebAPI.App_Start; using Swashbuckle.Swagger; using System.Web.Http.Description; using System.Collections.Generic; using System.Linq; using System.Web.Http.Controllers;
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace ThirdPartyWebAPI { public class SwaggerConfig { public static void Register() { var thisAssembly = typeof(SwaggerConfig).Assembly;
} My nugets:
and the controller
using System.Linq; using log4net; using Stabilis.Situator.OpServerTypes; using ThirdPartyWebAPI.common.Types; using SituatorLinq; using System.Web.OData; using System.Web.Http;
namespace ThirdPartyWebAPI.Controllers { public class KeywordIncidentTypesController : ODataController { private IOpClientWrapper _opClientWrapper = null; private ILog _log; private Context _LINQ;
}
Thanks