예제 #1
0
        public void OnProvidersExecuted(ApiDescriptionProviderContext context)
        {
            var endpoints = _endpointDataSource.Endpoints;

            for (var i = 0; i < endpoints.Count; i++)
            {
                if (!(endpoints[i] is RouteEndpoint routeEndpoint))
                {
                    continue;
                }

                var apiDescription = ApiDescriptionGenerator.TryCreateApiDescription(routeEndpoint);
                if (apiDescription != null)
                {
                    context.Results.Add(apiDescription);
                }
            }
        }
예제 #2
0
        public void GetRequestType(MethodInfo method)
        {
            var expected = method.GetCustomAttribute <RequestMetadataAttribute>();
            var message  = new MessageAssembler(method);

            var parameters       = ApiDescriptionGenerator.GetRequestParameters(message).ToArray();
            var headerParameters = ApiDescriptionGenerator.GetRequestHeaderParameters(message).ToArray();

            parameters.Length.ShouldBe(expected !.Parameters.Length);
            headerParameters.Length.ShouldBe(expected.HeaderParameters.Length);

            for (var i = 0; i < expected.Parameters.Length; i++)
            {
                parameters[i].ShouldBe(message.Parameters[expected.Parameters[i]]);
            }

            for (var i = 0; i < expected.HeaderParameters.Length; i++)
            {
                headerParameters[i].ShouldBe(message.Parameters[expected.HeaderParameters[i]]);
            }
        }