示例#1
0
        public void SwaggerPathHandlerWorksForSwaggerMetadataUri(string swaggerMetadataUri)
        {
            SwaggerPathHandler handler = new SwaggerPathHandler();
            IEdmModel          model   = new EdmModel();

            ODataPath path = handler.Parse(model, "http://any", swaggerMetadataUri);

            ODataPathSegment segment = path.Segments.Last();

            Assert.NotNull(path);
            Assert.Null(path.NavigationSource);
            Assert.Null(path.EdmType);
            Assert.Equal("$swagger", segment.ToString());
            Assert.IsType <SwaggerPathSegment>(segment);
        }
示例#2
0
        protected override void UpdateConfiguration(WebRouteConfiguration configuration)
        {
            var controllers = new[] { typeof(SwaggerController), typeof(MetadataController) };

            configuration.AddControllers(controllers);

            configuration.Routes.Clear();
            configuration.InsertFormatter(FormatterFactory.CreateJson(configuration));

            IODataPathHandler handler = new SwaggerPathHandler();
            IList <IODataRoutingConvention> conventions = ODataRoutingConventions.CreateDefault();

            conventions.Insert(0, new SwaggerRoutingConvention());

            configuration.MapODataServiceRoute("odata", "odata", GetEdmModel(configuration), handler, conventions);
            configuration.EnsureInitialized();
        }